diff --git a/apps/cat-fostering-api/package.json b/apps/cat-fostering-api/package.json index 6fe6716..5b95fae 100644 --- a/apps/cat-fostering-api/package.json +++ b/apps/cat-fostering-api/package.json @@ -16,6 +16,7 @@ "nestjs-pino": "^4.0.0", "typeorm": "^0.3.20", "pg": "^8.11.5", - "validator": "13.11.0" + "validator": "13.11.0", + "@nestjs/devtools-integration": "0.1.6" } } diff --git a/apps/cat-fostering-api/src/app/app.module.ts b/apps/cat-fostering-api/src/app/app.module.ts index 64e9e82..44e7c20 100644 --- a/apps/cat-fostering-api/src/app/app.module.ts +++ b/apps/cat-fostering-api/src/app/app.module.ts @@ -2,7 +2,8 @@ import { CatProfilesModule } from '@cat-fostering/nestjs-catprofile-module'; import { FosteringModule } from '@cat-fostering/nestjs-fostering-module'; import { UsersModule } from '@cat-fostering/nestjs-user-module'; import { Module } from '@nestjs/common'; -import { ConfigModule, ConfigService } from '@nestjs/config'; +import { ConditionalModule, ConfigModule, ConfigService } from '@nestjs/config'; +import { DevtoolsModule } from '@nestjs/devtools-integration'; import { TypeOrmModule } from '@nestjs/typeorm'; import { LoggerModule } from 'nestjs-pino'; import path from 'node:path'; @@ -29,6 +30,18 @@ import { ) ), }), + ConditionalModule.registerWhen( + DevtoolsModule.registerAsync({ + inject: [ConfigService], + useFactory: ( + configService: ConfigService + ) => ({ + http: true, + port: configService.get('DEVTOOLS_PORT', { infer: true }), + }), + }), + (env: NodeJS.ProcessEnv) => env.NODE_ENV === 'development' + ), LoggerModule.forRoot({ pinoHttp: { redact: [ diff --git a/apps/cat-fostering-api/src/app/environment-variables.ts b/apps/cat-fostering-api/src/app/environment-variables.ts index 30cadbc..d2a905d 100644 --- a/apps/cat-fostering-api/src/app/environment-variables.ts +++ b/apps/cat-fostering-api/src/app/environment-variables.ts @@ -42,6 +42,16 @@ export class EnvironmentVariables { @IsNumber() PORT?: number = 3000; + @Expose() + @IsString() + @IsOptional() + HOST?: string = '0.0.0.0'; + + @Expose() + @IsOptional() + @IsNumber() + DEVTOOLS_PORT?: number = 8000; + @Expose() @IsUrl({ protocols: ['postgres', 'postgresql'], diff --git a/apps/cat-fostering-api/src/main.ts b/apps/cat-fostering-api/src/main.ts index 1adc319..57d24bb 100644 --- a/apps/cat-fostering-api/src/main.ts +++ b/apps/cat-fostering-api/src/main.ts @@ -27,6 +27,7 @@ async function bootstrap() { { logger: ['error', 'warn', 'log', 'debug', 'verbose'], bufferLogs: true, + snapshot: true, } ); const configService = @@ -94,7 +95,8 @@ async function bootstrap() { SwaggerModule.setup('open-api', app, document, customOptions); const port = configService.get('PORT', { infer: true }); - await app.listen(port); + const host = configService.get('HOST', { infer: true }); + await app.listen(port, host); logger.log( `🚀 Application is running on: http://localhost:${port}/${globalPrefix}` ); diff --git a/package-lock.json b/package-lock.json index e7b89f8..9208de7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -33,6 +33,7 @@ "@nestjs/common": "^10.0.2", "@nestjs/config": "^3.2.1", "@nestjs/core": "^10.0.2", + "@nestjs/devtools-integration": "0.1.6", "@nestjs/platform-express": "^10.0.2", "@nestjs/swagger": "^7.3.1", "@nestjs/typeorm": "^10.0.2", @@ -6316,6 +6317,19 @@ } } }, + "node_modules/@nestjs/devtools-integration": { + "version": "0.1.6", + "resolved": "https://registry.npmjs.org/@nestjs/devtools-integration/-/devtools-integration-0.1.6.tgz", + "integrity": "sha512-7v2Oa7g2zxYB2DfRz5RsRyNOlrbPc32NG3FowyI3nGCOWtNaRAuZtAx7LjdnIphQGXDuIgVNMLROQaKpxI1eWg==", + "dependencies": { + "chalk": "^4.1.2", + "node-fetch": "^2.6.9" + }, + "peerDependencies": { + "@nestjs/common": "^9.3.7 || ^10.0.0", + "@nestjs/core": "^9.3.7 || ^10.0.0" + } + }, "node_modules/@nestjs/mapped-types": { "version": "2.0.5", "resolved": "https://registry.npmjs.org/@nestjs/mapped-types/-/mapped-types-2.0.5.tgz", diff --git a/package.json b/package.json index 9619a41..aefdc01 100644 --- a/package.json +++ b/package.json @@ -39,6 +39,7 @@ "@nestjs/common": "^10.0.2", "@nestjs/config": "^3.2.1", "@nestjs/core": "^10.0.2", + "@nestjs/devtools-integration": "0.1.6", "@nestjs/platform-express": "^10.0.2", "@nestjs/swagger": "^7.3.1", "@nestjs/typeorm": "^10.0.2", @@ -73,13 +74,13 @@ "@nx-tools/nx-container": "^6.0.1", "@nx/angular": "19.3.1", "@nx/devkit": "19.3.1", - "@nx/playwright": "19.3.1", "@nx/eslint": "19.3.1", "@nx/eslint-plugin": "19.3.1", "@nx/jest": "19.3.1", "@nx/js": "19.3.1", "@nx/nest": "19.3.1", "@nx/node": "19.3.1", + "@nx/playwright": "19.3.1", "@nx/web": "19.3.1", "@nx/webpack": "19.3.1", "@openapitools/openapi-generator-cli": "^2.13.4",