Add rate limiting to unfurl endpoint
This commit is contained in:
@@ -3,17 +3,20 @@ import parseDocumentSlug from "@shared/utils/parseDocumentSlug";
|
|||||||
import parseMentionUrl from "@shared/utils/parseMentionUrl";
|
import parseMentionUrl from "@shared/utils/parseMentionUrl";
|
||||||
import { NotFoundError } from "@server/errors";
|
import { NotFoundError } from "@server/errors";
|
||||||
import auth from "@server/middlewares/authentication";
|
import auth from "@server/middlewares/authentication";
|
||||||
|
import { rateLimiter } from "@server/middlewares/rateLimiter";
|
||||||
import validate from "@server/middlewares/validate";
|
import validate from "@server/middlewares/validate";
|
||||||
import { Document, User } from "@server/models";
|
import { Document, User } from "@server/models";
|
||||||
import { authorize } from "@server/policies";
|
import { authorize } from "@server/policies";
|
||||||
import { presentDocument, presentMention } from "@server/presenters/unfurls";
|
import { presentDocument, presentMention } from "@server/presenters/unfurls";
|
||||||
import { APIContext } from "@server/types";
|
import { APIContext } from "@server/types";
|
||||||
|
import { RateLimiterStrategy } from "@server/utils/RateLimiter";
|
||||||
import * as T from "./schema";
|
import * as T from "./schema";
|
||||||
|
|
||||||
const router = new Router();
|
const router = new Router();
|
||||||
|
|
||||||
router.post(
|
router.post(
|
||||||
"urls.unfurl",
|
"urls.unfurl",
|
||||||
|
rateLimiter(RateLimiterStrategy.OneThousandPerHour),
|
||||||
auth(),
|
auth(),
|
||||||
validate(T.UrlsUnfurlSchema),
|
validate(T.UrlsUnfurlSchema),
|
||||||
async (ctx: APIContext<T.UrlsUnfurlReq>) => {
|
async (ctx: APIContext<T.UrlsUnfurlReq>) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user