Skip to content

Commit

Permalink
fix(backend): improve envs
Browse files Browse the repository at this point in the history
  • Loading branch information
Mati365 committed Oct 22, 2024
1 parent f6fb608 commit 4e825a7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion apps/backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"check:types": "tsc"
},
"dependencies": {
"bcryptjs": "^2.4.3",
"pg-native": ">=3.0.1"
},
"devDependencies": {
Expand All @@ -24,7 +25,6 @@
"@types/pg": "^8.11.10",
"@types/pg-cursor": "^2.7.2",
"async-await-queue": "^2.1.4",
"bcryptjs": "^2.4.3",
"croner": "^8.1.1",
"dotenv": "^16.4.5",
"elastic-builder": "^2.29.0",
Expand Down
10 changes: 6 additions & 4 deletions apps/backend/src/modules/config/helpers/try-read-env-or-panic.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import process from 'node:process';

import * as dotenv from 'dotenv';
import dotenv from 'dotenv';
import { pipe } from 'fp-ts/lib/function';
import { fromError } from 'zod-validation-error';

Expand All @@ -14,8 +14,7 @@ import {
import { type ConfigT, ConfigV } from './config.dto';

export function tryReadEnvOrPanic() {
dotenv.config();

const envFile = dotenv.config();
const {
// BASE
APP_ENV,
Expand Down Expand Up @@ -48,7 +47,10 @@ export function tryReadEnvOrPanic() {
// Auth
JWT_SECRET,
JWT_EXPIRES_IN,
} = process.env ?? {};
} = {
...envFile.parsed,
...process.env,
};

const config: UnparsedEnvObject<ConfigT> = {
env: APP_ENV,
Expand Down

0 comments on commit 4e825a7

Please sign in to comment.