forked from rocicorp/mono
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.ts
More file actions
25 lines (22 loc) · 707 Bytes
/
config.ts
File metadata and controls
25 lines (22 loc) · 707 Bytes
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
import * as v from 'shared/src/valita.js';
const configSchema = v.object({
['REPLICA_ID']: v.string(),
['UPSTREAM_URI']: v.string(),
['CVR_DB_URI']: v.string(),
['REPLICA_DB_FILE']: v.string(),
['STORAGE_DB_TMP_DIR']: v.string().optional(),
['LOG_LEVEL']: v.union(
v.literal('debug'),
v.literal('info'),
v.literal('error'),
),
['DATADOG_LOGS_API_KEY']: v.string().optional(),
['DATADOG_SERVICE_LABEL']: v.string().optional(),
});
export type Config = v.Infer<typeof configSchema>;
export function configFromEnv(): Config {
const env = Object.fromEntries(
Object.keys(configSchema.shape).map(key => [key, process.env[key]]),
);
return v.parse(env, configSchema);
}