-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Refactor: Edit getEnvPath - 서버에서 실행할 때, (staging, production)에는 env파일에서 로딩하지 않도록 수정 * Refactor: Set ignoreEnvFile 환경에 따라 서버에서 실행되는 경우 ignoreEnvFile==true 가 되도록 설정 * Refactor: refactor get NODE_ENV NODE_ENV를 한번만 로드하고 사용할 수 있도록 수정 - 중복 코드 제거 Refactor: refactor get NODE_ENV Refactor: refactor get NODE_ENV
- Loading branch information
Showing
3 changed files
with
22 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,16 @@ | ||
import { resolve } from 'path'; | ||
import { InternalServerErrorException } from '@nestjs/common'; | ||
|
||
export const getEnvPath = (dest: string): string => { | ||
const env: string = process.env.NODE_ENV; | ||
const filename: string = env ? `.${env}.env` : '.development.env'; | ||
return resolve(`${dest}/${filename}`); | ||
}; | ||
import { NODE_ENVIRONMENT } from './env.validation'; | ||
|
||
export const getNodeEnv = (() => { | ||
const env = process.env.NODE_ENV; | ||
const nodeEnv = NODE_ENVIRONMENT[env]; | ||
if (nodeEnv === undefined) { | ||
throw new InternalServerErrorException('Unknown NODE_ENV'); | ||
} | ||
return nodeEnv; | ||
})(); | ||
|
||
export const isIgnoreEnvFile = | ||
getNodeEnv === NODE_ENVIRONMENT.stage || | ||
getNodeEnv === NODE_ENVIRONMENT.production; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters