This repository has been archived by the owner on Oct 12, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.ts
70 lines (67 loc) · 2.04 KB
/
config.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
// server side configuration
//
import path from 'path';
// import again to prevent out of order import
// eslint-disable-next-line @typescript-eslint/no-var-requires
require('dotenv').config();
//
interface Config {
http_port: number;
https_port: number;
mongodbUrl: string; // production same as development
viewPath: string;
cssPath: string;
reactPath: string;
publicJSPath: string;
htmlStructurePath: string;
errorPath: string;
semester: string;
}
const rootPath: string = path.join(__dirname, '..', '..');
//
const config_prod: Config = {
http_port: 80,
https_port: 443,
mongodbUrl: 'mongodb://localhost:27017', // same as development
viewPath: path.join(rootPath, 'bin', 'client', 'html', 'view'),
cssPath: path.join(rootPath, 'bin', 'client', 'static', 'css'),
reactPath: path.join(rootPath, 'bin', 'client', 'react'),
publicJSPath: path.join(rootPath, 'bin', 'client', 'static', 'javascript'),
htmlStructurePath: path.join(
rootPath,
'bin',
'client',
'static',
'html',
'structure'
),
errorPath: path.join(rootPath, 'bin', 'client', 'html', 'error'),
semester: '2230',
} as const;
//
const config_dev: Config = {
http_port: 8080,
https_port: 8088,
mongodbUrl: 'mongodb://localhost:27017',
viewPath: path.join(rootPath, 'src', 'client', 'html', 'view'),
cssPath: path.join(rootPath, 'src', 'client', 'static', 'css'),
reactPath: path.join(rootPath, 'bin', 'client', 'react'), // this one can only be in bin as building is required for js
publicJSPath: path.join(rootPath, 'bin', 'client', 'static', 'javascript'),
htmlStructurePath: path.join(
rootPath,
'src',
'client',
'static',
'html',
'structure'
),
errorPath: path.join(rootPath, 'src', 'client', 'html', 'error'),
semester: '2230',
} as const;
let _config: Config;
if (process.env.NODE_ENV !== 'production') {
_config = config_dev;
} else {
_config = config_prod;
}
export const config = _config;