diff --git a/.dev.env b/.dev.env new file mode 100644 index 00000000..0a964024 --- /dev/null +++ b/.dev.env @@ -0,0 +1 @@ +DATABASE_CONNECTION_PATH=mongodb://127.0.0.1:27017/studio-api \ No newline at end of file diff --git a/package.json b/package.json index cd86a25c..41bc1ef0 100644 --- a/package.json +++ b/package.json @@ -21,6 +21,7 @@ }, "dependencies": { "@nestjs/common": "^9.0.0", + "@nestjs/config": "^2.2.0", "@nestjs/core": "^9.0.0", "@nestjs/mongoose": "^9.2.1", "@nestjs/platform-express": "^9.0.0", diff --git a/src/app.module.ts b/src/app.module.ts index 14d99a5a..e1229376 100644 --- a/src/app.module.ts +++ b/src/app.module.ts @@ -1,10 +1,14 @@ import { Module } from '@nestjs/common'; import { AppAuthModule } from './app-auth/app-auth.module'; import { MongooseModule } from '@nestjs/mongoose'; +import { ConfigModule } from '@nestjs/config'; @Module({ imports: [ AppAuthModule, - MongooseModule.forRoot('mongodb://127.0.0.1:27017/studio-api'), + ConfigModule.forRoot({ + envFilePath: '.dev.env' + }), + MongooseModule.forRoot(process.env.DATABASE_CONNECTION_PATH) ], controllers: [], providers: [], diff --git a/yarn.lock b/yarn.lock index 2af895d6..dcd3b5ef 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1425,6 +1425,16 @@ tslib "2.4.1" uuid "9.0.0" +"@nestjs/config@^2.2.0": + version "2.2.0" + resolved "https://registry.yarnpkg.com/@nestjs/config/-/config-2.2.0.tgz#9f3da35f7c4a58724c0a0817d6f04b66e6703430" + integrity sha512-78Eg6oMbCy3D/YvqeiGBTOWei1Jwi3f2pSIZcZ1QxY67kYsJzTRTkwRT8Iv30DbK0sGKc1mcloDLD5UXgZAZtg== + dependencies: + dotenv "16.0.1" + dotenv-expand "8.0.3" + lodash "4.17.21" + uuid "8.3.2" + "@nestjs/core@^9.0.0": version "9.2.1" resolved "https://registry.yarnpkg.com/@nestjs/core/-/core-9.2.1.tgz#598e51a421a0aaafc568c1a02499f7c1f9491caf" @@ -2726,6 +2736,16 @@ doctrine@^3.0.0: dependencies: esutils "^2.0.2" +dotenv-expand@8.0.3: + version "8.0.3" + resolved "https://registry.yarnpkg.com/dotenv-expand/-/dotenv-expand-8.0.3.tgz#29016757455bcc748469c83a19b36aaf2b83dd6e" + integrity sha512-SErOMvge0ZUyWd5B0NXMQlDkN+8r+HhVUsxgOO7IoPDOdDRD2JjExpN6y3KnFR66jsJMwSn1pqIivhU5rcJiNg== + +dotenv@16.0.1: + version "16.0.1" + resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-16.0.1.tgz#8f8f9d94876c35dac989876a5d3a82a267fdce1d" + integrity sha512-1K6hR6wtk2FviQ4kEiSjFiH5rpzEVi8WW0x96aztHVMhEspNpc4DVOUTEHtEva5VThQ8IaBX1Pe4gSzpVVUsKQ== + ee-first@1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/ee-first/-/ee-first-1.1.1.tgz#590c61156b0ae2f4f0255732a158b266bc56b21d"