mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2024-09-20 15:26:15 +08:00
added admin endpoints configuration
This commit is contained in:
parent
9e0da3b25c
commit
18f27c26db
|
@ -1,11 +1,24 @@
|
|||
// import joi from "joi";
|
||||
import { Router } from "express";
|
||||
import { authenticateRequest } from "../../middlewares/auth";
|
||||
import { asyncHandler, checkIfUserIsAdmin } from "../../middlewares/api-utils";
|
||||
import {
|
||||
asyncHandler,
|
||||
checkIfUserIsAdmin,
|
||||
validateConfiguration,
|
||||
} from "../../middlewares/api-utils";
|
||||
import * as AdminController from "../controllers/admin";
|
||||
|
||||
const router = Router();
|
||||
|
||||
router.use(
|
||||
validateConfiguration({
|
||||
criteria: (configuration) => {
|
||||
return configuration.admin.endpointsEnabled;
|
||||
},
|
||||
invalidMessage: "Admin endpoints are currently disabled.",
|
||||
})
|
||||
);
|
||||
|
||||
router.get(
|
||||
"/",
|
||||
authenticateRequest({
|
||||
|
|
|
@ -22,6 +22,9 @@ export const BASE_CONFIGURATION: MonkeyTypes.Configuration = {
|
|||
submissionsEnabled: false,
|
||||
maxFavorites: 0,
|
||||
},
|
||||
admin: {
|
||||
endpointsEnabled: false,
|
||||
},
|
||||
apeKeys: {
|
||||
endpointsEnabled: false,
|
||||
acceptKeys: false,
|
||||
|
@ -202,6 +205,16 @@ export const CONFIGURATION_FORM_SCHEMA: ObjectSchema<MonkeyTypes.Configuration>
|
|||
},
|
||||
},
|
||||
},
|
||||
admin: {
|
||||
type: "object",
|
||||
label: "Admin",
|
||||
fields: {
|
||||
endpointsEnabled: {
|
||||
type: "boolean",
|
||||
label: "Endpoints Enabled",
|
||||
},
|
||||
},
|
||||
},
|
||||
apeKeys: {
|
||||
type: "object",
|
||||
label: "Ape Keys",
|
||||
|
|
3
backend/src/types/types.d.ts
vendored
3
backend/src/types/types.d.ts
vendored
|
@ -62,6 +62,9 @@ declare namespace MonkeyTypes {
|
|||
maxMail: number;
|
||||
};
|
||||
};
|
||||
admin: {
|
||||
endpointsEnabled: boolean;
|
||||
};
|
||||
apeKeys: {
|
||||
endpointsEnabled: boolean;
|
||||
acceptKeys: boolean;
|
||||
|
|
Loading…
Reference in a new issue