forked from Cylo-Traders/Agrocylo-PIP
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup-app.ts
More file actions
29 lines (25 loc) · 813 Bytes
/
Copy pathsetup-app.ts
File metadata and controls
29 lines (25 loc) · 813 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import { INestApplication, ValidationPipe } from '@nestjs/common';
import { ConfigService } from '@nestjs/config';
import helmet from 'helmet';
/**
* Applies production-hardening middleware/pipes shared by the real bootstrap
* (main.ts) and e2e tests, which build the Nest application directly via
* `createNestApplication()` and would otherwise bypass main.ts entirely.
*/
export function configureApp(app: INestApplication): void {
const config = app.get(ConfigService);
const corsAllowedOrigins =
config.get<string[]>('app.corsAllowedOrigins') ?? [];
app.use(helmet());
app.enableCors({
origin: corsAllowedOrigins,
credentials: true,
});
app.useGlobalPipes(
new ValidationPipe({
whitelist: true,
forbidNonWhitelisted: true,
transform: true,
}),
);
}