43 lines
1.0 KiB
TypeScript
43 lines
1.0 KiB
TypeScript
import { NestFactory } from '@nestjs/core';
|
|
import { AppModule } from './app.module';
|
|
import { ValidationPipe, VersioningType } from '@nestjs/common';
|
|
import { ConfigService } from '@nestjs/config';
|
|
import { Logger } from 'nestjs-pino';
|
|
import { NestExpressApplication } from '@nestjs/platform-express';
|
|
|
|
async function bootstrap() {
|
|
const app = await NestFactory.create<NestExpressApplication>(
|
|
AppModule,
|
|
// new FastifyAdapter(),
|
|
{ bufferLogs: true },
|
|
);
|
|
|
|
const logger = app.get(Logger);
|
|
|
|
app.useLogger(logger);
|
|
app.enableCors();
|
|
app.useGlobalPipes(
|
|
new ValidationPipe({
|
|
whitelist: true,
|
|
}),
|
|
);
|
|
app.enableVersioning({
|
|
type: VersioningType.URI,
|
|
});
|
|
|
|
const configService = app.get<ConfigService>(ConfigService);
|
|
const port = configService.get<number>('port');
|
|
|
|
await app.listen(port, '0.0.0.0', () => {
|
|
logger.log('Service Started');
|
|
// if (error) {
|
|
// logger.error(error);
|
|
// process.exit(1);
|
|
// } else {
|
|
// logger.log(`Server listening on ${address}`);
|
|
// }
|
|
});
|
|
}
|
|
|
|
bootstrap();
|