keq 5.0.0-alpha.24 → 5.0.0-alpha.25
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 +21 -0
- package/dist/exception/http-exceptions/bad-gateway.exception.d.ts +2 -2
- package/dist/exception/http-exceptions/bad-gateway.exception.d.ts.map +1 -1
- package/dist/exception/http-exceptions/bad-request.exception.d.ts +2 -2
- package/dist/exception/http-exceptions/bad-request.exception.d.ts.map +1 -1
- package/dist/exception/http-exceptions/conflict.exception.d.ts +2 -2
- package/dist/exception/http-exceptions/conflict.exception.d.ts.map +1 -1
- package/dist/exception/http-exceptions/content-too-large.exception.d.ts +2 -2
- package/dist/exception/http-exceptions/content-too-large.exception.d.ts.map +1 -1
- package/dist/exception/http-exceptions/forbidden.exception.d.ts +2 -2
- package/dist/exception/http-exceptions/forbidden.exception.d.ts.map +1 -1
- package/dist/exception/http-exceptions/gateway-timeout.exception.d.ts +2 -2
- package/dist/exception/http-exceptions/gateway-timeout.exception.d.ts.map +1 -1
- package/dist/exception/http-exceptions/http-version-not-supported.exception.d.ts +2 -2
- package/dist/exception/http-exceptions/http-version-not-supported.exception.d.ts.map +1 -1
- package/dist/exception/http-exceptions/im-a-teapot.exception.d.ts +2 -2
- package/dist/exception/http-exceptions/im-a-teapot.exception.d.ts.map +1 -1
- package/dist/exception/http-exceptions/internal-server-error.exception.d.ts +2 -2
- package/dist/exception/http-exceptions/internal-server-error.exception.d.ts.map +1 -1
- package/dist/exception/http-exceptions/method-not-allowed.exception.d.ts +2 -2
- package/dist/exception/http-exceptions/method-not-allowed.exception.d.ts.map +1 -1
- package/dist/exception/http-exceptions/not-acceptable.exception.d.ts +2 -2
- package/dist/exception/http-exceptions/not-acceptable.exception.d.ts.map +1 -1
- package/dist/exception/http-exceptions/not-founded.exception.d.ts +2 -2
- package/dist/exception/http-exceptions/not-founded.exception.d.ts.map +1 -1
- package/dist/exception/http-exceptions/not-implemented.exception.d.ts +2 -2
- package/dist/exception/http-exceptions/not-implemented.exception.d.ts.map +1 -1
- package/dist/exception/http-exceptions/precondition-failed.exception.d.ts +2 -2
- package/dist/exception/http-exceptions/precondition-failed.exception.d.ts.map +1 -1
- package/dist/exception/http-exceptions/proxy-authentication-required.exception.d.ts +2 -2
- package/dist/exception/http-exceptions/proxy-authentication-required.exception.d.ts.map +1 -1
- package/dist/exception/http-exceptions/request-timeout.exception.d.ts +2 -2
- package/dist/exception/http-exceptions/request-timeout.exception.d.ts.map +1 -1
- package/dist/exception/http-exceptions/request.exception.d.ts +7 -2
- package/dist/exception/http-exceptions/request.exception.d.ts.map +1 -1
- package/dist/exception/http-exceptions/service-unavailable.exception.d.ts +2 -2
- package/dist/exception/http-exceptions/service-unavailable.exception.d.ts.map +1 -1
- package/dist/exception/http-exceptions/too-many-requests.exception.d.ts +2 -2
- package/dist/exception/http-exceptions/too-many-requests.exception.d.ts.map +1 -1
- package/dist/exception/http-exceptions/unauthorized.exception.d.ts +2 -2
- package/dist/exception/http-exceptions/unauthorized.exception.d.ts.map +1 -1
- package/dist/exception/http-exceptions/unsupported-media-type.exception.d.ts +2 -2
- package/dist/exception/http-exceptions/unsupported-media-type.exception.d.ts.map +1 -1
- package/dist/exception/http-exceptions/uri-too-long.exception.d.ts +2 -2
- package/dist/exception/http-exceptions/uri-too-long.exception.d.ts.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +108 -73
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +108 -73
- package/dist/index.mjs.map +1 -1
- package/dist/request/request.d.ts +2 -1
- package/dist/request/request.d.ts.map +1 -1
- package/dist/router/index.d.ts +0 -5
- package/dist/router/index.d.ts.map +1 -1
- package/dist/router/keq-router.d.ts +25 -7
- package/dist/router/keq-router.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -67,11 +67,6 @@ __export(index_exports, {
|
|
|
67
67
|
composeRoute: () => composeRoute,
|
|
68
68
|
createProxyResponse: () => createProxyResponse,
|
|
69
69
|
createRequest: () => createRequest,
|
|
70
|
-
keqHostRoute: () => keqHostRoute,
|
|
71
|
-
keqLocationRoute: () => keqLocationRoute,
|
|
72
|
-
keqMethodRoute: () => keqMethodRoute,
|
|
73
|
-
keqModuleRoute: () => keqModuleRoute,
|
|
74
|
-
keqPathnameRoute: () => keqPathnameRoute,
|
|
75
70
|
request: () => request
|
|
76
71
|
});
|
|
77
72
|
module.exports = __toCommonJS(index_exports);
|
|
@@ -109,52 +104,54 @@ var TimeoutException = class extends AbortException {
|
|
|
109
104
|
|
|
110
105
|
// src/exception/http-exceptions/request.exception.ts
|
|
111
106
|
var RequestException = class extends Exception {
|
|
112
|
-
constructor(statusCode, message,
|
|
107
|
+
constructor(statusCode, message, options) {
|
|
113
108
|
super(message);
|
|
114
109
|
__publicField(this, "statusCode");
|
|
115
110
|
__publicField(this, "retry");
|
|
111
|
+
__publicField(this, "response");
|
|
116
112
|
this.statusCode = statusCode;
|
|
117
|
-
this.retry =
|
|
113
|
+
this.retry = !(options == null ? void 0 : options.fatal);
|
|
114
|
+
this.response = options == null ? void 0 : options.response;
|
|
118
115
|
Object.defineProperty(this, "name", { value: "RequestException" });
|
|
119
116
|
}
|
|
120
117
|
};
|
|
121
118
|
|
|
122
119
|
// src/exception/http-exceptions/bad-request.exception.ts
|
|
123
120
|
var BadRequestException = class extends RequestException {
|
|
124
|
-
constructor(message = "Bad Request",
|
|
125
|
-
super(400, message,
|
|
121
|
+
constructor(message = "Bad Request", options) {
|
|
122
|
+
super(400, message, { fatal: true, ...options });
|
|
126
123
|
Object.defineProperty(this, "name", { value: "BadRequestException" });
|
|
127
124
|
}
|
|
128
125
|
};
|
|
129
126
|
|
|
130
127
|
// src/exception/http-exceptions/unauthorized.exception.ts
|
|
131
128
|
var UnauthorizedException = class extends RequestException {
|
|
132
|
-
constructor(message = "Unauthorized",
|
|
133
|
-
super(401, message,
|
|
129
|
+
constructor(message = "Unauthorized", options) {
|
|
130
|
+
super(401, message, { fatal: true, ...options });
|
|
134
131
|
Object.defineProperty(this, "name", { value: "UnauthorizedException" });
|
|
135
132
|
}
|
|
136
133
|
};
|
|
137
134
|
|
|
138
135
|
// src/exception/http-exceptions/forbidden.exception.ts
|
|
139
136
|
var ForbiddenException = class extends RequestException {
|
|
140
|
-
constructor(message = "Forbidden",
|
|
141
|
-
super(403, message,
|
|
137
|
+
constructor(message = "Forbidden", options) {
|
|
138
|
+
super(403, message, { fatal: true, ...options });
|
|
142
139
|
Object.defineProperty(this, "name", { value: "ForbiddenException" });
|
|
143
140
|
}
|
|
144
141
|
};
|
|
145
142
|
|
|
146
143
|
// src/exception/http-exceptions/not-founded.exception.ts
|
|
147
144
|
var NotFoundedException = class extends RequestException {
|
|
148
|
-
constructor(message = "Not Founded",
|
|
149
|
-
super(404, message,
|
|
145
|
+
constructor(message = "Not Founded", options) {
|
|
146
|
+
super(404, message, { fatal: true, ...options });
|
|
150
147
|
Object.defineProperty(this, "name", { value: "NotFoundedException" });
|
|
151
148
|
}
|
|
152
149
|
};
|
|
153
150
|
|
|
154
151
|
// src/exception/http-exceptions/method-not-allowed.exception.ts
|
|
155
152
|
var MethodNotAllowedException = class extends RequestException {
|
|
156
|
-
constructor(message = "Method Not Allowed",
|
|
157
|
-
super(405, message,
|
|
153
|
+
constructor(message = "Method Not Allowed", options) {
|
|
154
|
+
super(405, message, { fatal: true, ...options });
|
|
158
155
|
Object.defineProperty(this, "name", {
|
|
159
156
|
value: "MethodNotAllowedException"
|
|
160
157
|
});
|
|
@@ -163,16 +160,16 @@ var MethodNotAllowedException = class extends RequestException {
|
|
|
163
160
|
|
|
164
161
|
// src/exception/http-exceptions/not-acceptable.exception.ts
|
|
165
162
|
var NotAcceptableException = class extends RequestException {
|
|
166
|
-
constructor(message = "Not Acceptable",
|
|
167
|
-
super(406, message,
|
|
163
|
+
constructor(message = "Not Acceptable", options) {
|
|
164
|
+
super(406, message, { fatal: true, ...options });
|
|
168
165
|
Object.defineProperty(this, "name", { value: "NotAcceptableException" });
|
|
169
166
|
}
|
|
170
167
|
};
|
|
171
168
|
|
|
172
169
|
// src/exception/http-exceptions/proxy-authentication-required.exception.ts
|
|
173
170
|
var ProxyAuthenticationRequiredException = class extends RequestException {
|
|
174
|
-
constructor(message = "Proxy Authentication Required",
|
|
175
|
-
super(407, message,
|
|
171
|
+
constructor(message = "Proxy Authentication Required", options) {
|
|
172
|
+
super(407, message, { fatal: true, ...options });
|
|
176
173
|
Object.defineProperty(this, "name", {
|
|
177
174
|
value: "ProxyAuthenticationRequiredException"
|
|
178
175
|
});
|
|
@@ -181,8 +178,8 @@ var ProxyAuthenticationRequiredException = class extends RequestException {
|
|
|
181
178
|
|
|
182
179
|
// src/exception/http-exceptions/request-timeout.exception.ts
|
|
183
180
|
var RequestTimeoutException = class extends RequestException {
|
|
184
|
-
constructor(message = "Request Timeout",
|
|
185
|
-
super(408, message,
|
|
181
|
+
constructor(message = "Request Timeout", options) {
|
|
182
|
+
super(408, message, { fatal: false, ...options });
|
|
186
183
|
Object.defineProperty(this, "name", {
|
|
187
184
|
value: "RequestTimeoutException"
|
|
188
185
|
});
|
|
@@ -191,16 +188,16 @@ var RequestTimeoutException = class extends RequestException {
|
|
|
191
188
|
|
|
192
189
|
// src/exception/http-exceptions/conflict.exception.ts
|
|
193
190
|
var ConflictException = class extends RequestException {
|
|
194
|
-
constructor(message = "Conflict",
|
|
195
|
-
super(409, message,
|
|
191
|
+
constructor(message = "Conflict", options) {
|
|
192
|
+
super(409, message, { fatal: true, ...options });
|
|
196
193
|
Object.defineProperty(this, "name", { value: "ConflictException" });
|
|
197
194
|
}
|
|
198
195
|
};
|
|
199
196
|
|
|
200
197
|
// src/exception/http-exceptions/precondition-failed.exception.ts
|
|
201
198
|
var PreconditionFailedException = class extends RequestException {
|
|
202
|
-
constructor(message = "Precondition Failed",
|
|
203
|
-
super(412, message,
|
|
199
|
+
constructor(message = "Precondition Failed", options) {
|
|
200
|
+
super(412, message, { fatal: true, ...options });
|
|
204
201
|
Object.defineProperty(this, "name", {
|
|
205
202
|
value: "PreconditionFailedException"
|
|
206
203
|
});
|
|
@@ -209,8 +206,8 @@ var PreconditionFailedException = class extends RequestException {
|
|
|
209
206
|
|
|
210
207
|
// src/exception/http-exceptions/content-too-large.exception.ts
|
|
211
208
|
var ContentTooLargeException = class extends RequestException {
|
|
212
|
-
constructor(message = "Content Too Large",
|
|
213
|
-
super(413, message,
|
|
209
|
+
constructor(message = "Content Too Large", options) {
|
|
210
|
+
super(413, message, { fatal: true, ...options });
|
|
214
211
|
Object.defineProperty(this, "name", {
|
|
215
212
|
value: "ContentTooLargeException"
|
|
216
213
|
});
|
|
@@ -219,40 +216,40 @@ var ContentTooLargeException = class extends RequestException {
|
|
|
219
216
|
|
|
220
217
|
// src/exception/http-exceptions/uri-too-long.exception.ts
|
|
221
218
|
var UriTooLongException = class extends RequestException {
|
|
222
|
-
constructor(message = "URI Too Long",
|
|
223
|
-
super(414, message,
|
|
219
|
+
constructor(message = "URI Too Long", options) {
|
|
220
|
+
super(414, message, { fatal: true, ...options });
|
|
224
221
|
Object.defineProperty(this, "name", { value: "UriTooLongException" });
|
|
225
222
|
}
|
|
226
223
|
};
|
|
227
224
|
|
|
228
225
|
// src/exception/http-exceptions/unsupported-media-type.exception.ts
|
|
229
226
|
var UnsupportedMediaTypeException = class extends RequestException {
|
|
230
|
-
constructor(message = "Unsupported Media Type",
|
|
231
|
-
super(415, message,
|
|
227
|
+
constructor(message = "Unsupported Media Type", options) {
|
|
228
|
+
super(415, message, { fatal: true, ...options });
|
|
232
229
|
Object.defineProperty(this, "name", { value: "UnsupportedMediaTypeException" });
|
|
233
230
|
}
|
|
234
231
|
};
|
|
235
232
|
|
|
236
233
|
// src/exception/http-exceptions/im-a-teapot.exception.ts
|
|
237
234
|
var ImATeapotException = class extends RequestException {
|
|
238
|
-
constructor(message = "I'm a teapot",
|
|
239
|
-
super(418, message,
|
|
235
|
+
constructor(message = "I'm a teapot", options) {
|
|
236
|
+
super(418, message, { fatal: true, ...options });
|
|
240
237
|
Object.defineProperty(this, "name", { value: "ImATeapotException" });
|
|
241
238
|
}
|
|
242
239
|
};
|
|
243
240
|
|
|
244
241
|
// src/exception/http-exceptions/too-many-requests.exception.ts
|
|
245
242
|
var TooManyRequestsException = class extends RequestException {
|
|
246
|
-
constructor(message = "Too Many Requests",
|
|
247
|
-
super(429, message,
|
|
243
|
+
constructor(message = "Too Many Requests", options) {
|
|
244
|
+
super(429, message, { fatal: false, ...options });
|
|
248
245
|
Object.defineProperty(this, "name", { value: "TooManyRequestsException" });
|
|
249
246
|
}
|
|
250
247
|
};
|
|
251
248
|
|
|
252
249
|
// src/exception/http-exceptions/internal-server-error.exception.ts
|
|
253
250
|
var InternalServerErrorException = class extends RequestException {
|
|
254
|
-
constructor(message = "Internal Server Error",
|
|
255
|
-
super(500, message,
|
|
251
|
+
constructor(message = "Internal Server Error", options) {
|
|
252
|
+
super(500, message, { fatal: false, ...options });
|
|
256
253
|
Object.defineProperty(this, "name", {
|
|
257
254
|
value: "InternalServerErrorException"
|
|
258
255
|
});
|
|
@@ -261,24 +258,24 @@ var InternalServerErrorException = class extends RequestException {
|
|
|
261
258
|
|
|
262
259
|
// src/exception/http-exceptions/not-implemented.exception.ts
|
|
263
260
|
var NotImplementedException = class extends RequestException {
|
|
264
|
-
constructor(message = "Not Implemented",
|
|
265
|
-
super(501, message,
|
|
261
|
+
constructor(message = "Not Implemented", options) {
|
|
262
|
+
super(501, message, { fatal: true, ...options });
|
|
266
263
|
Object.defineProperty(this, "name", { value: "NotImplementedException" });
|
|
267
264
|
}
|
|
268
265
|
};
|
|
269
266
|
|
|
270
267
|
// src/exception/http-exceptions/bad-gateway.exception.ts
|
|
271
268
|
var BadGatewayException = class extends RequestException {
|
|
272
|
-
constructor(message = "Bad Gateway",
|
|
273
|
-
super(502, message,
|
|
269
|
+
constructor(message = "Bad Gateway", options) {
|
|
270
|
+
super(502, message, { fatal: false, ...options });
|
|
274
271
|
Object.defineProperty(this, "name", { value: "BadGatewayException" });
|
|
275
272
|
}
|
|
276
273
|
};
|
|
277
274
|
|
|
278
275
|
// src/exception/http-exceptions/service-unavailable.exception.ts
|
|
279
276
|
var ServiceUnavailableException = class extends RequestException {
|
|
280
|
-
constructor(message = "Service Unavailable",
|
|
281
|
-
super(503, message,
|
|
277
|
+
constructor(message = "Service Unavailable", options) {
|
|
278
|
+
super(503, message, { fatal: false, ...options });
|
|
282
279
|
Object.defineProperty(this, "name", {
|
|
283
280
|
value: "ServiceUnavailableException"
|
|
284
281
|
});
|
|
@@ -287,8 +284,8 @@ var ServiceUnavailableException = class extends RequestException {
|
|
|
287
284
|
|
|
288
285
|
// src/exception/http-exceptions/gateway-timeout.exception.ts
|
|
289
286
|
var GatewayTimeoutException = class extends RequestException {
|
|
290
|
-
constructor(message = "Gateway Timeout",
|
|
291
|
-
super(504, message,
|
|
287
|
+
constructor(message = "Gateway Timeout", options) {
|
|
288
|
+
super(504, message, { fatal: false, ...options });
|
|
292
289
|
Object.defineProperty(this, "name", { value: "GatewayTimeoutException" });
|
|
293
290
|
}
|
|
294
291
|
};
|
|
@@ -1670,11 +1667,11 @@ function keqPathnameRoute(pathname) {
|
|
|
1670
1667
|
}
|
|
1671
1668
|
|
|
1672
1669
|
// src/router/keq-router.ts
|
|
1673
|
-
var KeqRouter = class {
|
|
1670
|
+
var KeqRouter = class _KeqRouter {
|
|
1674
1671
|
constructor(middlewares = []) {
|
|
1675
1672
|
this.middlewares = middlewares;
|
|
1676
1673
|
}
|
|
1677
|
-
buildMiddleware(route, middlewares) {
|
|
1674
|
+
static buildMiddleware(route, middlewares) {
|
|
1678
1675
|
if (middlewares.length === 0) {
|
|
1679
1676
|
throw new TypeException("At least one middleware is required to build a route middleware");
|
|
1680
1677
|
}
|
|
@@ -1685,42 +1682,72 @@ var KeqRouter = class {
|
|
|
1685
1682
|
};
|
|
1686
1683
|
return middleware;
|
|
1687
1684
|
}
|
|
1688
|
-
route(route, ...
|
|
1689
|
-
const
|
|
1690
|
-
|
|
1691
|
-
this.middlewares.push(middleware);
|
|
1685
|
+
route(route, middleware, ...additionalMiddlewares) {
|
|
1686
|
+
const mid = _KeqRouter.route(route, middleware, ...additionalMiddlewares);
|
|
1687
|
+
this.middlewares.push(mid);
|
|
1692
1688
|
return this;
|
|
1693
1689
|
}
|
|
1694
|
-
host(host, ...
|
|
1695
|
-
const
|
|
1696
|
-
|
|
1697
|
-
this.middlewares.push(middleware);
|
|
1690
|
+
host(host, middleware, ...additionalMiddlewares) {
|
|
1691
|
+
const mid = _KeqRouter.host(host, middleware, ...additionalMiddlewares);
|
|
1692
|
+
this.middlewares.push(mid);
|
|
1698
1693
|
return this;
|
|
1699
1694
|
}
|
|
1700
|
-
method(method, ...
|
|
1701
|
-
const
|
|
1702
|
-
|
|
1703
|
-
this.middlewares.push(middleware);
|
|
1695
|
+
method(method, middleware, ...additionalMiddlewares) {
|
|
1696
|
+
const mid = _KeqRouter.method(method, middleware, ...additionalMiddlewares);
|
|
1697
|
+
this.middlewares.push(mid);
|
|
1704
1698
|
return this;
|
|
1705
1699
|
}
|
|
1706
|
-
pathname(pathname, ...
|
|
1707
|
-
const
|
|
1708
|
-
|
|
1709
|
-
this.middlewares.push(middleware);
|
|
1700
|
+
pathname(pathname, middleware, ...additionalMiddlewares) {
|
|
1701
|
+
const mid = _KeqRouter.pathname(pathname, middleware, ...additionalMiddlewares);
|
|
1702
|
+
this.middlewares.push(mid);
|
|
1710
1703
|
return this;
|
|
1711
1704
|
}
|
|
1712
|
-
location(...
|
|
1713
|
-
const
|
|
1714
|
-
|
|
1715
|
-
this.middlewares.push(middleware);
|
|
1705
|
+
location(middleware, ...additionalMiddlewares) {
|
|
1706
|
+
const mid = _KeqRouter.location(middleware, ...additionalMiddlewares);
|
|
1707
|
+
this.middlewares.push(mid);
|
|
1716
1708
|
return this;
|
|
1717
1709
|
}
|
|
1718
|
-
module(moduleName, ...
|
|
1719
|
-
const
|
|
1720
|
-
|
|
1721
|
-
this.middlewares.push(middleware);
|
|
1710
|
+
module(moduleName, middleware, ...additionalMiddlewares) {
|
|
1711
|
+
const mid = _KeqRouter.module(moduleName, middleware, ...additionalMiddlewares);
|
|
1712
|
+
this.middlewares.push(mid);
|
|
1722
1713
|
return this;
|
|
1723
1714
|
}
|
|
1715
|
+
static route(route, middleware, ...additionalMiddlewares) {
|
|
1716
|
+
const list = Array.isArray(middleware) ? middleware : [middleware, ...additionalMiddlewares];
|
|
1717
|
+
const mid = _KeqRouter.buildMiddleware(route, list);
|
|
1718
|
+
mid.__keqMiddlewareName__ = "route(".concat(route.__keqRouteName__ || route.name, ", ").concat(list.map(getMiddlewareName).join(", "), ")");
|
|
1719
|
+
return mid;
|
|
1720
|
+
}
|
|
1721
|
+
static host(host, middleware, ...additionalMiddlewares) {
|
|
1722
|
+
const list = Array.isArray(middleware) ? middleware : [middleware, ...additionalMiddlewares];
|
|
1723
|
+
const mid = _KeqRouter.buildMiddleware(keqHostRoute(host), list);
|
|
1724
|
+
mid.__keqMiddlewareName__ = "host(".concat(JSON.stringify(host), ", ").concat(list.map(getMiddlewareName).join(", "), ")");
|
|
1725
|
+
return mid;
|
|
1726
|
+
}
|
|
1727
|
+
static method(method, middleware, ...additionalMiddlewares) {
|
|
1728
|
+
const list = Array.isArray(middleware) ? middleware : [middleware, ...additionalMiddlewares];
|
|
1729
|
+
const mid = _KeqRouter.buildMiddleware(keqMethodRoute(method), list);
|
|
1730
|
+
mid.__keqMiddlewareName__ = "method(".concat(JSON.stringify(method), ", ").concat(list.map(getMiddlewareName).join(", "), ")");
|
|
1731
|
+
return mid;
|
|
1732
|
+
}
|
|
1733
|
+
static pathname(pathname, middleware, ...additionalMiddlewares) {
|
|
1734
|
+
const list = Array.isArray(middleware) ? middleware : [middleware, ...additionalMiddlewares];
|
|
1735
|
+
const mid = _KeqRouter.buildMiddleware(keqPathnameRoute(pathname), list);
|
|
1736
|
+
mid.__keqMiddlewareName__ = "pathname(".concat(JSON.stringify(pathname), ", ").concat(list.map(getMiddlewareName).join(", "), ")");
|
|
1737
|
+
return mid;
|
|
1738
|
+
}
|
|
1739
|
+
static location(middleware, ...additionalMiddlewares) {
|
|
1740
|
+
const list = Array.isArray(middleware) ? middleware : [middleware, ...additionalMiddlewares];
|
|
1741
|
+
const mid = _KeqRouter.buildMiddleware(keqLocationRoute(), list);
|
|
1742
|
+
mid.__keqMiddlewareName__ = "location(".concat(list.map(getMiddlewareName).join(", "), ")");
|
|
1743
|
+
return mid;
|
|
1744
|
+
}
|
|
1745
|
+
static module(moduleName, middleware, ...additionalMiddlewares) {
|
|
1746
|
+
const list = Array.isArray(middleware) ? middleware : [middleware, ...additionalMiddlewares];
|
|
1747
|
+
const mid = _KeqRouter.buildMiddleware(keqModuleRoute(moduleName), list);
|
|
1748
|
+
mid.__keqMiddlewareName__ = "module(".concat(JSON.stringify(moduleName), ", ").concat(list.map(getMiddlewareName).join(", "), ")");
|
|
1749
|
+
return mid;
|
|
1750
|
+
}
|
|
1724
1751
|
};
|
|
1725
1752
|
|
|
1726
1753
|
// src/middlewares/timeout-middleware/index.ts
|
|
@@ -1922,6 +1949,14 @@ var KeqRequest = class {
|
|
|
1922
1949
|
useRouter() {
|
|
1923
1950
|
return new KeqRouter(this.preMiddlewares);
|
|
1924
1951
|
}
|
|
1952
|
+
on(event, listener) {
|
|
1953
|
+
const middleware = async (context, next) => {
|
|
1954
|
+
context.emitter.on(event, listener);
|
|
1955
|
+
await next();
|
|
1956
|
+
};
|
|
1957
|
+
this.use(middleware);
|
|
1958
|
+
return this;
|
|
1959
|
+
}
|
|
1925
1960
|
};
|
|
1926
1961
|
var request = new KeqRequest();
|
|
1927
1962
|
|