@wooksjs/event-http 0.2.19 → 0.2.21
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/index.cjs +4 -4
- package/dist/index.d.ts +1 -0
- package/dist/index.mjs +4 -4
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -832,7 +832,7 @@ class HttpErrorRenderer extends BaseHttpResponseRenderer {
|
|
|
832
832
|
`<head><title>${data.statusCode} ${httpStatusCodes[data.statusCode]}</title></head>` +
|
|
833
833
|
`<body><center><h1>${data.statusCode} ${httpStatusCodes[data.statusCode]}</h1></center>` +
|
|
834
834
|
`<center><h4>${data.message}</h1></center><hr color="#666">` +
|
|
835
|
-
`<center style="color: #666;"> Wooks v${"0.2.
|
|
835
|
+
`<center style="color: #666;"> Wooks v${"0.2.21"} </center>` +
|
|
836
836
|
`${keys.length
|
|
837
837
|
? `<pre style="${preStyles}">${JSON.stringify(Object.assign(Object.assign({}, data), { statusCode: undefined, message: undefined, error: undefined }), null, ' ')}</pre>`
|
|
838
838
|
: ''}` +
|
|
@@ -1007,12 +1007,12 @@ class WooksHttp extends wooks.WooksAdapterBase {
|
|
|
1007
1007
|
}
|
|
1008
1008
|
getServerCb() {
|
|
1009
1009
|
return (req, res) => __awaiter(this, void 0, void 0, function* () {
|
|
1010
|
-
var _a;
|
|
1010
|
+
var _a, _b, _c;
|
|
1011
1011
|
const { restoreCtx, clearCtx } = createHttpContext({ req, res }, this.mergeEventOptions((_a = this.opts) === null || _a === void 0 ? void 0 : _a.eventOptions));
|
|
1012
1012
|
const handlers = this.wooks.lookup(req.method, req.url);
|
|
1013
|
-
if (handlers) {
|
|
1013
|
+
if (handlers || ((_b = this.opts) === null || _b === void 0 ? void 0 : _b.onNotFound)) {
|
|
1014
1014
|
try {
|
|
1015
|
-
yield this.processHandlers(handlers);
|
|
1015
|
+
yield this.processHandlers(handlers || [(_c = this.opts) === null || _c === void 0 ? void 0 : _c.onNotFound]);
|
|
1016
1016
|
}
|
|
1017
1017
|
catch (e) {
|
|
1018
1018
|
this.logger.error('Internal error, please report', e);
|
package/dist/index.d.ts
CHANGED
|
@@ -349,6 +349,7 @@ export declare interface TWooksErrorBodyExt extends TWooksErrorBody {
|
|
|
349
349
|
export declare interface TWooksHttpOptions {
|
|
350
350
|
logger?: TConsoleBase;
|
|
351
351
|
eventOptions?: TEventOptions;
|
|
352
|
+
onNotFound?: TWooksHandler<unknown>;
|
|
352
353
|
}
|
|
353
354
|
|
|
354
355
|
export declare interface TWooksResponseRenderer<T = unknown> {
|
package/dist/index.mjs
CHANGED
|
@@ -830,7 +830,7 @@ class HttpErrorRenderer extends BaseHttpResponseRenderer {
|
|
|
830
830
|
`<head><title>${data.statusCode} ${httpStatusCodes[data.statusCode]}</title></head>` +
|
|
831
831
|
`<body><center><h1>${data.statusCode} ${httpStatusCodes[data.statusCode]}</h1></center>` +
|
|
832
832
|
`<center><h4>${data.message}</h1></center><hr color="#666">` +
|
|
833
|
-
`<center style="color: #666;"> Wooks v${"0.2.
|
|
833
|
+
`<center style="color: #666;"> Wooks v${"0.2.21"} </center>` +
|
|
834
834
|
`${keys.length
|
|
835
835
|
? `<pre style="${preStyles}">${JSON.stringify(Object.assign(Object.assign({}, data), { statusCode: undefined, message: undefined, error: undefined }), null, ' ')}</pre>`
|
|
836
836
|
: ''}` +
|
|
@@ -1005,12 +1005,12 @@ class WooksHttp extends WooksAdapterBase {
|
|
|
1005
1005
|
}
|
|
1006
1006
|
getServerCb() {
|
|
1007
1007
|
return (req, res) => __awaiter(this, void 0, void 0, function* () {
|
|
1008
|
-
var _a;
|
|
1008
|
+
var _a, _b, _c;
|
|
1009
1009
|
const { restoreCtx, clearCtx } = createHttpContext({ req, res }, this.mergeEventOptions((_a = this.opts) === null || _a === void 0 ? void 0 : _a.eventOptions));
|
|
1010
1010
|
const handlers = this.wooks.lookup(req.method, req.url);
|
|
1011
|
-
if (handlers) {
|
|
1011
|
+
if (handlers || ((_b = this.opts) === null || _b === void 0 ? void 0 : _b.onNotFound)) {
|
|
1012
1012
|
try {
|
|
1013
|
-
yield this.processHandlers(handlers);
|
|
1013
|
+
yield this.processHandlers(handlers || [(_c = this.opts) === null || _c === void 0 ? void 0 : _c.onNotFound]);
|
|
1014
1014
|
}
|
|
1015
1015
|
catch (e) {
|
|
1016
1016
|
this.logger.error('Internal error, please report', e);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wooksjs/event-http",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.21",
|
|
4
4
|
"description": "@wooksjs/event-http",
|
|
5
5
|
"main": "dist/index.cjs",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -31,9 +31,9 @@
|
|
|
31
31
|
"url": "https://github.com/wooksjs/wooksjs/issues"
|
|
32
32
|
},
|
|
33
33
|
"peerDependencies": {
|
|
34
|
-
"wooks": "0.2.
|
|
34
|
+
"wooks": "0.2.21",
|
|
35
35
|
"@prostojs/router": "^0.1.0",
|
|
36
|
-
"@wooksjs/event-core": "0.2.
|
|
36
|
+
"@wooksjs/event-core": "0.2.21"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"@prostojs/logger": "^0.3.6"
|