@universal-middleware/express 0.4.12 → 0.4.13
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.d.ts +5 -3
- package/dist/index.js +12 -1
- package/package.json +5 -3
package/dist/index.d.ts
CHANGED
|
@@ -2,7 +2,8 @@ import { IncomingMessage, ServerResponse, OutgoingHttpHeaders } from 'node:http'
|
|
|
2
2
|
import { Socket } from 'node:net';
|
|
3
3
|
import { Get, UniversalHandler, UniversalFn, Awaitable, UniversalMiddleware, RuntimeAdapterTarget, UniversalRouter, UniversalRouterInterface, EnhancedMiddleware } from '@universal-middleware/core';
|
|
4
4
|
import { Readable } from 'node:stream';
|
|
5
|
-
import { Express } from 'express';
|
|
5
|
+
import { Express as Express$2 } from 'express';
|
|
6
|
+
import { Express as Express$1 } from 'express4';
|
|
6
7
|
|
|
7
8
|
/** Adapter options */
|
|
8
9
|
interface NodeRequestAdapterOptions {
|
|
@@ -79,6 +80,7 @@ declare function getContext<InContext extends Universal.Context = Universal.Cont
|
|
|
79
80
|
*/
|
|
80
81
|
declare function sendResponse(fetchResponse: Response, nodeResponse: DecoratedServerResponse): Promise<void>;
|
|
81
82
|
|
|
83
|
+
type Express = Express$1 | Express$2;
|
|
82
84
|
type ConnectMiddleware = (req: IncomingMessage, res: ServerResponse, next?: (err?: unknown) => void) => void | Promise<void>;
|
|
83
85
|
type ConnectMiddlewareBoolean = (req: IncomingMessage, res: ServerResponse, next?: (err?: unknown) => void) => boolean | Promise<boolean>;
|
|
84
86
|
type WebHandler<InContext extends Universal.Context = Universal.Context, Target = unknown> = (request: Request, context?: InContext, runtime?: RuntimeAdapterTarget<Target>) => Response | undefined | Promise<Response | undefined>;
|
|
@@ -111,9 +113,9 @@ declare function createServerResponse(incomingMessage: IncomingMessage): {
|
|
|
111
113
|
}) => void) => void;
|
|
112
114
|
};
|
|
113
115
|
|
|
114
|
-
declare class UniversalExpressRouter extends UniversalRouter implements UniversalRouterInterface {
|
|
116
|
+
declare class UniversalExpressRouter<T extends Express> extends UniversalRouter implements UniversalRouterInterface {
|
|
115
117
|
#private;
|
|
116
|
-
constructor(app:
|
|
118
|
+
constructor(app: T);
|
|
117
119
|
use(middleware: EnhancedMiddleware): this;
|
|
118
120
|
applyCatchAll(): this;
|
|
119
121
|
}
|
package/dist/index.js
CHANGED
|
@@ -514,6 +514,12 @@ function flattenHeaders(headers) {
|
|
|
514
514
|
}
|
|
515
515
|
return flatHeaders;
|
|
516
516
|
}
|
|
517
|
+
function isExpressV4(app) {
|
|
518
|
+
return "del" in app;
|
|
519
|
+
}
|
|
520
|
+
function isExpressV5(app) {
|
|
521
|
+
return !isExpressV4(app);
|
|
522
|
+
}
|
|
517
523
|
|
|
518
524
|
// src/router.ts
|
|
519
525
|
import {
|
|
@@ -533,7 +539,12 @@ var UniversalExpressRouter = class extends UniversalRouter {
|
|
|
533
539
|
return this;
|
|
534
540
|
}
|
|
535
541
|
applyCatchAll() {
|
|
536
|
-
|
|
542
|
+
if (isExpressV5(this.#app)) {
|
|
543
|
+
this.#app.all("/{*catchAll}", createHandler(() => this[universalSymbol2])());
|
|
544
|
+
}
|
|
545
|
+
if (isExpressV4(this.#app)) {
|
|
546
|
+
this.#app.all("/**", createHandler(() => this[universalSymbol2])());
|
|
547
|
+
}
|
|
537
548
|
return this;
|
|
538
549
|
}
|
|
539
550
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@universal-middleware/express",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.13",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Express adapter for universal middlewares",
|
|
6
6
|
"files": [
|
|
@@ -17,9 +17,11 @@
|
|
|
17
17
|
},
|
|
18
18
|
"devDependencies": {
|
|
19
19
|
"@swc/core": "^1.11.13",
|
|
20
|
-
"@types/express": "^
|
|
20
|
+
"@types/express": "^5.0.1",
|
|
21
|
+
"@types/express4": "npm:@types/express@^4",
|
|
21
22
|
"@types/node": "^20.17.19",
|
|
22
|
-
"
|
|
23
|
+
"express4": "npm:express@^4",
|
|
24
|
+
"express": "^5.1.0",
|
|
23
25
|
"helmet": "^8.1.0",
|
|
24
26
|
"rimraf": "^6.0.1",
|
|
25
27
|
"tsup": "^8.4.0",
|