add config

This commit is contained in:
Jurgis Sakalauskas
2022-12-08 21:20:35 +02:00
parent b938f1a3ba
commit b353e00bec
3 changed files with 34 additions and 6 deletions
+20 -6
View File
@@ -16,6 +16,7 @@
"@nestjs/platform-express": "^9.0.0", "@nestjs/platform-express": "^9.0.0",
"@nestjs/serve-static": "^3.0.0", "@nestjs/serve-static": "^3.0.0",
"@nestjs/typeorm": "^9.0.1", "@nestjs/typeorm": "^9.0.1",
"dotenv": "^16.0.3",
"reflect-metadata": "^0.1.13", "reflect-metadata": "^0.1.13",
"rimraf": "^3.0.2", "rimraf": "^3.0.2",
"rxjs": "^7.2.0", "rxjs": "^7.2.0",
@@ -1611,6 +1612,14 @@
"rxjs": "^6.0.0 || ^7.2.0" "rxjs": "^6.0.0 || ^7.2.0"
} }
}, },
"node_modules/@nestjs/config/node_modules/dotenv": {
"version": "16.0.1",
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.0.1.tgz",
"integrity": "sha512-1K6hR6wtk2FviQ4kEiSjFiH5rpzEVi8WW0x96aztHVMhEspNpc4DVOUTEHtEva5VThQ8IaBX1Pe4gSzpVVUsKQ==",
"engines": {
"node": ">=12"
}
},
"node_modules/@nestjs/config/node_modules/uuid": { "node_modules/@nestjs/config/node_modules/uuid": {
"version": "8.3.2", "version": "8.3.2",
"resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz",
@@ -3902,9 +3911,9 @@
} }
}, },
"node_modules/dotenv": { "node_modules/dotenv": {
"version": "16.0.1", "version": "16.0.3",
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.0.1.tgz", "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.0.3.tgz",
"integrity": "sha512-1K6hR6wtk2FviQ4kEiSjFiH5rpzEVi8WW0x96aztHVMhEspNpc4DVOUTEHtEva5VThQ8IaBX1Pe4gSzpVVUsKQ==", "integrity": "sha512-7GO6HghkA5fYG9TYnNxi14/7K9f5occMlp3zXAuSxn7CKCxt9xbNWG7yF8hTCSUchlfWSe3uLmlPfigevRItzQ==",
"engines": { "engines": {
"node": ">=12" "node": ">=12"
} }
@@ -10815,6 +10824,11 @@
"uuid": "8.3.2" "uuid": "8.3.2"
}, },
"dependencies": { "dependencies": {
"dotenv": {
"version": "16.0.1",
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.0.1.tgz",
"integrity": "sha512-1K6hR6wtk2FviQ4kEiSjFiH5rpzEVi8WW0x96aztHVMhEspNpc4DVOUTEHtEva5VThQ8IaBX1Pe4gSzpVVUsKQ=="
},
"uuid": { "uuid": {
"version": "8.3.2", "version": "8.3.2",
"resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz",
@@ -12566,9 +12580,9 @@
} }
}, },
"dotenv": { "dotenv": {
"version": "16.0.1", "version": "16.0.3",
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.0.1.tgz", "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.0.3.tgz",
"integrity": "sha512-1K6hR6wtk2FviQ4kEiSjFiH5rpzEVi8WW0x96aztHVMhEspNpc4DVOUTEHtEva5VThQ8IaBX1Pe4gSzpVVUsKQ==" "integrity": "sha512-7GO6HghkA5fYG9TYnNxi14/7K9f5occMlp3zXAuSxn7CKCxt9xbNWG7yF8hTCSUchlfWSe3uLmlPfigevRItzQ=="
}, },
"dotenv-expand": { "dotenv-expand": {
"version": "8.0.3", "version": "8.0.3",
+1
View File
@@ -28,6 +28,7 @@
"@nestjs/platform-express": "^9.0.0", "@nestjs/platform-express": "^9.0.0",
"@nestjs/serve-static": "^3.0.0", "@nestjs/serve-static": "^3.0.0",
"@nestjs/typeorm": "^9.0.1", "@nestjs/typeorm": "^9.0.1",
"dotenv": "^16.0.3",
"reflect-metadata": "^0.1.13", "reflect-metadata": "^0.1.13",
"rimraf": "^3.0.2", "rimraf": "^3.0.2",
"rxjs": "^7.2.0", "rxjs": "^7.2.0",
+13
View File
@@ -0,0 +1,13 @@
import * as Dotenv from 'dotenv';
const dotenv: any = Dotenv.config().parsed;
class Config {
public readonly port = dotenv.PORT;
getPort() {
return process.env.PORT;
}
//todo - check dotenv again if not loaded before emmiting err.
//works globally, loaded once
}
export default new Config();