@spinajs/configuration 2.0.529 → 2.0.531
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/lib/cjs/config/configuration.d.ts +27 -0
- package/lib/cjs/config/configuration.d.ts.map +1 -1
- package/lib/cjs/config/configuration.js +44 -8
- package/lib/cjs/config/configuration.js.map +1 -1
- package/lib/mjs/config/configuration.d.ts +27 -0
- package/lib/mjs/config/configuration.d.ts.map +1 -1
- package/lib/mjs/config/configuration.js +43 -8
- package/lib/mjs/config/configuration.js.map +1 -1
- package/lib/tsconfig.cjs.tsbuildinfo +1 -1
- package/lib/tsconfig.mjs.tsbuildinfo +1 -1
- package/package.json +6 -6
|
@@ -1,3 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The single source of truth for "which environment am I running as".
|
|
3
|
+
*
|
|
4
|
+
* Derived from the SAME value that selects the config files - `APP_ENV`, falling back to
|
|
5
|
+
* `NODE_ENV` - and run through the SAME normalizer, so a guard reading these flags and the config
|
|
6
|
+
* that was actually loaded can never disagree. Reading `NODE_ENV` directly, as this used to,
|
|
7
|
+
* disagreed in two ways:
|
|
8
|
+
*
|
|
9
|
+
* - A container may pin `NODE_ENV=production` so npm installs production dependencies, and then
|
|
10
|
+
* distinguish its stacks with `APP_ENV`. Such a dev container reported production.
|
|
11
|
+
* - Only the spelling `production` matched, so `APP_ENV=prod` - which `normalizeEnvironment` maps
|
|
12
|
+
* onto the prod config suffix - reported false.
|
|
13
|
+
*
|
|
14
|
+
* Both are fail-open for consumers that guard on this: the http package hides error detail on
|
|
15
|
+
* production, and the email package refuses recipient redirection there.
|
|
16
|
+
*
|
|
17
|
+
* These stay ordinary configuration values, so an app may override them in its own config - that
|
|
18
|
+
* is the point of deciding it here rather than re-deriving it at each call site.
|
|
19
|
+
*
|
|
20
|
+
* @param env - process.env, taken as an argument so the derivation is testable without reloading
|
|
21
|
+
* the module
|
|
22
|
+
*/
|
|
23
|
+
export declare function buildEnvironmentFlags(env: NodeJS.ProcessEnv): {
|
|
24
|
+
isDevelopment: boolean;
|
|
25
|
+
isProduction: boolean;
|
|
26
|
+
isLocal: boolean;
|
|
27
|
+
};
|
|
1
28
|
declare const config: {
|
|
2
29
|
configuration: {
|
|
3
30
|
isDevelopment: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"configuration.d.ts","sourceRoot":"","sources":["../../../src/config/configuration.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"configuration.d.ts","sourceRoot":"","sources":["../../../src/config/configuration.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,MAAM,CAAC,UAAU;IAYxD,aAAa;IACb,YAAY;IACZ,OAAO;EAEV;AAED,QAAA,MAAM,MAAM;IACV,aAAa;;;;;IAEb,GAAG;QACD,IAAI;QACJ,OAAO;;CAEV,CAAC;eAEa,MAAM"}
|
|
@@ -1,15 +1,51 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.buildEnvironmentFlags = buildEnvironmentFlags;
|
|
4
|
+
const configuration_common_1 = require("@spinajs/configuration-common");
|
|
5
|
+
/**
|
|
6
|
+
* The single source of truth for "which environment am I running as".
|
|
7
|
+
*
|
|
8
|
+
* Derived from the SAME value that selects the config files - `APP_ENV`, falling back to
|
|
9
|
+
* `NODE_ENV` - and run through the SAME normalizer, so a guard reading these flags and the config
|
|
10
|
+
* that was actually loaded can never disagree. Reading `NODE_ENV` directly, as this used to,
|
|
11
|
+
* disagreed in two ways:
|
|
12
|
+
*
|
|
13
|
+
* - A container may pin `NODE_ENV=production` so npm installs production dependencies, and then
|
|
14
|
+
* distinguish its stacks with `APP_ENV`. Such a dev container reported production.
|
|
15
|
+
* - Only the spelling `production` matched, so `APP_ENV=prod` - which `normalizeEnvironment` maps
|
|
16
|
+
* onto the prod config suffix - reported false.
|
|
17
|
+
*
|
|
18
|
+
* Both are fail-open for consumers that guard on this: the http package hides error detail on
|
|
19
|
+
* production, and the email package refuses recipient redirection there.
|
|
20
|
+
*
|
|
21
|
+
* These stay ordinary configuration values, so an app may override them in its own config - that
|
|
22
|
+
* is the point of deciding it here rather than re-deriving it at each call site.
|
|
23
|
+
*
|
|
24
|
+
* @param env - process.env, taken as an argument so the derivation is testable without reloading
|
|
25
|
+
* the module
|
|
26
|
+
*/
|
|
27
|
+
function buildEnvironmentFlags(env) {
|
|
28
|
+
// `?? 'development'` mirrors FrameworkConfiguration.load(), which resolves
|
|
29
|
+
// `Env ?? APP_ENV ?? NODE_ENV ?? 'development'`. Without it a bare process would fall through to
|
|
30
|
+
// normalizeEnvironment's own default of production and call a developer's laptop prod.
|
|
31
|
+
//
|
|
32
|
+
// An explicitly EMPTY APP_ENV is deliberately NOT caught by that default: `??` tests only
|
|
33
|
+
// null/undefined, so `APP_ENV=` reaches normalizeEnvironment, which resolves it to production -
|
|
34
|
+
// and such a deployment really does load its prod config. The flag agrees rather than papering
|
|
35
|
+
// over it.
|
|
36
|
+
const environment = (0, configuration_common_1.normalizeEnvironment)(env.APP_ENV ?? env.NODE_ENV ?? 'development');
|
|
37
|
+
return {
|
|
38
|
+
isDevelopment: environment === 'dev',
|
|
39
|
+
isProduction: environment === 'prod',
|
|
40
|
+
isLocal: environment === 'local',
|
|
41
|
+
};
|
|
42
|
+
}
|
|
3
43
|
const config = {
|
|
4
|
-
configuration:
|
|
5
|
-
isDevelopment: process.env.NODE_ENV === 'development',
|
|
6
|
-
isProduction: process.env.NODE_ENV === 'production',
|
|
7
|
-
isLocal: process.env.NODE_ENV === 'local'
|
|
8
|
-
},
|
|
44
|
+
configuration: buildEnvironmentFlags(process.env),
|
|
9
45
|
app: {
|
|
10
|
-
name:
|
|
11
|
-
version:
|
|
12
|
-
}
|
|
46
|
+
name: 'spinajs',
|
|
47
|
+
version: '1.0.0',
|
|
48
|
+
},
|
|
13
49
|
};
|
|
14
50
|
exports.default = config;
|
|
15
51
|
//# sourceMappingURL=configuration.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"configuration.js","sourceRoot":"","sources":["../../../src/config/configuration.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"configuration.js","sourceRoot":"","sources":["../../../src/config/configuration.ts"],"names":[],"mappings":";;;AAAA,wEAAqE;AAErE;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,+BAAsC,GAAsB;IAC1D,2EAA2E;IAC3E,iGAAiG;IACjG,uFAAuF;IACvF,EAAE;IACF,0FAA0F;IAC1F,gGAAgG;IAChG,+FAA+F;IAC/F,WAAW;IACX,MAAM,WAAW,GAAG,IAAA,2CAAoB,EAAC,GAAG,CAAC,OAAO,IAAI,GAAG,CAAC,QAAQ,IAAI,aAAa,CAAC,CAAC;IAEvF,OAAO;QACL,aAAa,EAAE,WAAW,KAAK,KAAK;QACpC,YAAY,EAAE,WAAW,KAAK,MAAM;QACpC,OAAO,EAAE,WAAW,KAAK,OAAO;KACjC,CAAC;AACJ,CAAC;AAED,MAAM,MAAM,GAAG;IACb,aAAa,EAAE,qBAAqB,CAAC,OAAO,CAAC,GAAG,CAAC;IAEjD,GAAG,EAAE;QACH,IAAI,EAAE,SAAS;QACf,OAAO,EAAE,OAAO;KACjB;CACF,CAAC;kBAEa,MAAM"}
|
|
@@ -1,3 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The single source of truth for "which environment am I running as".
|
|
3
|
+
*
|
|
4
|
+
* Derived from the SAME value that selects the config files - `APP_ENV`, falling back to
|
|
5
|
+
* `NODE_ENV` - and run through the SAME normalizer, so a guard reading these flags and the config
|
|
6
|
+
* that was actually loaded can never disagree. Reading `NODE_ENV` directly, as this used to,
|
|
7
|
+
* disagreed in two ways:
|
|
8
|
+
*
|
|
9
|
+
* - A container may pin `NODE_ENV=production` so npm installs production dependencies, and then
|
|
10
|
+
* distinguish its stacks with `APP_ENV`. Such a dev container reported production.
|
|
11
|
+
* - Only the spelling `production` matched, so `APP_ENV=prod` - which `normalizeEnvironment` maps
|
|
12
|
+
* onto the prod config suffix - reported false.
|
|
13
|
+
*
|
|
14
|
+
* Both are fail-open for consumers that guard on this: the http package hides error detail on
|
|
15
|
+
* production, and the email package refuses recipient redirection there.
|
|
16
|
+
*
|
|
17
|
+
* These stay ordinary configuration values, so an app may override them in its own config - that
|
|
18
|
+
* is the point of deciding it here rather than re-deriving it at each call site.
|
|
19
|
+
*
|
|
20
|
+
* @param env - process.env, taken as an argument so the derivation is testable without reloading
|
|
21
|
+
* the module
|
|
22
|
+
*/
|
|
23
|
+
export declare function buildEnvironmentFlags(env: NodeJS.ProcessEnv): {
|
|
24
|
+
isDevelopment: boolean;
|
|
25
|
+
isProduction: boolean;
|
|
26
|
+
isLocal: boolean;
|
|
27
|
+
};
|
|
1
28
|
declare const config: {
|
|
2
29
|
configuration: {
|
|
3
30
|
isDevelopment: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"configuration.d.ts","sourceRoot":"","sources":["../../../src/config/configuration.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"configuration.d.ts","sourceRoot":"","sources":["../../../src/config/configuration.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,MAAM,CAAC,UAAU;IAYxD,aAAa;IACb,YAAY;IACZ,OAAO;EAEV;AAED,QAAA,MAAM,MAAM;IACV,aAAa;;;;;IAEb,GAAG;QACD,IAAI;QACJ,OAAO;;CAEV,CAAC;eAEa,MAAM"}
|
|
@@ -1,13 +1,48 @@
|
|
|
1
|
+
import { normalizeEnvironment } from '@spinajs/configuration-common';
|
|
2
|
+
/**
|
|
3
|
+
* The single source of truth for "which environment am I running as".
|
|
4
|
+
*
|
|
5
|
+
* Derived from the SAME value that selects the config files - `APP_ENV`, falling back to
|
|
6
|
+
* `NODE_ENV` - and run through the SAME normalizer, so a guard reading these flags and the config
|
|
7
|
+
* that was actually loaded can never disagree. Reading `NODE_ENV` directly, as this used to,
|
|
8
|
+
* disagreed in two ways:
|
|
9
|
+
*
|
|
10
|
+
* - A container may pin `NODE_ENV=production` so npm installs production dependencies, and then
|
|
11
|
+
* distinguish its stacks with `APP_ENV`. Such a dev container reported production.
|
|
12
|
+
* - Only the spelling `production` matched, so `APP_ENV=prod` - which `normalizeEnvironment` maps
|
|
13
|
+
* onto the prod config suffix - reported false.
|
|
14
|
+
*
|
|
15
|
+
* Both are fail-open for consumers that guard on this: the http package hides error detail on
|
|
16
|
+
* production, and the email package refuses recipient redirection there.
|
|
17
|
+
*
|
|
18
|
+
* These stay ordinary configuration values, so an app may override them in its own config - that
|
|
19
|
+
* is the point of deciding it here rather than re-deriving it at each call site.
|
|
20
|
+
*
|
|
21
|
+
* @param env - process.env, taken as an argument so the derivation is testable without reloading
|
|
22
|
+
* the module
|
|
23
|
+
*/
|
|
24
|
+
export function buildEnvironmentFlags(env) {
|
|
25
|
+
// `?? 'development'` mirrors FrameworkConfiguration.load(), which resolves
|
|
26
|
+
// `Env ?? APP_ENV ?? NODE_ENV ?? 'development'`. Without it a bare process would fall through to
|
|
27
|
+
// normalizeEnvironment's own default of production and call a developer's laptop prod.
|
|
28
|
+
//
|
|
29
|
+
// An explicitly EMPTY APP_ENV is deliberately NOT caught by that default: `??` tests only
|
|
30
|
+
// null/undefined, so `APP_ENV=` reaches normalizeEnvironment, which resolves it to production -
|
|
31
|
+
// and such a deployment really does load its prod config. The flag agrees rather than papering
|
|
32
|
+
// over it.
|
|
33
|
+
const environment = normalizeEnvironment(env.APP_ENV ?? env.NODE_ENV ?? 'development');
|
|
34
|
+
return {
|
|
35
|
+
isDevelopment: environment === 'dev',
|
|
36
|
+
isProduction: environment === 'prod',
|
|
37
|
+
isLocal: environment === 'local',
|
|
38
|
+
};
|
|
39
|
+
}
|
|
1
40
|
const config = {
|
|
2
|
-
configuration:
|
|
3
|
-
isDevelopment: process.env.NODE_ENV === 'development',
|
|
4
|
-
isProduction: process.env.NODE_ENV === 'production',
|
|
5
|
-
isLocal: process.env.NODE_ENV === 'local'
|
|
6
|
-
},
|
|
41
|
+
configuration: buildEnvironmentFlags(process.env),
|
|
7
42
|
app: {
|
|
8
|
-
name:
|
|
9
|
-
version:
|
|
10
|
-
}
|
|
43
|
+
name: 'spinajs',
|
|
44
|
+
version: '1.0.0',
|
|
45
|
+
},
|
|
11
46
|
};
|
|
12
47
|
export default config;
|
|
13
48
|
//# sourceMappingURL=configuration.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"configuration.js","sourceRoot":"","sources":["../../../src/config/configuration.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,
|
|
1
|
+
{"version":3,"file":"configuration.js","sourceRoot":"","sources":["../../../src/config/configuration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AAErE;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,UAAU,qBAAqB,CAAC,GAAsB;IAC1D,2EAA2E;IAC3E,iGAAiG;IACjG,uFAAuF;IACvF,EAAE;IACF,0FAA0F;IAC1F,gGAAgG;IAChG,+FAA+F;IAC/F,WAAW;IACX,MAAM,WAAW,GAAG,oBAAoB,CAAC,GAAG,CAAC,OAAO,IAAI,GAAG,CAAC,QAAQ,IAAI,aAAa,CAAC,CAAC;IAEvF,OAAO;QACL,aAAa,EAAE,WAAW,KAAK,KAAK;QACpC,YAAY,EAAE,WAAW,KAAK,MAAM;QACpC,OAAO,EAAE,WAAW,KAAK,OAAO;KACjC,CAAC;AACJ,CAAC;AAED,MAAM,MAAM,GAAG;IACb,aAAa,EAAE,qBAAqB,CAAC,OAAO,CAAC,GAAG,CAAC;IAEjD,GAAG,EAAE;QACH,IAAI,EAAE,SAAS;QACf,OAAO,EAAE,OAAO;KACjB;CACF,CAAC;AAEF,eAAe,MAAM,CAAC"}
|