added admin endpoints configuration

This commit is contained in:
Miodec 2023-03-27 15:12:33 +02:00
parent 9e0da3b25c
commit 18f27c26db
3 changed files with 30 additions and 1 deletions

View file

@ -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({

View file

@ -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",

View file

@ -62,6 +62,9 @@ declare namespace MonkeyTypes {
maxMail: number;
};
};
admin: {
endpointsEnabled: boolean;
};
apeKeys: {
endpointsEnabled: boolean;
acceptKeys: boolean;