added endpoint to check if quote submission is enabled

This commit is contained in:
Miodec 2023-07-25 16:40:29 +02:00
parent 2e8c58365f
commit 574532f280
3 changed files with 26 additions and 0 deletions

View file

@ -35,6 +35,16 @@ export async function getQuotes(
return new MonkeyResponse("Quote submissions retrieved", data);
}
export async function isSubmissionEnabled(
req: MonkeyTypes.Request
): Promise<MonkeyResponse> {
const { submissionsEnabled } = req.ctx.configuration.quotes;
return new MonkeyResponse(
"Quote submission " + (submissionsEnabled ? "enabled" : "disabled"),
submissionsEnabled
);
}
export async function addQuote(
req: MonkeyTypes.Request
): Promise<MonkeyResponse> {

View file

@ -26,6 +26,15 @@ router.get(
asyncHandler(QuoteController.getQuotes)
);
router.get(
"/isSubmissionEnabled",
authenticateRequest({
isPublic: true,
}),
RateLimit.newQuotesIsSubmissionEnabled,
asyncHandler(QuoteController.isSubmissionEnabled)
);
router.post(
"/",
validateConfiguration({

View file

@ -136,6 +136,13 @@ export const newQuotesGet = rateLimit({
handler: customHandler,
});
export const newQuotesIsSubmissionEnabled = rateLimit({
windowMs: 60 * 1000,
max: 60 * REQUEST_MULTIPLIER,
keyGenerator: getKeyWithUid,
handler: customHandler,
});
export const newQuotesAdd = rateLimit({
windowMs: ONE_HOUR_MS,
max: 60 * REQUEST_MULTIPLIER,