mirror of
https://github.com/outline/outline.git
synced 2026-08-03 13:27:25 +03:00
chore: Refactor get+post combos to register (#13168)
This commit is contained in:
@@ -212,17 +212,14 @@ const emailCallback = async (ctx: APIContext<T.EmailCallbackReq>) => {
|
||||
client,
|
||||
});
|
||||
};
|
||||
router.get(
|
||||
router.register(
|
||||
"email.callback",
|
||||
rateLimiter(RateLimiterStrategy.FivePerMinute),
|
||||
validate(T.EmailCallbackSchema),
|
||||
emailCallback
|
||||
);
|
||||
router.post(
|
||||
"email.callback",
|
||||
rateLimiter(RateLimiterStrategy.FivePerMinute),
|
||||
validate(T.EmailCallbackSchema),
|
||||
emailCallback
|
||||
["get", "post"],
|
||||
[
|
||||
rateLimiter(RateLimiterStrategy.FivePerMinute),
|
||||
validate(T.EmailCallbackSchema),
|
||||
emailCallback,
|
||||
]
|
||||
);
|
||||
|
||||
export default router;
|
||||
|
||||
@@ -255,8 +255,11 @@ export function createOIDCRouter(
|
||||
);
|
||||
|
||||
router.get(config.id, startOAuthFlow, passport.authenticate(config.id));
|
||||
router.get(`${config.id}.callback`, passportMiddleware(config.id));
|
||||
router.post(`${config.id}.callback`, passportMiddleware(config.id));
|
||||
router.register(
|
||||
`${config.id}.callback`,
|
||||
["get", "post"],
|
||||
passportMiddleware(config.id)
|
||||
);
|
||||
|
||||
// Performs a spec-compliant RP-initiated logout against the provider's end
|
||||
// session endpoint. Passing `id_token_hint` identifies the session being
|
||||
|
||||
@@ -337,17 +337,14 @@ const handleAttachmentsRedirect = async (
|
||||
}
|
||||
};
|
||||
|
||||
router.get(
|
||||
router.register(
|
||||
"attachments.redirect",
|
||||
auth({ optional: true }),
|
||||
validate(T.AttachmentsRedirectSchema),
|
||||
handleAttachmentsRedirect
|
||||
);
|
||||
router.post(
|
||||
"attachments.redirect",
|
||||
auth({ optional: true }),
|
||||
validate(T.AttachmentsRedirectSchema),
|
||||
handleAttachmentsRedirect
|
||||
["get", "post"],
|
||||
[
|
||||
auth({ optional: true }),
|
||||
validate(T.AttachmentsRedirectSchema),
|
||||
handleAttachmentsRedirect,
|
||||
]
|
||||
);
|
||||
|
||||
export default router;
|
||||
|
||||
@@ -93,11 +93,17 @@ const cronHandler = async (ctx: APIContext<T.CronSchemaReq>) => {
|
||||
success: true,
|
||||
};
|
||||
};
|
||||
router.get("cron.:period", validate(T.CronSchema), cronHandler);
|
||||
router.post("cron.:period", validate(T.CronSchema), cronHandler);
|
||||
router.register(
|
||||
"cron.:period",
|
||||
["get", "post"],
|
||||
[validate(T.CronSchema), cronHandler]
|
||||
);
|
||||
|
||||
// For backwards compatibility
|
||||
router.get("utils.gc", validate(T.CronSchema), cronHandler);
|
||||
router.post("utils.gc", validate(T.CronSchema), cronHandler);
|
||||
router.register(
|
||||
"utils.gc",
|
||||
["get", "post"],
|
||||
[validate(T.CronSchema), cronHandler]
|
||||
);
|
||||
|
||||
export default router;
|
||||
|
||||
@@ -92,17 +92,14 @@ const handleFileOperationsRedirect = async (
|
||||
ctx.redirect(accessUrl);
|
||||
};
|
||||
|
||||
router.get(
|
||||
router.register(
|
||||
"fileOperations.redirect",
|
||||
auth(),
|
||||
validate(T.FileOperationsRedirectSchema),
|
||||
handleFileOperationsRedirect
|
||||
);
|
||||
router.post(
|
||||
"fileOperations.redirect",
|
||||
auth(),
|
||||
validate(T.FileOperationsRedirectSchema),
|
||||
handleFileOperationsRedirect
|
||||
["get", "post"],
|
||||
[
|
||||
auth(),
|
||||
validate(T.FileOperationsRedirectSchema),
|
||||
handleFileOperationsRedirect,
|
||||
]
|
||||
);
|
||||
|
||||
router.post(
|
||||
|
||||
@@ -131,11 +131,7 @@ if (env.isDevelopment) {
|
||||
router.use("/", developer.routes());
|
||||
}
|
||||
|
||||
router.post("*", (ctx) => {
|
||||
ctx.throw(NotFoundError("Endpoint not found"));
|
||||
});
|
||||
|
||||
router.get("*", (ctx) => {
|
||||
router.register("*", ["get", "post"], (ctx) => {
|
||||
ctx.throw(NotFoundError("Endpoint not found"));
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user