feat(api): ratelimiting
because some group of idiots like me so much that they spam my endpoint
This commit is contained in:
@@ -7,6 +7,14 @@ export default defineEventHandler(async (event) => {
|
||||
FeedbackSchema.parseAsync
|
||||
)
|
||||
const env = useRuntimeConfig(event)
|
||||
const { pathname } = new URL(event.node.req.url)
|
||||
|
||||
const { success } = await env.MY_RATE_LIMITER.limit({ key: pathname })
|
||||
if (!success) {
|
||||
return new Response(`429 Failure – rate limit exceeded for ${pathname}`, {
|
||||
status: 429
|
||||
})
|
||||
}
|
||||
|
||||
let description = `${message}\n\n`
|
||||
if (page) description += `**Page:** \`${page}\``
|
||||
|
Reference in New Issue
Block a user