Skip to content

Commit 6bd5941

Browse files
feat: initialize NestJS application with global validation pipe and configuration-based port listening.
1 parent d13ae85 commit 6bd5941

1 file changed

Lines changed: 4 additions & 6 deletions

File tree

backend/src/main.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
import { ValidationPipe } from '@nestjs/common';
22
import { NestFactory } from '@nestjs/core';
3+
import { ConfigService } from '@nestjs/config';
34
import { AppModule } from './app.module';
4-
import { AppConfigService } from './common/config/app-config.service';
55

66
async function bootstrap() {
77
const app = await NestFactory.create(AppModule);
8-
const appConfigService = app.get(AppConfigService);
9-
10-
app.setGlobalPrefix(appConfigService.apiPrefix);
8+
const configService = app.get(ConfigService);
119

1210
app.useGlobalPipes(
1311
new ValidationPipe({
@@ -16,7 +14,7 @@ async function bootstrap() {
1614
transform: true,
1715
}),
1816
);
19-
20-
await app.listen(appConfigService.port);
17+
const PORT = configService.get<number>('port') || 3000;
18+
await app.listen(PORT);
2119
}
2220
bootstrap();

0 commit comments

Comments
 (0)