diff --git a/.env.example b/.env.example new file mode 100644 index 0000000000000000000000000000000000000000..60937fa941f657b5baedda90beed212a9592da3d --- /dev/null +++ b/.env.example @@ -0,0 +1,5 @@ +POSTGRES_HOST=localhost +POSTGRES_PORT=5432 +POSTGRES_USER= +POSTGRES_PASSWORD= +POSTGRES_DATABASE= \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 3b0efc219e1ccdf02c4bb56db818482675034618..ed3799a3fcf1ec45d7e2d40c205a4b94a1abd5c7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,6 +11,7 @@ "dependencies": { "@nestjs/axios": "^3.0.2", "@nestjs/common": "^10.0.0", + "@nestjs/config": "^3.2.0", "@nestjs/core": "^10.0.0", "@nestjs/platform-express": "^10.0.0", "@nestjs/typeorm": "^10.0.2", @@ -1824,6 +1825,32 @@ } } }, + "node_modules/@nestjs/config": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/@nestjs/config/-/config-3.2.0.tgz", + "integrity": "sha512-BpYRn57shg7CH35KGT6h+hT7ZucB6Qn2B3NBNdvhD4ApU8huS5pX/Wc2e/aO5trIha606Bz2a9t9/vbiuTBTww==", + "dependencies": { + "dotenv": "16.4.1", + "dotenv-expand": "10.0.0", + "lodash": "4.17.21", + "uuid": "9.0.1" + }, + "peerDependencies": { + "@nestjs/common": "^8.0.0 || ^9.0.0 || ^10.0.0", + "rxjs": "^7.1.0" + } + }, + "node_modules/@nestjs/config/node_modules/dotenv": { + "version": "16.4.1", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.4.1.tgz", + "integrity": "sha512-CjA3y+Dr3FyFDOAMnxZEGtnW9KBR2M0JvvUtXNW+dYJL5ROWxP9DUHCwgFqpMk0OXCc0ljhaNTr2w/kutYIcHQ==", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/motdotla/dotenv?sponsor=1" + } + }, "node_modules/@nestjs/core": { "version": "10.3.3", "resolved": "https://registry.npmjs.org/@nestjs/core/-/core-10.3.3.tgz", @@ -3977,6 +4004,14 @@ "url": "https://dotenvx.com" } }, + "node_modules/dotenv-expand": { + "version": "10.0.0", + "resolved": "https://registry.npmjs.org/dotenv-expand/-/dotenv-expand-10.0.0.tgz", + "integrity": "sha512-GopVGCpVS1UKH75VKHGuQFqS1Gusej0z4FyQkPdwjil2gNIv+LNsqBlboOzpJFZKVT95GkCyWJbBSdFEFUWI2A==", + "engines": { + "node": ">=12" + } + }, "node_modules/eastasianwidth": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/eastasianwidth/-/eastasianwidth-0.2.0.tgz", @@ -6408,8 +6443,7 @@ "node_modules/lodash": { "version": "4.17.21", "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", - "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==", - "dev": true + "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==" }, "node_modules/lodash.memoize": { "version": "4.1.2", diff --git a/package.json b/package.json index 0024ad425b2d0f7d5660218631693adbda6573d7..1f1c5a9790adf7d2f639a8d849efafa899f05127 100644 --- a/package.json +++ b/package.json @@ -25,6 +25,7 @@ "dependencies": { "@nestjs/axios": "^3.0.2", "@nestjs/common": "^10.0.0", + "@nestjs/config": "^3.2.0", "@nestjs/core": "^10.0.0", "@nestjs/platform-express": "^10.0.0", "@nestjs/typeorm": "^10.0.2", diff --git a/src/app.module.ts b/src/app.module.ts index aedee62cd4d24b2846de9fcd8f750f8c9a6c6834..171261220ecfc70b89c378e1e99dfedd349b039c 100644 --- a/src/app.module.ts +++ b/src/app.module.ts @@ -22,16 +22,19 @@ import { PembimbingSeminar } from "./entities/pembimbingSeminar.entity"; import { PembimbingSidang } from "./entities/pembimbingSidang.entity"; import { PengujiSidang } from "./entities/pengujiSidang.entity"; import { RegistrasiTesisModule } from "./registrasi-tesis/registrasi-tesis.module"; +import { ConfigModule } from "@nestjs/config"; @Module({ imports: [ + ConfigModule.forRoot(), TypeOrmModule.forRoot({ type: "postgres", - host: "localhost", - port: 5432, - username: "ppl", - password: "ppl", - database: "ppl", + host: process.env.POSTGRES_HOST, + port: +process.env.POSTGRES_PORT || 5432, + username: process.env.POSTGRES_USER, + password: process.env.POSTGRES_PASSWORD, + database: process.env.POSTGRES_DATABASE, + ssl: process.env.POSTGRES_HOST !== "localhost", entities: [ Bimbingan, Pengguna,