Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor/env #15

Merged
merged 4 commits into from
Jun 29, 2024
Merged

Refactor/env #15

merged 4 commits into from
Jun 29, 2024

Conversation

sally0226
Copy link
Collaborator

PR Type

  • Bugfix
  • Feature
  • Docs
  • Refactoring (no functional changes, no api changes)

For what purpose

서버에서 실행되는 경우 env file을 로드하지 않도록 수정

Key changes

  1. NODE_ENV가 stage, production일 경우 ignoreEnvFile = true로 설정

To reviewers

ignoreEnvFile 관련 문서

- 서버에서 실행할 때, (staging, production)에는 env파일에서 로딩하지 않도록 수정
환경에 따라 서버에서 실행되는 경우 ignoreEnvFile==true 가 되도록 설정
src/common/helper/env.helper.ts Show resolved Hide resolved
src/app.module.ts Outdated Show resolved Hide resolved
@@ -13,16 +13,16 @@ const stage = 'stage';
const production = 'production';
const test = 'test';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

갑자기 생각난 건데, 여기 const들 재사용 안되니까,

export type ArrayElement<T extends readonly unknown[]> = T extends readonly (infer K)[] ? K : never;

const array = ['development', 'stage', 'production', 'test'] as const;

type ArrayType = ArrayElement<typeof array>;

const NODE_ENVIRONMENT = array.reduce(
  (acc, cur) => {
    acc[cur] = cur;
    return acc;
  },
  {} as Record<ArrayType, ArrayType>,
);

이런식으로 가는 거 어떨까요?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

올려준 방식은 아니지만 NODE_ENV한번만 로드해서 사용할 수 있도록 수정했습니당

NODE_ENV를 한번만 로드하고 사용할 수 있도록 수정
- 중복 코드 제거

Refactor: refactor get NODE_ENV

Refactor: refactor get NODE_ENV
@sally0226 sally0226 merged commit 081d6e7 into stage Jun 29, 2024
3 checks passed
@sally0226 sally0226 deleted the refactor/env branch June 29, 2024 05:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants