@tsed/platform-middlewares 7.0.0-beta.9 → 7.0.0-rc.1
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/jest.config.js +14 -0
- package/lib/cjs/utils/getMiddlewaresForHook.js +3 -4
- package/lib/cjs/utils/getMiddlewaresForHook.js.map +1 -1
- package/lib/esm/utils/getMiddlewaresForHook.js +3 -4
- package/lib/esm/utils/getMiddlewaresForHook.js.map +1 -1
- package/lib/types/utils/getMiddlewaresForHook.d.ts +2 -1
- package/package.json +15 -11
- package/readme.md +3 -2
package/jest.config.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// For a detailed explanation regarding each configuration property, visit:
|
|
2
|
+
// https://jestjs.io/docs/en/configuration.html
|
|
3
|
+
|
|
4
|
+
module.exports = {
|
|
5
|
+
...require("@tsed/jest-config")(__dirname, "platform-middlewares"),
|
|
6
|
+
coverageThreshold: {
|
|
7
|
+
global: {
|
|
8
|
+
statements: 100,
|
|
9
|
+
branches: 100,
|
|
10
|
+
functions: 100,
|
|
11
|
+
lines: 100
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
};
|
|
@@ -3,7 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.getMiddlewaresForHook = void 0;
|
|
4
4
|
const core_1 = require("@tsed/core");
|
|
5
5
|
function getMiddlewaresForHook(hook, settings, defaultHook = "") {
|
|
6
|
-
const
|
|
6
|
+
const env = settings.env;
|
|
7
|
+
const middlewares = settings.get("middlewares", []);
|
|
7
8
|
return middlewares
|
|
8
9
|
.map((middleware) => {
|
|
9
10
|
return (0, core_1.isFunction)(middleware)
|
|
@@ -18,9 +19,7 @@ function getMiddlewaresForHook(hook, settings, defaultHook = "") {
|
|
|
18
19
|
...middleware
|
|
19
20
|
};
|
|
20
21
|
})
|
|
21
|
-
.filter((options) =>
|
|
22
|
-
return options.use && options.env === env && options.hook === hook;
|
|
23
|
-
});
|
|
22
|
+
.filter((options) => options.use && options.env === env && options.hook === hook);
|
|
24
23
|
}
|
|
25
24
|
exports.getMiddlewaresForHook = getMiddlewaresForHook;
|
|
26
25
|
//# sourceMappingURL=getMiddlewaresForHook.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getMiddlewaresForHook.js","sourceRoot":"","sources":["../../../src/utils/getMiddlewaresForHook.ts"],"names":[],"mappings":";;;AAAA,qCAAsC;
|
|
1
|
+
{"version":3,"file":"getMiddlewaresForHook.js","sourceRoot":"","sources":["../../../src/utils/getMiddlewaresForHook.ts"],"names":[],"mappings":";;;AAAA,qCAAsC;AAItC,SAAgB,qBAAqB,CAAC,IAAY,EAAE,QAAyB,EAAE,WAAW,GAAG,EAAE;IAC7F,MAAM,GAAG,GAAG,QAAQ,CAAC,GAAG,CAAC;IACzB,MAAM,WAAW,GAAG,QAAQ,CAAC,GAAG,CAA+B,aAAa,EAAE,EAAE,CAAC,CAAC;IAElF,OAAO,WAAW;SACf,GAAG,CAAmC,CAAC,UAAU,EAAE,EAAE;QACpD,OAAO,IAAA,iBAAU,EAAC,UAAU,CAAC;YAC3B,CAAC,CAAC;gBACE,GAAG;gBACH,IAAI,EAAE,WAAW;gBACjB,GAAG,EAAE,UAAU;aAChB;YACH,CAAC,CAAC;gBACE,GAAG;gBACH,IAAI,EAAE,WAAW;gBACjB,GAAG,UAAU;aACd,CAAC;IACR,CAAC,CAAC;SACD,MAAM,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,IAAI,OAAO,CAAC,GAAG,KAAK,GAAG,IAAI,OAAO,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC;AACtF,CAAC;AAnBD,sDAmBC","sourcesContent":["import {isFunction} from \"@tsed/core\";\nimport {DIConfiguration} from \"@tsed/di\";\nimport {PlatformMiddlewareLoadingOptions, PlatformMiddlewareSettings} from \"../domain/PlatformMiddlewareSettings\";\n\nexport function getMiddlewaresForHook(hook: string, settings: DIConfiguration, defaultHook = \"\") {\n const env = settings.env;\n const middlewares = settings.get<PlatformMiddlewareSettings[]>(\"middlewares\", []);\n\n return middlewares\n .map<PlatformMiddlewareLoadingOptions>((middleware) => {\n return isFunction(middleware)\n ? {\n env,\n hook: defaultHook,\n use: middleware\n }\n : {\n env,\n hook: defaultHook,\n ...middleware\n };\n })\n .filter((options) => options.use && options.env === env && options.hook === hook);\n}\n"]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { isFunction } from "@tsed/core";
|
|
2
2
|
export function getMiddlewaresForHook(hook, settings, defaultHook = "") {
|
|
3
|
-
const
|
|
3
|
+
const env = settings.env;
|
|
4
|
+
const middlewares = settings.get("middlewares", []);
|
|
4
5
|
return middlewares
|
|
5
6
|
.map((middleware) => {
|
|
6
7
|
return isFunction(middleware)
|
|
@@ -15,8 +16,6 @@ export function getMiddlewaresForHook(hook, settings, defaultHook = "") {
|
|
|
15
16
|
...middleware
|
|
16
17
|
};
|
|
17
18
|
})
|
|
18
|
-
.filter((options) =>
|
|
19
|
-
return options.use && options.env === env && options.hook === hook;
|
|
20
|
-
});
|
|
19
|
+
.filter((options) => options.use && options.env === env && options.hook === hook);
|
|
21
20
|
}
|
|
22
21
|
//# sourceMappingURL=getMiddlewaresForHook.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getMiddlewaresForHook.js","sourceRoot":"","sources":["../../../src/utils/getMiddlewaresForHook.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"getMiddlewaresForHook.js","sourceRoot":"","sources":["../../../src/utils/getMiddlewaresForHook.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,YAAY,CAAC;AAItC,MAAM,UAAU,qBAAqB,CAAC,IAAY,EAAE,QAAyB,EAAE,WAAW,GAAG,EAAE;IAC7F,MAAM,GAAG,GAAG,QAAQ,CAAC,GAAG,CAAC;IACzB,MAAM,WAAW,GAAG,QAAQ,CAAC,GAAG,CAA+B,aAAa,EAAE,EAAE,CAAC,CAAC;IAElF,OAAO,WAAW;SACf,GAAG,CAAmC,CAAC,UAAU,EAAE,EAAE;QACpD,OAAO,UAAU,CAAC,UAAU,CAAC;YAC3B,CAAC,CAAC;gBACE,GAAG;gBACH,IAAI,EAAE,WAAW;gBACjB,GAAG,EAAE,UAAU;aAChB;YACH,CAAC,CAAC;gBACE,GAAG;gBACH,IAAI,EAAE,WAAW;gBACjB,GAAG,UAAU;aACd,CAAC;IACR,CAAC,CAAC;SACD,MAAM,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,IAAI,OAAO,CAAC,GAAG,KAAK,GAAG,IAAI,OAAO,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC;AACtF,CAAC","sourcesContent":["import {isFunction} from \"@tsed/core\";\nimport {DIConfiguration} from \"@tsed/di\";\nimport {PlatformMiddlewareLoadingOptions, PlatformMiddlewareSettings} from \"../domain/PlatformMiddlewareSettings\";\n\nexport function getMiddlewaresForHook(hook: string, settings: DIConfiguration, defaultHook = \"\") {\n const env = settings.env;\n const middlewares = settings.get<PlatformMiddlewareSettings[]>(\"middlewares\", []);\n\n return middlewares\n .map<PlatformMiddlewareLoadingOptions>((middleware) => {\n return isFunction(middleware)\n ? {\n env,\n hook: defaultHook,\n use: middleware\n }\n : {\n env,\n hook: defaultHook,\n ...middleware\n };\n })\n .filter((options) => options.use && options.env === env && options.hook === hook);\n}\n"]}
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
+
import { DIConfiguration } from "@tsed/di";
|
|
1
2
|
import { PlatformMiddlewareLoadingOptions } from "../domain/PlatformMiddlewareSettings";
|
|
2
|
-
export declare function getMiddlewaresForHook(hook: string, settings:
|
|
3
|
+
export declare function getMiddlewaresForHook(hook: string, settings: DIConfiguration, defaultHook?: string): PlatformMiddlewareLoadingOptions[];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsed/platform-middlewares",
|
|
3
|
-
"version": "7.0.0-
|
|
3
|
+
"version": "7.0.0-rc.1",
|
|
4
4
|
"description": "Middlewares module for Ts.ED Framework",
|
|
5
5
|
"private": false,
|
|
6
6
|
"source": "./src/index.ts",
|
|
@@ -17,20 +17,21 @@
|
|
|
17
17
|
"build": "yarn barrels && yarn run build:esm && yarn run build:cjs",
|
|
18
18
|
"build:cjs": "tsc --build tsconfig.compile.json",
|
|
19
19
|
"build:esm": "tsc --build tsconfig.compile.esm.json",
|
|
20
|
-
"barrels": "yarn barrelsby --delete -d ./src -e \"\\.spec\\.ts\" -e \"__mock__\" -e \".benchmark.ts\""
|
|
20
|
+
"barrels": "yarn barrelsby --delete -d ./src -e \"\\.spec\\.ts\" -e \"__mock__\" -e \".benchmark.ts\"",
|
|
21
|
+
"test": "cross-env NODE_ENV=test yarn jest --max-workers=2"
|
|
21
22
|
},
|
|
22
23
|
"dependencies": {
|
|
23
|
-
"tslib": "2.
|
|
24
|
+
"tslib": "2.4.0"
|
|
24
25
|
},
|
|
25
26
|
"devDependencies": {
|
|
26
|
-
"@tsed/core": "7.0.0-
|
|
27
|
-
"@tsed/di": "7.0.0-
|
|
28
|
-
"@tsed/schema": "7.0.0-
|
|
27
|
+
"@tsed/core": "7.0.0-rc.1",
|
|
28
|
+
"@tsed/di": "7.0.0-rc.1",
|
|
29
|
+
"@tsed/schema": "7.0.0-rc.1"
|
|
29
30
|
},
|
|
30
31
|
"peerDependencies": {
|
|
31
|
-
"@tsed/core": "^7.0.0-
|
|
32
|
-
"@tsed/di": "^7.0.0-
|
|
33
|
-
"@tsed/schema": "^7.0.0-
|
|
32
|
+
"@tsed/core": "^7.0.0-rc.1",
|
|
33
|
+
"@tsed/di": "^7.0.0-rc.1",
|
|
34
|
+
"@tsed/schema": "^7.0.0-rc.1"
|
|
34
35
|
},
|
|
35
36
|
"peerDependenciesMeta": {
|
|
36
37
|
"@tsed/core": {
|
|
@@ -47,7 +48,10 @@
|
|
|
47
48
|
"bugs": {
|
|
48
49
|
"url": "https://github.com/tsedio/tsed/issues"
|
|
49
50
|
},
|
|
50
|
-
"homepage": "https://github.com/tsedio/tsed/tree/
|
|
51
|
+
"homepage": "https://github.com/tsedio/tsed/tree/rc/packages/platform/platform-middlewares",
|
|
51
52
|
"author": "Romain Lenzotti",
|
|
52
|
-
"license": "MIT"
|
|
53
|
+
"license": "MIT",
|
|
54
|
+
"publishConfig": {
|
|
55
|
+
"tag": "rc"
|
|
56
|
+
}
|
|
53
57
|
}
|
package/readme.md
CHANGED
|
@@ -11,7 +11,8 @@
|
|
|
11
11
|
[](https://badge.fury.io/js/%40tsed%2Fcommon)
|
|
12
12
|
[](https://github.com/semantic-release/semantic-release)
|
|
13
13
|
[](https://github.com/prettier/prettier)
|
|
14
|
-
[](https://github.com/sponsors/romakita)
|
|
15
|
+
[](https://opencollective.com/tsed)
|
|
15
16
|
|
|
16
17
|
</div>
|
|
17
18
|
|
|
@@ -55,7 +56,7 @@ Support this project by becoming a sponsor. Your logo will show up here with a l
|
|
|
55
56
|
|
|
56
57
|
The MIT License (MIT)
|
|
57
58
|
|
|
58
|
-
Copyright (c) 2016 -
|
|
59
|
+
Copyright (c) 2016 - 2022 Romain Lenzotti
|
|
59
60
|
|
|
60
61
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
61
62
|
|