From 8b0b43177d9913082103c0c5f99a2d01338453c3 Mon Sep 17 00:00:00 2001 From: A1BFF9F Date: Sat, 13 Apr 2024 18:53:54 +0200 Subject: [PATCH] add config --- apps/auth/src/auth.module.ts | 9 +++++++++ apps/gateway/src/gateway.module.ts | 1 + package.json | 2 ++ 3 files changed, 12 insertions(+) diff --git a/apps/auth/src/auth.module.ts b/apps/auth/src/auth.module.ts index 0ac3f11..a3865c4 100644 --- a/apps/auth/src/auth.module.ts +++ b/apps/auth/src/auth.module.ts @@ -8,6 +8,8 @@ import { MongooseModule } from '@nestjs/mongoose'; import { UsersService } from './users/users.service'; import { UserSchema } from './users/users.schema'; import { LoggerModule } from '@app/common'; +import * as Joi form 'joi'; +import { ConfigModule } from '@nestjs/config'; @Module({ imports: [ @@ -18,6 +20,13 @@ import { LoggerModule } from '@app/common'; secret: jwtConstants.secret, signOptions: { expiresIn: '60s' }, }), + ConfigModule.forRoot({ + isGlobal: true, + validationSchema: Joi.object({ + MONGODB_URI: Joi.string().default('mongodb://admin:secret@mongodb/'), + MONGODB_DATABASE: Joi.string().default('auth'), + }), + }), MongooseModule.forRoot( 'mongodb://admin:secret@mongodb/auth?authSource=admin', ), diff --git a/apps/gateway/src/gateway.module.ts b/apps/gateway/src/gateway.module.ts index 1b1a020..bfe4d76 100644 --- a/apps/gateway/src/gateway.module.ts +++ b/apps/gateway/src/gateway.module.ts @@ -7,6 +7,7 @@ import { JwtModule } from '@nestjs/jwt'; import { jwtConstants } from 'apps/auth/src/auth.constants'; import { APP_GUARD } from '@nestjs/core'; import { AuthGuard } from '@app/common'; +import { LoggerModule } from '@app/common'; @Module({ imports: [ diff --git a/package.json b/package.json index e853b92..f25645e 100644 --- a/package.json +++ b/package.json @@ -33,6 +33,7 @@ "bcrypt": "^5.1.1", "class-transformer": "^0.5.1", "class-validator": "^0.14.1", + "joi": "^17.12.3", "cookie-parser": "^1.4.6", "express": "^4.19.2", "mongoose": "^8.2.4", @@ -52,6 +53,7 @@ "@nestjs/testing": "^10.0.0", "@types/express": "^4.17.17", "@types/jest": "^29.5.2", + "@types/joi": "^17.2.3", "@types/node": "^20.3.1", "@types/supertest": "^2.0.12", "@typescript-eslint/eslint-plugin": "^6.0.0",