2
2
import dotenv from "dotenv" ;
3
3
import { type Algorithm } from "jsonwebtoken" ;
4
4
import { type ServiceAccount } from "firebase-admin" ;
5
+ import exp from "constants" ;
5
6
6
7
if ( process . env . NODE_ENV === undefined ) {
7
8
// logger.ts가 아직 초기화되지 않았으므로 console.error를 사용합니다.
@@ -18,52 +19,55 @@ if (process.env.DB_PATH === undefined) {
18
19
process . exit ( 1 ) ;
19
20
}
20
21
21
- export const nodeEnv = process . env . NODE_ENV ; // required ("production" or "development" or "test")
22
- export const mongo = process . env . DB_PATH ; // required
23
- export const session = {
24
- secret : process . env . SESSION_KEY || "TAXI_SESSION_KEY" , // optional
25
- expiry : 14 * 24 * 3600 * 1000 , // 14일, ms 단위입니다.
26
- } ;
27
- export const redis = process . env . REDIS_PATH ; // optional
28
- export const sparcssso = {
29
- id : process . env . SPARCSSSO_CLIENT_ID || "" , // optional
30
- key : process . env . SPARCSSSO_CLIENT_KEY || "" , // optional
31
- } ;
32
- export const port = process . env . PORT ? parseInt ( process . env . PORT ) : 80 ; // optional (default = 80)
33
- export const corsWhiteList = ( process . env . CORS_WHITELIST &&
34
- ( JSON . parse ( process . env . CORS_WHITELIST ) as string [ ] ) ) || [ true ] ; // optional (default = [true])
35
- export const aws = {
36
- accessKeyId : process . env . AWS_ACCESS_KEY_ID as string , // required
37
- secretAccessKey : process . env . AWS_SECRET_ACCESS_KEY as string , // required
38
- s3BucketName : process . env . AWS_S3_BUCKET_NAME as string , // required
39
- s3Url :
40
- process . env . AWS_S3_URL ||
41
- `https://${ process . env . AWS_S3_BUCKET_NAME } .s3.ap-northeast-2.amazonaws.com` , // optional
42
- } ;
43
- export const jwt = {
44
- secretKey : process . env . JWT_SECRET_KEY || "TAXI_JWT_KEY" ,
45
- option : {
46
- algorithm : "HS256" as Algorithm ,
47
- // FIXME: remove FRONT_URL from issuer. 단, issuer를 변경하면 이전에 발급했던 모든 JWT가 무효화됩니다.
48
- // See https://github.com/sparcs-kaist/taxi-back/issues/415
49
- issuer : process . env . FRONT_URL || "http://localhost:3000" , // optional (default = "http://localhost:3000")
22
+ const config = {
23
+ nodeEnv : process . env . NODE_ENV ,
24
+ mongoUrl : process . env . DB_PATH ,
25
+ session : {
26
+ secret : process . env . SESSION_KEY || "TAXI_SESSION_KEY" ,
27
+ expiry : 14 * 24 * 3600 * 1000 ,
28
+ } ,
29
+ redisUrl : process . env . REDIS_PATH ,
30
+ sparcssso : {
31
+ id : process . env . SPARCSSSO_CLIENT_ID || "" ,
32
+ key : process . env . SPARCSSSO_CLIENT_KEY || "" ,
33
+ } ,
34
+ port : process . env . PORT ? parseInt ( process . env . PORT ) : 80 ,
35
+ corsWhiteList : ( process . env . CORS_WHITELIST &&
36
+ ( JSON . parse ( process . env . CORS_WHITELIST ) as string [ ] ) ) || [ true ] ,
37
+ aws : {
38
+ accessKeyId : process . env . AWS_ACCESS_KEY_ID as string ,
39
+ secretAccessKey : process . env . AWS_SECRET_ACCESS_KEY as string ,
40
+ s3BucketName : process . env . AWS_S3_BUCKET_NAME as string ,
41
+ s3Url :
42
+ process . env . AWS_S3_URL ||
43
+ `https://${ process . env . AWS_S3_BUCKET_NAME } .s3.ap-northeast-2.amazonaws.com` ,
44
+ } ,
45
+ jwt : {
46
+ secretKey : process . env . JWT_SECRET || "TAXI_JWT_KEY" ,
47
+ option : {
48
+ algorithm : "HS256" as Algorithm ,
49
+ // FIXME: remove FRONT_URL from issuer. 단, issuer를 변경하면 이전에 발급했던 모든 JWT가 무효화됩니다.
50
+ // See https://github.com/sparcs-kaist/taxi-back/issues/415
51
+ issuer : process . env . FRONT_URL || "http://localhost:3000" ,
52
+ } ,
53
+ TOKEN_EXPIRED : - 3 ,
54
+ TOKEN_INVALID : - 2 ,
55
+ } ,
56
+
57
+ googleApplicationCredentials :
58
+ process . env . GOOGLE_APPLICATION_CREDENTIALS &&
59
+ ( JSON . parse ( process . env . GOOGLE_APPLICATION_CREDENTIALS ) as ServiceAccount ) ,
60
+ testAccounts :
61
+ ( process . env . TEST_ACCOUNTS &&
62
+ ( JSON . parse ( process . env . TEST_ACCOUNTS ) as string [ ] ) ) ||
63
+ [ ] ,
64
+ slackWebhookUrl : {
65
+ report : process . env . SLACK_REPORT_WEBHOOK_URL || "" ,
66
+ } ,
67
+ naverMap : {
68
+ apiId : process . env . NAVER_MAP_API_ID || "" ,
69
+ apiKey : process . env . NAVER_MAP_API_KEY || "" ,
50
70
} ,
51
- TOKEN_EXPIRED : - 3 ,
52
- TOKEN_INVALID : - 2 ,
53
- } ;
54
- export const googleApplicationCredentials =
55
- process . env . GOOGLE_APPLICATION_CREDENTIALS &&
56
- ( JSON . parse ( process . env . GOOGLE_APPLICATION_CREDENTIALS ) as ServiceAccount ) ; // optional
57
- export const testAccounts =
58
- ( process . env . TEST_ACCOUNTS &&
59
- ( JSON . parse ( process . env . TEST_ACCOUNTS ) as string [ ] ) ) ||
60
- [ ] ; // optional
61
- export const slackWebhookUrl = {
62
- report : process . env . SLACK_REPORT_WEBHOOK_URL || "" , // optional
63
- } ;
64
- // export const eventConfig =
65
- // process.env.EVENT_CONFIG && JSON.parse(process.env.EVENT_CONFIG); // optional
66
- export const naverMap = {
67
- apiId : process . env . NAVER_MAP_API_ID || "" , // optional
68
- apiKey : process . env . NAVER_MAP_API_KEY || "" , // optional
69
71
} ;
72
+
73
+ export default config ;
0 commit comments