Commit ad37ca6f authored by nanahira's avatar nanahira

improve

parent 4753daf5
Pipeline #6547 passed with stages
in 1 minute and 59 seconds
...@@ -3,7 +3,9 @@ npm install --save \ ...@@ -3,7 +3,9 @@ npm install --save \
class-validator \ class-validator \
class-transformer \ class-transformer \
@nestjs/swagger \ @nestjs/swagger \
@nestjs/config \
swagger-ui-express \ swagger-ui-express \
yaml
npm install --save-dev \ npm install --save-dev \
@types/express @types/express
import { Module } from '@nestjs/common'; import { Module } from '@nestjs/common';
import { AppController } from './app.controller'; import { AppController } from './app.controller';
import { AppService } from './app.service'; import { AppService } from './app.service';
import { ConfigModule } from '@nestjs/config';
import { loadConfig } from './utility/config';
@Module({ @Module({
imports: [], imports: [
ConfigModule.forRoot({
ignoreEnvVars: true,
load: [loadConfig],
}),
],
controllers: [AppController], controllers: [AppController],
providers: [AppService], providers: [AppService],
}) })
......
...@@ -2,6 +2,7 @@ import { NestFactory } from '@nestjs/core'; ...@@ -2,6 +2,7 @@ import { NestFactory } from '@nestjs/core';
import { SwaggerModule, DocumentBuilder } from '@nestjs/swagger'; import { SwaggerModule, DocumentBuilder } from '@nestjs/swagger';
import { NestExpressApplication } from '@nestjs/platform-express'; import { NestExpressApplication } from '@nestjs/platform-express';
import { AppModule } from './app.module'; import { AppModule } from './app.module';
import { ConfigService } from '@nestjs/config';
async function bootstrap() { async function bootstrap() {
const app = await NestFactory.create<NestExpressApplication>(AppModule); const app = await NestFactory.create<NestExpressApplication>(AppModule);
...@@ -17,6 +18,10 @@ async function bootstrap() { ...@@ -17,6 +18,10 @@ async function bootstrap() {
const document = SwaggerModule.createDocument(app, documentConfig); const document = SwaggerModule.createDocument(app, documentConfig);
SwaggerModule.setup('docs', app, document); SwaggerModule.setup('docs', app, document);
await app.listen(3000); const config = app.get(ConfigService);
await app.listen(
config.get<number>('port') || 3000,
config.get<string>('host') || '::',
);
} }
bootstrap(); bootstrap();
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment