Skip to content

Commit

Permalink
feat(api): add rate limiting plugin
Browse files Browse the repository at this point in the history
Related to #65
  • Loading branch information
JoosepAlviste committed Jun 27, 2023
1 parent ae2ae7c commit 5b36e25
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
21 changes: 21 additions & 0 deletions api/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"@escape.tech/graphql-armor": "^2.2.0",
"@fastify/cookie": "^8.3.0",
"@fastify/cors": "^8.2.1",
"@fastify/rate-limit": "^8.0.1",
"@pothos/core": "^3.29.0",
"@pothos/plugin-dataloader": "^3.17.1",
"@pothos/plugin-errors": "^3.11.0",
Expand Down
6 changes: 6 additions & 0 deletions api/src/lib/fastify.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import cookie, { type FastifyCookieOptions } from '@fastify/cookie'
import cors from '@fastify/cors'
import rateLimit from '@fastify/rate-limit'
import fastify, { type FastifyServerOptions } from 'fastify'

import { config } from '@/config'
Expand Down Expand Up @@ -31,3 +32,8 @@ await app.register(cors, {
credentials: true,
origin: [config.webapp.url],
})

await app.register(rateLimit, {
max: 100,
timeWindow: '1 minute',
})

0 comments on commit 5b36e25

Please sign in to comment.