Skip to content

Commit

Permalink
feat: add fastify compression
Browse files Browse the repository at this point in the history
  • Loading branch information
lamngockhuong committed Nov 8, 2024
1 parent 8b2d465 commit fbcc82b
Show file tree
Hide file tree
Showing 3 changed files with 91 additions and 8 deletions.
1 change: 1 addition & 0 deletions apps/admin-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"test:e2e": "jest --config ./test/jest-e2e.json"
},
"dependencies": {
"@fastify/compress": "^7.0.3",
"@fastify/helmet": "^11.1.1",
"@fastify/static": "^7.0.4",
"@nestjs/common": "^10.4.6",
Expand Down
4 changes: 4 additions & 0 deletions apps/admin-api/src/main.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import compression from '@fastify/compress';
import helmet from '@fastify/helmet';
import {
ClassSerializerInterceptor,
Expand Down Expand Up @@ -53,6 +54,9 @@ async function bootstrap() {
// Setup security headers
app.register(helmet);

// For high-traffic websites in production, it is strongly recommended to offload compression from the application server - typically in a reverse proxy (e.g., Nginx). In that case, you should not use compression middleware.
app.register(compression);

const configService = app.get(ConfigService<AllConfigType>);
const reflector = app.get(Reflector);

Expand Down
94 changes: 86 additions & 8 deletions pnpm-lock.yaml

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

0 comments on commit fbcc82b

Please sign in to comment.