-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathconfig.ts
131 lines (116 loc) · 4.95 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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
import * as process from "process"
import { PoolConfig } from "mysql"
import * as dotenv from "dotenv"
dotenv.config()
/**
* This entirely static class contains the configuration of the webserver and data sources.
*/
export default class CONFIG {
public static readonly smics_hostname: string =
process.env.SMICS_HOSTNAME !== undefined
? process.env.SMICS_HOSTNAME
: "localhost"
public static readonly smics_port: number =
process.env.SMICS_PORT !== undefined
? parseInt(process.env.SMICS_PORT)
: 9000
/**
* The HTTP port that is either taken from the `HTTP_PORT` environment variable or else defaults to `3231`.
*/
public static readonly http_port: number =
process.env.HTTP_PORT !== undefined ? parseInt(process.env.HTTP_PORT) : 3231
/**
* The HTTPS port that is either taken from the `HTTPS_PORT` environment variable or else defaults to `3232`.
*/
public static readonly https_port: number =
process.env.HTTPS_PORT !== undefined
? parseInt(process.env.HTTPS_PORT)
: 3232
/**
* This flag is used to suppress logging while unit testing the webserver.
* It is either set via the `IS_TESTING` environment variable or else defaults to `false`.
*/
public static readonly is_testing: boolean =
process.env.IS_TESTING !== undefined
? process.env.IS_TESTING.toLowerCase() === "true"
: false
/**
* This flag is used to differentiate between production and development settings for the webserver.
* It is either set via the `DEV_MODE` environment variable or else defaults to `true`.
*/
public static readonly dev_mode: boolean =
process.env.DEV_MODE !== undefined
? process.env.DEV_MODE.toLowerCase() !== "false"
: true
/**
* This flag is used to decide whether to enable or disable authentication for the webserver.
* It is either set via the `USE_AUTH` environment variable or else defaults to `false`.
*/
public static readonly use_auth: boolean =
process.env.USE_AUTH !== undefined
? process.env.USE_AUTH.toLowerCase() === "true"
: false
/**
* This flag is used to decide whether to enable or disable the export of errors
* to an external .log file in the ./src/server/logs folder
*/
public static readonly use_logging: boolean =
process.env.USE_LOGGING !== undefined
? process.env.USE_LOGGING.toLowerCase() !== "false"
: false
/**
* This flag is used to declare the time when the restAPI is asked for
* the new 'OutbreakDetectionConfigurations' data
* By default it is set to 6:00
*/
public static readonly daily_req: string =
process.env.DAILY_REQ !== undefined ? process.env.DAILY_REQ : "6:00"
/**
* This flag defines the database to connect to.
* Default is the restAPI
*/
public static readonly datasource: string =
process.env.DATASOURCE !== undefined ? process.env.DATASOURCE : "rest"
/**
* The configuration for connecting with the internal MySQL database. See #PoolConfig for available options.
*/
public static readonly igd_database_config: PoolConfig = {
host: "highmeddatstring.igd.fraunhofer.de",
port: 1812,
user: "root",
password: "u7GE5n9k",
database: "hmhdnov18",
connectionLimit: 4,
// the data base is not in UTC but instead in the local time of Darmstadt, Germany
// this setting assumes that the server is in that very same time zone
timezone: "local",
dateStrings: false, // we want this conversion but also need to convert back to strings for the JSON schema validation
}
/**
* The access information for the REST API of the MAH that is used internally to this class in order to create the
* public #rest_api_path.
*
* @private
*/
private static readonly rest_api_config = {
protocol: "http",
hostname: CONFIG.dev_mode ? "localhost" : CONFIG.smics_hostname,
// hostname: "192.168.0.108", // EntwicklungsVM IP (SmICS)
port: CONFIG.dev_mode ? 9000 : CONFIG.smics_port,
path: CONFIG.dev_mode ? "/" : "/api/StoredProcedures/",
}
/**
* The complete URL of REST API of the MAH. Ends with a slash.
*/
public static readonly rest_api_path = `${CONFIG.rest_api_config.protocol}://${CONFIG.rest_api_config.hostname}:${CONFIG.rest_api_config.port}${CONFIG.rest_api_config.path}`
/**
* The access information for the openid-connect auth provider in order to authenticate users and start/close sessions.
*/
public static readonly auth_provider_config = {
provider_url: process.env.AUTH_PROVIDER_URL || "http://localhost:8080", // Base URL of auth provider to handle login/logout
redirect_url: process.env.AUTH_REDIRECT_URL || "http://localhost:3231", // Base URL of app to return to after login/logout
realm: process.env.AUTH_REALM || "sample-realm", // Auth provider realm name
client_id: process.env.AUTH_CLIENT_ID || "sample-client", // Auth provider client name
client_secret: process.env.AUTH_CLIENT_SECRET || "no-secret", // Auth provider client secret (No empty string!)
}
}