-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.ts
More file actions
45 lines (38 loc) · 1.13 KB
/
Copy pathconfig.ts
File metadata and controls
45 lines (38 loc) · 1.13 KB
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
import { readJsonWithSchema } from './validation.ts'
import { type Infer, Schema } from '../common/validation.ts'
export const SERVER_CONFIG_SCHEMA = Schema.union(
Schema.object({
port: Schema.uint32,
processName: Schema.string,
}),
Schema.object({
socket: Schema.string,
processName: Schema.string,
}),
)
export type IServerConfig = Infer<typeof SERVER_CONFIG_SCHEMA>
export const SERVICE_CONFIG_SCHEMA = Schema.object({
files: Schema.object({
realRoot: Schema.string,
mockRoot: Schema.string,
}),
pacman: Schema.object({
mockDBPath: Schema.string,
realDBPath: Schema.string,
}),
translation: Schema.object({
root: Schema.string,
}),
})
export type IServiceConfig = Infer<typeof SERVICE_CONFIG_SCHEMA>
export const WEBSITE_CONFIG_SCHEMA = Schema.object({
server: SERVER_CONFIG_SCHEMA,
services: SERVICE_CONFIG_SCHEMA,
})
export interface IWebsiteConfig extends Infer<typeof WEBSITE_CONFIG_SCHEMA> {
server: IServerConfig
services: IServiceConfig
}
export async function readConfig(): Promise<IWebsiteConfig> {
return readJsonWithSchema(WEBSITE_CONFIG_SCHEMA, 'config/active.json')
}