mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2026-01-11 01:44:50 +08:00
added endpoint to check if quote submission is enabled
This commit is contained in:
parent
2e8c58365f
commit
574532f280
3 changed files with 26 additions and 0 deletions
|
|
@ -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> {
|
||||
|
|
|
|||
|
|
@ -26,6 +26,15 @@ router.get(
|
|||
asyncHandler(QuoteController.getQuotes)
|
||||
);
|
||||
|
||||
router.get(
|
||||
"/isSubmissionEnabled",
|
||||
authenticateRequest({
|
||||
isPublic: true,
|
||||
}),
|
||||
RateLimit.newQuotesIsSubmissionEnabled,
|
||||
asyncHandler(QuoteController.isSubmissionEnabled)
|
||||
);
|
||||
|
||||
router.post(
|
||||
"/",
|
||||
validateConfiguration({
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue