@feathersjs/configuration 5.0.0-pre.17 → 5.0.0-pre.18
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/CHANGELOG.md +11 -0
- package/README.md +1 -0
- package/lib/index.d.ts +2 -1
- package/lib/index.js +9 -1
- package/lib/index.js.map +1 -1
- package/package.json +12 -11
- package/src/index.ts +12 -2
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,17 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [5.0.0-pre.18](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.17...v5.0.0-pre.18) (2022-04-11)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* **configuration:** Allow app configuration to be validated against a schema ([#2590](https://github.com/feathersjs/feathers/issues/2590)) ([a268f86](https://github.com/feathersjs/feathers/commit/a268f86da92a8ada14ed11ab456aac0a4bba5bb0))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
6
17
|
# [5.0.0-pre.17](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.16...v5.0.0-pre.17) (2022-02-15)
|
|
7
18
|
|
|
8
19
|
**Note:** Version bump only for package @feathersjs/configuration
|
package/README.md
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
[](https://github.com/feathersjs/feathers/actions?query=workflow%3ACI)
|
|
4
4
|
[](https://www.npmjs.com/package/@feathersjs/configuration)
|
|
5
|
+
[](https://discord.gg/qa8kez8QBx)
|
|
5
6
|
|
|
6
7
|
> A small configuration module for your Feathers application.
|
|
7
8
|
|
package/lib/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Application } from '@feathersjs/feathers';
|
|
2
|
+
import { Schema } from '@feathersjs/schema';
|
|
2
3
|
import config from 'config';
|
|
3
|
-
declare const _default: () => (app?: Application) => config.IConfig;
|
|
4
|
+
declare const _default: (schema?: Schema<any>) => (app?: Application) => config.IConfig;
|
|
4
5
|
export = _default;
|
package/lib/index.js
CHANGED
|
@@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
const commons_1 = require("@feathersjs/commons");
|
|
6
6
|
const config_1 = __importDefault(require("config"));
|
|
7
7
|
const debug = (0, commons_1.createDebug)('@feathersjs/configuration');
|
|
8
|
-
module.exports = function init() {
|
|
8
|
+
module.exports = function init(schema) {
|
|
9
9
|
return (app) => {
|
|
10
10
|
if (!app) {
|
|
11
11
|
return config_1.default;
|
|
@@ -16,6 +16,14 @@ module.exports = function init() {
|
|
|
16
16
|
debug(`Setting ${name} configuration value to`, value);
|
|
17
17
|
app.set(name, value);
|
|
18
18
|
});
|
|
19
|
+
if (schema) {
|
|
20
|
+
app.hooks({
|
|
21
|
+
setup: [async (context, next) => {
|
|
22
|
+
await schema.validate(context.app.settings);
|
|
23
|
+
await next();
|
|
24
|
+
}]
|
|
25
|
+
});
|
|
26
|
+
}
|
|
19
27
|
return config_1.default;
|
|
20
28
|
};
|
|
21
29
|
};
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;AACA,iDAAkD;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;AACA,iDAAkD;AAElD,oDAA4B;AAE5B,MAAM,KAAK,GAAG,IAAA,qBAAW,EAAC,2BAA2B,CAAC,CAAC;AAEvD,iBAAS,SAAS,IAAI,CAAE,MAAoB;IAC1C,OAAO,CAAC,GAAiB,EAAE,EAAE;QAC3B,IAAI,CAAC,GAAG,EAAE;YACR,OAAO,gBAAM,CAAC;SACf;QAED,KAAK,CAAC,kCAAkC,gBAAM,CAAC,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,cAAc,CAAC,CAAC;QAEtF,MAAM,CAAC,IAAI,CAAC,gBAAM,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;YACjC,MAAM,KAAK,GAAI,gBAAc,CAAC,IAAI,CAAC,CAAC;YACpC,KAAK,CAAC,WAAW,IAAI,yBAAyB,EAAE,KAAK,CAAC,CAAC;YACvD,GAAG,CAAC,GAAG,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;QACvB,CAAC,CAAC,CAAC;QAEH,IAAI,MAAM,EAAE;YACV,GAAG,CAAC,KAAK,CAAC;gBACR,KAAK,EAAE,CAAC,KAAK,EAAE,OAA+B,EAAE,IAAkB,EAAE,EAAE;wBACpE,MAAM,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;wBAC5C,MAAM,IAAI,EAAE,CAAC;oBACf,CAAC,CAAC;aACH,CAAC,CAAA;SACH;QAED,OAAO,gBAAM,CAAC;IAChB,CAAC,CAAC;AACJ,CAAC,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@feathersjs/configuration",
|
|
3
3
|
"description": "A small configuration module for your Feathers application.",
|
|
4
|
-
"version": "5.0.0-pre.
|
|
4
|
+
"version": "5.0.0-pre.18",
|
|
5
5
|
"homepage": "https://feathersjs.com",
|
|
6
6
|
"main": "lib/",
|
|
7
7
|
"types": "lib/",
|
|
@@ -16,7 +16,8 @@
|
|
|
16
16
|
},
|
|
17
17
|
"repository": {
|
|
18
18
|
"type": "git",
|
|
19
|
-
"url": "git://github.com/feathersjs/feathers.git"
|
|
19
|
+
"url": "git://github.com/feathersjs/feathers.git",
|
|
20
|
+
"directory": "packages/configuration"
|
|
20
21
|
},
|
|
21
22
|
"author": {
|
|
22
23
|
"name": "Feathers contributors",
|
|
@@ -42,8 +43,7 @@
|
|
|
42
43
|
"scripts": {
|
|
43
44
|
"prepublish": "npm run compile",
|
|
44
45
|
"compile": "shx rm -rf lib/ && tsc",
|
|
45
|
-
"test": "
|
|
46
|
-
"mocha": "NODE_CONFIG_DIR=./test/config mocha --config ../../.mocharc.json --recursive test/**.test.ts test/**/*.test.ts"
|
|
46
|
+
"test": "NODE_CONFIG_DIR=./test/config mocha --config ../../.mocharc.json --recursive test/**.test.ts test/**/*.test.ts"
|
|
47
47
|
},
|
|
48
48
|
"semistandard": {
|
|
49
49
|
"env": [
|
|
@@ -57,18 +57,19 @@
|
|
|
57
57
|
"access": "public"
|
|
58
58
|
},
|
|
59
59
|
"dependencies": {
|
|
60
|
-
"@feathersjs/commons": "^5.0.0-pre.
|
|
61
|
-
"@feathersjs/feathers": "^5.0.0-pre.
|
|
60
|
+
"@feathersjs/commons": "^5.0.0-pre.18",
|
|
61
|
+
"@feathersjs/feathers": "^5.0.0-pre.18",
|
|
62
|
+
"@feathersjs/schema": "^5.0.0-pre.18",
|
|
62
63
|
"@types/config": "^0.0.41",
|
|
63
64
|
"config": "^3.3.7"
|
|
64
65
|
},
|
|
65
66
|
"devDependencies": {
|
|
66
67
|
"@types/mocha": "^9.1.0",
|
|
67
|
-
"@types/node": "^17.0.
|
|
68
|
-
"mocha": "^9.2.
|
|
68
|
+
"@types/node": "^17.0.23",
|
|
69
|
+
"mocha": "^9.2.2",
|
|
69
70
|
"shx": "^0.3.4",
|
|
70
|
-
"ts-node": "^10.
|
|
71
|
-
"typescript": "^4.
|
|
71
|
+
"ts-node": "^10.7.0",
|
|
72
|
+
"typescript": "^4.6.3"
|
|
72
73
|
},
|
|
73
|
-
"gitHead": "
|
|
74
|
+
"gitHead": "c0b7b67d872dcd6b6d94e4587f21332c8a519b50"
|
|
74
75
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { Application } from '@feathersjs/feathers';
|
|
1
|
+
import { Application, ApplicationHookContext, NextFunction } from '@feathersjs/feathers';
|
|
2
2
|
import { createDebug } from '@feathersjs/commons';
|
|
3
|
+
import { Schema } from '@feathersjs/schema'
|
|
3
4
|
import config from 'config';
|
|
4
5
|
|
|
5
6
|
const debug = createDebug('@feathersjs/configuration');
|
|
6
7
|
|
|
7
|
-
export = function init () {
|
|
8
|
+
export = function init (schema?: Schema<any>) {
|
|
8
9
|
return (app?: Application) => {
|
|
9
10
|
if (!app) {
|
|
10
11
|
return config;
|
|
@@ -18,6 +19,15 @@ export = function init () {
|
|
|
18
19
|
app.set(name, value);
|
|
19
20
|
});
|
|
20
21
|
|
|
22
|
+
if (schema) {
|
|
23
|
+
app.hooks({
|
|
24
|
+
setup: [async (context: ApplicationHookContext, next: NextFunction) => {
|
|
25
|
+
await schema.validate(context.app.settings);
|
|
26
|
+
await next();
|
|
27
|
+
}]
|
|
28
|
+
})
|
|
29
|
+
}
|
|
30
|
+
|
|
21
31
|
return config;
|
|
22
32
|
};
|
|
23
33
|
}
|