🔧 update @nestjs/config
This commit is contained in:
		
							parent
							
								
									1961bfaa1a
								
							
						
					
					
						commit
						19e76970a2
					
				| @ -1,11 +1,10 @@ | ||||
| import { Logger, Module } from '@nestjs/common' | ||||
| import { ConfigModule } from '@nestjs/config' | ||||
| import config from 'src/common/configs/config' | ||||
| import { PrismaModule, loggingMiddleware, QueryInfo } from 'nestjs-prisma' | ||||
| import { PrismaModule, loggingMiddleware } from 'nestjs-prisma' | ||||
| 
 | ||||
| @Module({ | ||||
|   imports: [ | ||||
|     ConfigModule.forRoot({ isGlobal: true, load: [config] }), | ||||
|     ConfigModule.forRoot({ isGlobal: true }), | ||||
|     PrismaModule.forRoot({ | ||||
|       isGlobal: true, | ||||
|       prismaServiceOptions: { | ||||
|  | ||||
| @ -1,7 +0,0 @@ | ||||
| export interface Config { | ||||
|   nest: NestConfig | ||||
| } | ||||
| 
 | ||||
| export interface NestConfig { | ||||
|   port: number | ||||
| } | ||||
| @ -1,9 +0,0 @@ | ||||
| import type { Config } from './config.interface' | ||||
| 
 | ||||
| const config: Config = { | ||||
|   nest: { | ||||
|     port: parseInt(process.env.PORT) || 3000, | ||||
|   }, | ||||
| } | ||||
| 
 | ||||
| export default (): Config => config | ||||
| @ -1,4 +1,5 @@ | ||||
| import { HttpAdapterHost, NestFactory } from '@nestjs/core' | ||||
| import { ConfigService } from '@nestjs/config' | ||||
| import { PrismaClientExceptionFilter, PrismaService } from 'nestjs-prisma' | ||||
| import { AppModule } from './app.module' | ||||
| 
 | ||||
| @ -13,6 +14,9 @@ async function bootstrap() { | ||||
|   const { httpAdapter } = app.get(HttpAdapterHost) | ||||
|   app.useGlobalFilters(new PrismaClientExceptionFilter(httpAdapter)) | ||||
| 
 | ||||
|   await app.listen(3000) | ||||
|   const configService = app.get(ConfigService) | ||||
|   const PORT = configService.get<number>('PORT', 12400) | ||||
| 
 | ||||
|   await app.listen(PORT) | ||||
| } | ||||
| bootstrap() | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user