-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConfiguration.ts
More file actions
35 lines (34 loc) · 1.05 KB
/
Configuration.ts
File metadata and controls
35 lines (34 loc) · 1.05 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
export interface Configuration {
/**
* This public key is used be the client.
* If not present, no verification of the signature on jwt:s is done.
* (Which is fine)
*/
publicKey?: string
/**
* E.g `${pathPrefix}/me`
* Default:
*/
application?: string
pathPrefix: "" | `/${string}`
inviteParameterName: string
}
export namespace Configuration {
export type Required = Partial<Configuration>
export function addDefault(configuration: Required): Configuration
export function addDefault<K extends keyof Configuration>(
configuration: Required,
...property: K[]
): Pick<Configuration, K>
export function addDefault(configuration: Required, ...properties: (keyof Configuration)[]): Partial<Configuration> {
const defaultConfiguration: Configuration = {
pathPrefix: "",
inviteParameterName: "invite",
}
return Object.fromEntries(
(properties.length > 0 ? properties : (["publicKey", "pathPrefix", "inviteParameterName"] as const)).map(
property => [property, configuration[property] ?? defaultConfiguration[property]]
)
)
}
}