mirror of
https://github.com/hcengineering/platform.git
synced 2025-04-08 00:52:30 +00:00

Some checks are pending
CI / build (push) Waiting to run
CI / svelte-check (push) Blocked by required conditions
CI / formatting (push) Blocked by required conditions
CI / test (push) Blocked by required conditions
CI / uitest (push) Waiting to run
CI / uitest-pg (push) Waiting to run
CI / uitest-qms (push) Waiting to run
CI / docker-build (push) Blocked by required conditions
CI / dist-build (push) Blocked by required conditions
Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
40 lines
1.1 KiB
TypeScript
40 lines
1.1 KiB
TypeScript
//
|
|
// Copyright © 2024 Hardcore Engineering Inc.
|
|
//
|
|
|
|
import fs from 'fs'
|
|
|
|
export interface Config {
|
|
AccountsUrl: string
|
|
Cert: Buffer
|
|
CertPwd: string
|
|
Port: number
|
|
Secret: string
|
|
ServiceID: string
|
|
BrandingPath: string
|
|
}
|
|
|
|
const parseNumber = (str: string | undefined): number | undefined => (str !== undefined ? Number(str) : undefined)
|
|
|
|
const config: Config = (() => {
|
|
const params: Partial<Config> = {
|
|
AccountsUrl: process.env.ACCOUNTS_URL,
|
|
Cert: process.env.CERTIFICATE_PATH !== undefined ? fs.readFileSync(process.env.CERTIFICATE_PATH) : undefined,
|
|
CertPwd: process.env.CERTIFICATE_PASSWORD ?? '',
|
|
Port: parseNumber(process.env.PORT) ?? 4006,
|
|
Secret: process.env.SECRET,
|
|
ServiceID: process.env.SERVICE_ID,
|
|
BrandingPath: process.env.BRANDING_PATH ?? ''
|
|
}
|
|
|
|
const missingEnv = (Object.keys(params) as Array<keyof Config>).filter((key) => params[key] === undefined)
|
|
|
|
if (missingEnv.length > 0) {
|
|
throw Error(`Missing config for attributes: ${missingEnv.join(', ')}`)
|
|
}
|
|
|
|
return params as Config
|
|
})()
|
|
|
|
export default config
|