Skip to content

Commit

Permalink
feat(api): add security plugins
Browse files Browse the repository at this point in the history
Signed-off-by: iverly <github@iverly.net>
  • Loading branch information
iverly committed Dec 3, 2023
1 parent 5b59bb5 commit e515ecf
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 1 deletion.
7 changes: 7 additions & 0 deletions apps/api/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ import {
import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger';
import { ResponseFormatterInterceptor } from '@nx-next-nest-prisma-ory-template/utils';
import { Logger } from 'nestjs-pino';
import helmet from '@fastify/helmet';
import csrf from '@fastify/csrf-protection';

async function bootstrap() {
if (otelEnabled) {
Expand All @@ -38,6 +40,11 @@ async function bootstrap() {

const httpAdapter = app.getHttpAdapter();

// Security plugins
app.enableCors();
await app.register(helmet);
await app.register(csrf);

// Validation pipe
app.useGlobalPipes(
new ValidationPipe({
Expand Down
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
"postinstall": "pnpm prisma:generate"
},
"dependencies": {
"@fastify/cors": "^8.4.1",
"@fastify/csrf-protection": "^6.4.1",
"@fastify/helmet": "^11.1.1",
"@fastify/static": "^6.12.0",
"@nestjs/common": "^10.2.10",
"@nestjs/config": "^3.1.1",
Expand Down
43 changes: 42 additions & 1 deletion pnpm-lock.yaml

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

0 comments on commit e515ecf

Please sign in to comment.