Skip to content

Commit 7e35766

Browse files
authored
환경변수 정리 (#135)
* chore: 환경변수 줄이기 * docs: 기여문서 업데이트 * chore: docker-compose 파일 수정 * chore: update .env.example
1 parent 81c1ede commit 7e35766

File tree

7 files changed

+40
-50
lines changed

7 files changed

+40
-50
lines changed

.env.example

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,16 @@
1-
VITE_BASE_SERVER_URL_DEV=
2-
VITE_BASE_SERVER_URL_PROD=
1+
VITE_BASE_SERVER_URL=
32
VITE_AUTH0_DOMAIN=
43
VITE_AUTH0_CLIENT_ID=
54
VITE_EMAIL_DOMAIN_NAME=
65

7-
BASE_SERVER_URL_DEV=
8-
BASE_SERVER_URL_PROD=
6+
SLACK_BOT_TOKEN=
97

10-
SLACK_BOT_TOKEN_DEV=
11-
SLACK_BOT_TOKEN_PROD=
8+
CODEPOCKET_CHANNEL_ID=
129

13-
CODEPOCKET_CHANNEL_ID_DEV=
14-
CODEPOCKET_CHANNEL_ID_PROD=
10+
CHAPTER_FRONTED_CHANNEL_ID=
1511

16-
CHAPTER_FRONTED_CHANNEL_ID_DEV=
17-
CHAPTER_FRONTED_CHANNEL_ID_PROD=
12+
MONGO_DB_URI=
1813

19-
MONGO_DB_URI_DEV=
20-
MONGO_DB_URI_PROD=
14+
MONGO_DB_NAME=
2115

22-
MONGO_DB_NAME_DEV=
23-
MONGO_DB_NAME_PROD=
16+
BASE_SERVER_URL=

CONTRIBUTING.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,25 @@ yarn set version 3.2.1
1010

1111
### .env 작성하기
1212

13-
아래와 같이 .env파일을 만들어주세요!
13+
아래와 같이 .env파일을 만들어주세요!(뒤에 !가 들어가있는 부분은 직접 값을 넣어주셔야해요)
1414

1515
```
16+
VITE_BASE_SERVER_URL=http://0.0.0.0:8080
17+
VITE_AUTH0_DOMAIN=AUTO0 도메인!
18+
VITE_AUTH0_CLIENT_ID=AUTH0 클라이언트 아이디!
19+
VITE_EMAIL_DOMAIN_NAME=*
1620
21+
SLACK_BOT_TOKEN=슬랙 봇 토큰!
22+
23+
CODEPOCKET_CHANNEL_ID=코드 알림이 올라올 슬랙 채널 아이디!
24+
25+
CHAPTER_FRONTED_CHANNEL_ID=코드가 올라올 슬랙 채널 아이디!
26+
27+
MONGO_DB_URI=mongodb://root:example@localhost:27017
28+
29+
MONGO_DB_NAME=codepocket
30+
31+
BASE_SERVER_URL=http://0.0.0.0:8080
1732
```
1833

1934
### Codepocket 구동하기

client/src/env.d.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
interface ImportMetaEnv {
2-
readonly VITE_BASE_SERVER_URL_DEV: string;
3-
readonly VITE_BASE_SERVER_URL_PROD: string;
2+
readonly VITE_BASE_SERVER_URL: string;
43
readonly VITE_AUTH0_DOMAIN: string;
54
readonly VITE_AUTH0_CLIENT_ID: string;
65
readonly VITE_EMAIL_DOMAIN_NAME: string;

client/src/shared/constant.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
export const BASE_LOCAL_SERVER_URL = import.meta.env.VITE_BASE_SERVER_URL_DEV;
2-
export const BASE_PROD_SERVER_URL = import.meta.env.VITE_BASE_SERVER_URL_PROD;
1+
export const BASE_SERVER_URL = import.meta.env.VITE_BASE_SERVER_URL;
32

43
export const AUTH0_DOMAIN = import.meta.env.VITE_AUTH0_DOMAIN;
54
export const AUTH0_CLIENT_ID = import.meta.env.VITE_AUTH0_CLIENT_ID;

client/src/shared/lib/axios.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import axios, { AxiosResponse } from 'axios';
22

3-
import { BASE_LOCAL_SERVER_URL, BASE_PROD_SERVER_URL } from '../constant';
3+
import { BASE_SERVER_URL } from '../constant';
44

55
export interface ResponseType<T> extends AxiosResponse {
66
data: T;
@@ -26,5 +26,5 @@ const transformResponse = (data: string) => {
2626

2727
export const axiosInstance = axios.create({
2828
transformResponse,
29-
baseURL: process.env.NODE_ENV === 'development' ? BASE_LOCAL_SERVER_URL : BASE_PROD_SERVER_URL,
29+
baseURL: BASE_SERVER_URL,
3030
});

docker-compose.yml

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,13 @@ services:
2424
- '8080:8080'
2525
environment:
2626
NODE_ENV: development
27-
VITE_BASE_SERVER_URL_DEV: ${VITE_BASE_SERVER_URL_DEV}
28-
VITE_BASE_SERVER_URL_PROD: ${VITE_BASE_SERVER_URL_PROD}
27+
VITE_BASE_SERVER_URL: ${VITE_BASE_SERVER_URL}
2928
VITE_AUTH0_DOMAIN: ${VITE_AUTH0_DOMAIN}
3029
VITE_AUTH0_CLIENT_ID: ${VITE_AUTH0_CLIENT_ID}
3130
VITE_EMAIL_DOMAIN_NAME: ${VITE_EMAIL_DOMAIN_NAME}
32-
BASE_SERVER_URL_DEV: ${BASE_SERVER_URL_DEV}
33-
BASE_SERVER_URL_PROD: ${BASE_SERVER_URL_PROD}
34-
SLACK_BOT_TOKEN_DEV: ${SLACK_BOT_TOKEN_DEV}
35-
SLACK_BOT_TOKEN_PROD: ${SLACK_BOT_TOKEN_PROD}
36-
CODEPOCKET_CHANNEL_ID_DEV: ${CODEPOCKET_CHANNEL_ID_DEV}
37-
CODEPOCKET_CHANNEL_ID_PROD: ${CODEPOCKET_CHANNEL_ID_PROD}
38-
CHAPTER_FRONTED_CHANNEL_ID_DEV: ${CHAPTER_FRONTED_CHANNEL_ID_DEV}
39-
CHAPTER_FRONTED_CHANNEL_ID_PROD: ${CHAPTER_FRONTED_CHANNEL_ID_PROD}
40-
MONGO_DB_URI_DEV: ${MONGO_DB_URI_DEV}
41-
MONGO_DB_URI_PROD: ${MONGO_DB_URI_PROD}
42-
MONGO_DB_NAME_DEV: ${MONGO_DB_NAME_DEV}
43-
MONGO_DB_NAME_PROD: ${MONGO_DB_NAME_PROD}
31+
SLACK_BOT_TOKEN: ${SLACK_BOT_TOKEN}
32+
CODEPOCKET_CHANNEL_ID: ${CODEPOCKET_CHANNEL_ID}
33+
CHAPTER_FRONTED_CHANNEL_ID: ${CHAPTER_FRONTED_CHANNEL_ID}
34+
MONGO_DB_URI: ${MONGO_DB_URI}
35+
MONGO_DB_NAME: ${MONGO_DB_NAME}
36+
BASE_SERVER_URL: ${BASE_SERVER_URL}

server/src/utils/env.ts

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,10 @@
1-
export const isDevelopment = () => process.env.NODE_ENV === 'development';
2-
3-
const s = (dev: string | undefined, prod: string | undefined) => (isDevelopment() ? dev : prod);
41
export const env = {
5-
SELF_URL: s(process.env.BASE_SERVER_URL_DEV, process.env.BASE_SERVER_URL_PROD),
6-
MONGO_DB_URI: s(process.env.MONGO_DB_URI_DEV, process.env.MONGO_DB_URI_PROD),
7-
MONGO_DB_NAME: s(process.env.MONGO_DB_NAME_DEV, process.env.MONGO_DB_NAME_PROD),
8-
SLACK_BOT_TOKEN: s(process.env.SLACK_BOT_TOKEN_DEV, process.env.SLACK_BOT_TOKEN_PROD),
9-
CODEPOCKET_CHANNEL_ID: s(
10-
process.env.CODEPOCKET_CHANNEL_ID_DEV,
11-
process.env.CODEPOCKET_CHANNEL_ID_PROD,
12-
),
13-
CHAPTER_FRONTED_CHANNEL_ID: s(
14-
process.env.CHAPTER_FRONTED_CHANNEL_ID_DEV,
15-
process.env.CHAPTER_FRONTED_CHANNEL_ID_PROD,
16-
),
2+
SELF_URL: process.env.BASE_SERVER_URL,
3+
MONGO_DB_URI: process.env.MONGO_DB_URI,
4+
MONGO_DB_NAME: process.env.MONGO_DB_NAME,
5+
SLACK_BOT_TOKEN: process.env.SLACK_BOT_TOKEN,
6+
CODEPOCKET_CHANNEL_ID: process.env.CODEPOCKET_CHANNEL_ID,
7+
CHAPTER_FRONTED_CHANNEL_ID: process.env.CHAPTER_FRONTED_CHANNEL_ID,
178
} as const;
189

1910
export const checkSlackPossible =

0 commit comments

Comments
 (0)