* feat: install rate-limiter-flexible and ioredis * feat: setup redis client * feat: add withRateLimit wrapper * feat: wrap trpc endpoint in withRateLimit * feat: wrap withRateLimit on remaining routes * feat: exclude webhook route from rate limiting * chore: update compose files and readme * refactor: move into api/db packages
12 lines
338 B
TypeScript
12 lines
338 B
TypeScript
import type { NextApiRequest, NextApiResponse } from "next";
|
|
|
|
import { openApiDocument } from "@kan/api/openapi";
|
|
import { withRateLimit } from "@kan/api/utils/rateLimit";
|
|
|
|
export default withRateLimit(
|
|
{ points: 100, duration: 60 },
|
|
(req: NextApiRequest, res: NextApiResponse) => {
|
|
res.status(200).send(openApiDocument);
|
|
},
|
|
);
|