forked from daquinoaldo/https-localhost
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConfig.ts
More file actions
22 lines (20 loc) · 744 Bytes
/
Copy pathConfig.ts
File metadata and controls
22 lines (20 loc) · 744 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
export default class Config {
rootDir: string
port: number
domain: string
cors: boolean
compress: boolean
minify: boolean
redirectFromPort?: number
redirect404To?: string
constructor(config?: Partial<Config>) {
this.rootDir = config?.rootDir || process.cwd()
this.domain = config?.domain || "localhost"
this.port = config?.port || parseInt(process.env.PORT || "443")
this.cors = config?.cors || true
this.compress = config?.compress || process.env.NODE_ENV === "production"
this.minify = config?.minify || process.env.NODE_ENV === "production"
this.redirectFromPort = config?.redirectFromPort || this.port === 443 ? 80 : undefined
}
getLocation = () => `https://${this.domain}:${this.port}`
}