@sockethub/server 5.0.0-alpha.15 → 5.0.0-alpha.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/config-schema.d.ts +58 -0
- package/dist/index.js +154781 -154593
- package/dist/index.js.map +45 -42
- package/dist/platform.js +295 -231
- package/dist/platform.js.map +8 -6
- package/dist/write-config.d.ts +18 -0
- package/package.json +14 -13
- package/res/sockethub-client.js +102 -8
- package/res/sockethub-client.min.js +19 -19
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import convict from "convict";
|
|
2
|
+
/**
|
|
3
|
+
* The convict configuration schema, derived from the canonical JSON schema in
|
|
4
|
+
* `@sockethub/schemas` so defaults, types and enums have a single source of
|
|
5
|
+
* truth. This module only layers on the server-specific concerns the JSON
|
|
6
|
+
* schema cannot express: environment variable and command-line argument
|
|
7
|
+
* bindings, and convict format refinements ("nat", "port").
|
|
8
|
+
*/
|
|
9
|
+
type JsonSchemaNode = {
|
|
10
|
+
type?: string | Array<string>;
|
|
11
|
+
enum?: Array<unknown>;
|
|
12
|
+
default?: unknown;
|
|
13
|
+
description?: string;
|
|
14
|
+
properties?: Record<string, JsonSchemaNode>;
|
|
15
|
+
};
|
|
16
|
+
type OverlayEntry = {
|
|
17
|
+
/** Convict format override (e.g. "nat", "port", "*"). */
|
|
18
|
+
format?: unknown;
|
|
19
|
+
/** Environment variable bound to this key. */
|
|
20
|
+
env?: string;
|
|
21
|
+
/**
|
|
22
|
+
* Treat an empty-string value of `env` as unset so it falls back to the
|
|
23
|
+
* config file / default, preserving the historical `process.env.X || ...`
|
|
24
|
+
* behavior (convict would otherwise apply the empty string as an
|
|
25
|
+
* override). Deliberately NOT set for SOCKETHUB_CORS_ORIGIN, where an
|
|
26
|
+
* empty string must stay applied so CORS fails closed.
|
|
27
|
+
*/
|
|
28
|
+
emptyEnvIsUnset?: boolean;
|
|
29
|
+
/** Command-line argument bound to this key. */
|
|
30
|
+
arg?: string;
|
|
31
|
+
/**
|
|
32
|
+
* Treat this object node as a single convict leaf (validated as a whole
|
|
33
|
+
* by the JSON schema pass) instead of recursing into its properties.
|
|
34
|
+
*/
|
|
35
|
+
leaf?: boolean;
|
|
36
|
+
/** Default for leaves the JSON schema declares no default for. */
|
|
37
|
+
default?: unknown;
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* Build the convict schema definition from a JSON schema plus a server
|
|
41
|
+
* overlay. Exported for tests; production code uses {@link buildSchema}.
|
|
42
|
+
* Throws when an overlay entry references a path the JSON schema does not
|
|
43
|
+
* declare, or when a leaf ends up without a default.
|
|
44
|
+
*/
|
|
45
|
+
export declare function buildConvictDefinition(jsonSchema: JsonSchemaNode, overlays: Record<string, OverlayEntry>): Record<string, unknown>;
|
|
46
|
+
export declare function buildSchema(): convict.Config<Record<string, unknown>>;
|
|
47
|
+
/**
|
|
48
|
+
* Environment variables where an empty-string value means "unset" rather
|
|
49
|
+
* than an override (historical `process.env.X || <config>` semantics).
|
|
50
|
+
*/
|
|
51
|
+
export declare const EMPTY_ENV_IS_UNSET_VARS: ReadonlyArray<string>;
|
|
52
|
+
/**
|
|
53
|
+
* The fully materialized default configuration tree, straight from the JSON
|
|
54
|
+
* schema (no environment or command-line overrides applied). The `$schema`
|
|
55
|
+
* key is omitted; callers stamp their own reference.
|
|
56
|
+
*/
|
|
57
|
+
export declare function getDefaultConfig(): Record<string, unknown>;
|
|
58
|
+
export {};
|