@universal-middleware/express 0.0.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/LICENSE +7 -0
- package/dist/chunk-5VGN5WIU.js +69 -0
- package/dist/chunk-CDXJFGTO.js +6 -0
- package/dist/chunk-NPSKJAQI.js +70 -0
- package/dist/chunk-VWRNJC72.js +81 -0
- package/dist/fast-fetch.d.ts +2 -0
- package/dist/fast-fetch.js +19 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.js +19 -0
- package/dist/native-fetch.d.ts +44 -0
- package/dist/native-fetch.js +25 -0
- package/dist/request.d.ts +45 -0
- package/dist/request.js +6 -0
- package/dist/response.d.ts +8 -0
- package/dist/response.js +7 -0
- package/dist/whatwg-node.d.ts +16 -0
- package/dist/whatwg-node.js +19 -0
- package/package.json +47 -0
- package/readme.md +5 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
Copyright 2021 Fatih Aygün and contributors
|
|
2
|
+
|
|
3
|
+
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:
|
|
4
|
+
|
|
5
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
6
|
+
|
|
7
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createRequestAdapter
|
|
3
|
+
} from "./chunk-NPSKJAQI.js";
|
|
4
|
+
import {
|
|
5
|
+
sendResponse
|
|
6
|
+
} from "./chunk-VWRNJC72.js";
|
|
7
|
+
|
|
8
|
+
// src/common.ts
|
|
9
|
+
import {
|
|
10
|
+
createServer as createHttpServer
|
|
11
|
+
} from "node:http";
|
|
12
|
+
import process from "node:process";
|
|
13
|
+
function createMiddleware(handler, options = {}) {
|
|
14
|
+
const { alwaysCallNext = true, ...requestOptions } = options;
|
|
15
|
+
const requestAdapter = createRequestAdapter(requestOptions);
|
|
16
|
+
return async (req, res, next) => {
|
|
17
|
+
try {
|
|
18
|
+
const [request, ip] = requestAdapter(req);
|
|
19
|
+
let passThroughCalled = false;
|
|
20
|
+
const context = {
|
|
21
|
+
request,
|
|
22
|
+
ip,
|
|
23
|
+
env(variable) {
|
|
24
|
+
return process.env[variable];
|
|
25
|
+
},
|
|
26
|
+
waitUntil(promise) {
|
|
27
|
+
},
|
|
28
|
+
passThrough() {
|
|
29
|
+
passThroughCalled = true;
|
|
30
|
+
},
|
|
31
|
+
platform: {
|
|
32
|
+
name: "node",
|
|
33
|
+
request: req,
|
|
34
|
+
response: res
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
const response = await handler(context);
|
|
38
|
+
if (passThroughCalled && next) {
|
|
39
|
+
next();
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
await sendResponse(response, res);
|
|
43
|
+
if (next && alwaysCallNext) {
|
|
44
|
+
next();
|
|
45
|
+
}
|
|
46
|
+
} catch (error) {
|
|
47
|
+
if (next) {
|
|
48
|
+
next(error);
|
|
49
|
+
} else {
|
|
50
|
+
console.error(error);
|
|
51
|
+
if (!res.headersSent) {
|
|
52
|
+
res.statusCode = 500;
|
|
53
|
+
}
|
|
54
|
+
if (!res.writableEnded) {
|
|
55
|
+
res.end();
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
function createServer(handler, adapterOptions, serverOptions) {
|
|
62
|
+
const listener = createMiddleware(handler, adapterOptions);
|
|
63
|
+
return serverOptions ? createHttpServer(serverOptions, listener) : createHttpServer(listener);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export {
|
|
67
|
+
createMiddleware,
|
|
68
|
+
createServer
|
|
69
|
+
};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
// src/request.ts
|
|
2
|
+
import process from "node:process";
|
|
3
|
+
var deno = typeof Deno !== "undefined";
|
|
4
|
+
var bun = typeof Bun !== "undefined";
|
|
5
|
+
function createRequestAdapter(options = {}) {
|
|
6
|
+
const {
|
|
7
|
+
origin = process.env.ORIGIN,
|
|
8
|
+
trustProxy = process.env.TRUST_PROXY === "1"
|
|
9
|
+
} = options;
|
|
10
|
+
let { protocol: protocolOverride, host: hostOverride } = origin ? new URL(origin) : {};
|
|
11
|
+
if (protocolOverride) {
|
|
12
|
+
protocolOverride = protocolOverride.slice(0, -1);
|
|
13
|
+
}
|
|
14
|
+
let warned = false;
|
|
15
|
+
return function requestAdapter(req) {
|
|
16
|
+
function parseForwardedHeader(name) {
|
|
17
|
+
return (headers["x-forwarded-" + name] || "").split(",", 1)[0].trim();
|
|
18
|
+
}
|
|
19
|
+
let headers = req.headers;
|
|
20
|
+
if (headers[":method"]) {
|
|
21
|
+
headers = Object.fromEntries(
|
|
22
|
+
Object.entries(headers).filter(([key]) => !key.startsWith(":"))
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
const ip = req.ip || trustProxy && parseForwardedHeader("for") || req.socket?.remoteAddress || "";
|
|
26
|
+
if (req._request) {
|
|
27
|
+
return [req._request, ip];
|
|
28
|
+
}
|
|
29
|
+
const protocol = protocolOverride || req.protocol || trustProxy && parseForwardedHeader("proto") || req.socket?.encrypted && "https" || "http";
|
|
30
|
+
let host = hostOverride || trustProxy && parseForwardedHeader("host") || headers.host;
|
|
31
|
+
if (!host && !warned) {
|
|
32
|
+
console.warn(
|
|
33
|
+
"Could not automatically determine the origin host, using 'localhost'. Use the 'origin' option or the 'ORIGIN' environment variable to set the origin explicitly."
|
|
34
|
+
);
|
|
35
|
+
warned = true;
|
|
36
|
+
host = "localhost";
|
|
37
|
+
}
|
|
38
|
+
const request = new Request(protocol + "://" + host + req.url, {
|
|
39
|
+
method: req.method,
|
|
40
|
+
headers,
|
|
41
|
+
body: convertBody(req),
|
|
42
|
+
// @ts-ignore
|
|
43
|
+
duplex: "half"
|
|
44
|
+
});
|
|
45
|
+
req._request = request;
|
|
46
|
+
return [request, ip];
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
function convertBody(req) {
|
|
50
|
+
if (req.method === "GET" || req.method === "HEAD") {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
if (req.rawBody !== void 0) {
|
|
54
|
+
return req.rawBody;
|
|
55
|
+
}
|
|
56
|
+
if (!bun && !deno) {
|
|
57
|
+
return req;
|
|
58
|
+
}
|
|
59
|
+
return new ReadableStream({
|
|
60
|
+
start(controller) {
|
|
61
|
+
req.on("data", (chunk) => controller.enqueue(chunk));
|
|
62
|
+
req.on("end", () => controller.close());
|
|
63
|
+
req.on("error", (err) => controller.error(err));
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export {
|
|
69
|
+
createRequestAdapter
|
|
70
|
+
};
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import {
|
|
2
|
+
rawBodySymbol
|
|
3
|
+
} from "./chunk-CDXJFGTO.js";
|
|
4
|
+
|
|
5
|
+
// src/response.ts
|
|
6
|
+
import { Readable } from "node:stream";
|
|
7
|
+
var deno = typeof Deno !== "undefined";
|
|
8
|
+
if (deno) {
|
|
9
|
+
const oldSet = Headers.prototype.set;
|
|
10
|
+
Headers.prototype.set = function set(key, value) {
|
|
11
|
+
if (Array.isArray(value)) {
|
|
12
|
+
this.delete(key);
|
|
13
|
+
value.forEach((v) => this.append(key, v));
|
|
14
|
+
} else {
|
|
15
|
+
oldSet.call(this, key, value);
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
async function sendResponse(fetchResponse, nodeResponse) {
|
|
20
|
+
if (fetchResponse[rawBodySymbol]) {
|
|
21
|
+
writeHead(fetchResponse, nodeResponse);
|
|
22
|
+
nodeResponse.end(fetchResponse[rawBodySymbol]);
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
const { body: fetchBody } = fetchResponse;
|
|
26
|
+
let body = null;
|
|
27
|
+
if (!deno && fetchBody instanceof Readable) {
|
|
28
|
+
body = fetchBody;
|
|
29
|
+
} else if (fetchBody instanceof ReadableStream) {
|
|
30
|
+
if (!deno && Readable.fromWeb) {
|
|
31
|
+
body = Readable.fromWeb(fetchBody);
|
|
32
|
+
} else {
|
|
33
|
+
const reader = fetchBody.getReader();
|
|
34
|
+
body = new Readable({
|
|
35
|
+
async read() {
|
|
36
|
+
const { done, value } = await reader.read();
|
|
37
|
+
this.push(done ? null : value);
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
} else if (fetchBody) {
|
|
42
|
+
body = Readable.from(fetchBody);
|
|
43
|
+
}
|
|
44
|
+
writeHead(fetchResponse, nodeResponse);
|
|
45
|
+
if (body) {
|
|
46
|
+
body.pipe(nodeResponse);
|
|
47
|
+
await new Promise((resolve, reject) => {
|
|
48
|
+
body.on("error", reject);
|
|
49
|
+
nodeResponse.on("finish", resolve);
|
|
50
|
+
nodeResponse.on("error", reject);
|
|
51
|
+
});
|
|
52
|
+
} else {
|
|
53
|
+
nodeResponse.setHeader("content-length", "0");
|
|
54
|
+
nodeResponse.end();
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
function writeHead(fetchResponse, nodeResponse) {
|
|
58
|
+
nodeResponse.statusCode = fetchResponse.status;
|
|
59
|
+
if (fetchResponse.statusText) {
|
|
60
|
+
nodeResponse.statusMessage = fetchResponse.statusText;
|
|
61
|
+
}
|
|
62
|
+
const uniqueHeaderNames = new Set(fetchResponse.headers.keys());
|
|
63
|
+
for (const key of uniqueHeaderNames) {
|
|
64
|
+
if (key === "set-cookie") {
|
|
65
|
+
const setCookie = fetchResponse.headers.getSetCookie();
|
|
66
|
+
if (nodeResponse.appendHeader) {
|
|
67
|
+
for (const cookie of setCookie) {
|
|
68
|
+
nodeResponse.appendHeader("set-cookie", cookie);
|
|
69
|
+
}
|
|
70
|
+
} else {
|
|
71
|
+
nodeResponse.setHeader("set-cookie", setCookie);
|
|
72
|
+
}
|
|
73
|
+
} else {
|
|
74
|
+
nodeResponse.setHeader(key, fetchResponse.headers.get(key));
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export {
|
|
80
|
+
sendResponse
|
|
81
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import {
|
|
2
|
+
rawBodySymbol
|
|
3
|
+
} from "./chunk-CDXJFGTO.js";
|
|
4
|
+
|
|
5
|
+
// src/fast-fetch.ts
|
|
6
|
+
import { Readable } from "node:stream";
|
|
7
|
+
var OriginalResponse = global.Response;
|
|
8
|
+
var Response = class extends OriginalResponse {
|
|
9
|
+
[rawBodySymbol];
|
|
10
|
+
constructor(body, init) {
|
|
11
|
+
super(body, init);
|
|
12
|
+
if (typeof body === "string" || body instanceof Uint8Array || body instanceof ArrayBuffer || body instanceof Readable) {
|
|
13
|
+
this[rawBodySymbol] = body;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
Object.defineProperty(global, "Response", {
|
|
18
|
+
value: Response
|
|
19
|
+
});
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ServerResponse } from 'node:http';
|
|
2
|
+
import { DecoratedRequest } from './native-fetch.js';
|
|
3
|
+
export { NodeAdapterOptions, createMiddleware, createServer } from './native-fetch.js';
|
|
4
|
+
import '@hattip/core';
|
|
5
|
+
import 'node:net';
|
|
6
|
+
import './request.js';
|
|
7
|
+
import 'node:buffer';
|
|
8
|
+
|
|
9
|
+
/** Connect/Express style request listener/middleware */
|
|
10
|
+
type NodeMiddleware = (req: DecoratedRequest, res: ServerResponse, next?: () => void) => void;
|
|
11
|
+
interface NodePlatformInfo {
|
|
12
|
+
request: DecoratedRequest;
|
|
13
|
+
response: ServerResponse;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export { DecoratedRequest, type NodeMiddleware, type NodePlatformInfo };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createMiddleware,
|
|
3
|
+
createServer
|
|
4
|
+
} from "./chunk-5VGN5WIU.js";
|
|
5
|
+
import "./chunk-NPSKJAQI.js";
|
|
6
|
+
import "./chunk-VWRNJC72.js";
|
|
7
|
+
import "./chunk-CDXJFGTO.js";
|
|
8
|
+
|
|
9
|
+
// src/index.ts
|
|
10
|
+
import installNodeFetch from "@hattip/polyfills/node-fetch";
|
|
11
|
+
import installGetSetCookie from "@hattip/polyfills/get-set-cookie";
|
|
12
|
+
import installCrypto from "@hattip/polyfills/crypto";
|
|
13
|
+
installNodeFetch();
|
|
14
|
+
installGetSetCookie();
|
|
15
|
+
installCrypto();
|
|
16
|
+
export {
|
|
17
|
+
createMiddleware,
|
|
18
|
+
createServer
|
|
19
|
+
};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { HattipHandler } from '@hattip/core';
|
|
2
|
+
import { IncomingMessage, ServerResponse, ServerOptions, Server } from 'node:http';
|
|
3
|
+
import { Socket } from 'node:net';
|
|
4
|
+
import { NodeRequestAdapterOptions } from './request.js';
|
|
5
|
+
import 'node:buffer';
|
|
6
|
+
|
|
7
|
+
interface PossiblyEncryptedSocket extends Socket {
|
|
8
|
+
encrypted?: boolean;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* `IncomingMessage` possibly augmented by Express-specific
|
|
12
|
+
* `ip` and `protocol` properties.
|
|
13
|
+
*/
|
|
14
|
+
interface DecoratedRequest extends Omit<IncomingMessage, "socket"> {
|
|
15
|
+
ip?: string;
|
|
16
|
+
protocol?: string;
|
|
17
|
+
socket?: PossiblyEncryptedSocket;
|
|
18
|
+
}
|
|
19
|
+
/** Connect/Express style request listener/middleware */
|
|
20
|
+
type NodeMiddleware = (req: DecoratedRequest, res: ServerResponse, next?: (err?: unknown) => void) => void;
|
|
21
|
+
/** Adapter options */
|
|
22
|
+
interface NodeAdapterOptions extends NodeRequestAdapterOptions {
|
|
23
|
+
/**
|
|
24
|
+
* Whether to call the next middleware in the chain even if the request
|
|
25
|
+
* was handled.@default true
|
|
26
|
+
*/
|
|
27
|
+
alwaysCallNext?: boolean;
|
|
28
|
+
}
|
|
29
|
+
interface NodePlatformInfo {
|
|
30
|
+
name: "node";
|
|
31
|
+
request: DecoratedRequest;
|
|
32
|
+
response: ServerResponse;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Creates a request handler to be passed to http.createServer() or used as a
|
|
36
|
+
* middleware in Connect-style frameworks like Express.
|
|
37
|
+
*/
|
|
38
|
+
declare function createMiddleware(handler: HattipHandler<NodePlatformInfo>, options?: NodeAdapterOptions): NodeMiddleware;
|
|
39
|
+
/**
|
|
40
|
+
* Create an HTTP server
|
|
41
|
+
*/
|
|
42
|
+
declare function createServer(handler: HattipHandler<NodePlatformInfo>, adapterOptions?: NodeAdapterOptions, serverOptions?: ServerOptions): Server;
|
|
43
|
+
|
|
44
|
+
export { type DecoratedRequest, type NodeAdapterOptions, type NodeMiddleware, type NodePlatformInfo, createMiddleware, createServer };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createMiddleware,
|
|
3
|
+
createServer
|
|
4
|
+
} from "./chunk-5VGN5WIU.js";
|
|
5
|
+
import "./chunk-NPSKJAQI.js";
|
|
6
|
+
import "./chunk-VWRNJC72.js";
|
|
7
|
+
import "./chunk-CDXJFGTO.js";
|
|
8
|
+
|
|
9
|
+
// src/native-fetch.ts
|
|
10
|
+
import * as webStream from "node:stream/web";
|
|
11
|
+
import installGetSetCookie from "@hattip/polyfills/get-set-cookie";
|
|
12
|
+
import installCrypto from "@hattip/polyfills/crypto";
|
|
13
|
+
import installHalfDuplexRequest from "@hattip/polyfills/half-duplex-request";
|
|
14
|
+
installGetSetCookie();
|
|
15
|
+
installCrypto();
|
|
16
|
+
installHalfDuplexRequest();
|
|
17
|
+
for (const key of Object.keys(webStream)) {
|
|
18
|
+
if (!(key in globalThis)) {
|
|
19
|
+
globalThis[key] = webStream[key];
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
export {
|
|
23
|
+
createMiddleware,
|
|
24
|
+
createServer
|
|
25
|
+
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { IncomingMessage } from 'node:http';
|
|
2
|
+
import { Socket } from 'node:net';
|
|
3
|
+
import { Buffer } from 'node:buffer';
|
|
4
|
+
|
|
5
|
+
interface PossiblyEncryptedSocket extends Socket {
|
|
6
|
+
encrypted?: boolean;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* `IncomingMessage` possibly augmented with some environment-specific
|
|
10
|
+
* properties.
|
|
11
|
+
*/
|
|
12
|
+
interface DecoratedRequest extends Omit<IncomingMessage, "socket"> {
|
|
13
|
+
ip?: string;
|
|
14
|
+
protocol?: string;
|
|
15
|
+
socket?: PossiblyEncryptedSocket;
|
|
16
|
+
rawBody?: Buffer | null;
|
|
17
|
+
_request?: Request;
|
|
18
|
+
}
|
|
19
|
+
/** Adapter options */
|
|
20
|
+
interface NodeRequestAdapterOptions {
|
|
21
|
+
/**
|
|
22
|
+
* Set the origin part of the URL to a constant value.
|
|
23
|
+
* It defaults to `process.env.ORIGIN`. If neither is set,
|
|
24
|
+
* the origin is computed from the protocol and hostname.
|
|
25
|
+
* To determine the protocol, `req.protocol` is tried first.
|
|
26
|
+
* If `trustProxy` is set, `X-Forwarded-Proto` header is used.
|
|
27
|
+
* Otherwise, `req.socket.encrypted` is used.
|
|
28
|
+
* To determine the hostname, `X-Forwarded-Host`
|
|
29
|
+
* (if `trustProxy` is set) or `Host` header is used.
|
|
30
|
+
*/
|
|
31
|
+
origin?: string;
|
|
32
|
+
/**
|
|
33
|
+
* Whether to trust `X-Forwarded-*` headers. `X-Forwarded-Proto`
|
|
34
|
+
* and `X-Forwarded-Host` are used to determine the origin when
|
|
35
|
+
* `origin` and `process.env.ORIGIN` are not set. `X-Forwarded-For`
|
|
36
|
+
* is used to determine the IP address. The leftmost values are used
|
|
37
|
+
* if multiple values are set. Defaults to true if `process.env.TRUST_PROXY`
|
|
38
|
+
* is set to `1`, otherwise false.
|
|
39
|
+
*/
|
|
40
|
+
trustProxy?: boolean;
|
|
41
|
+
}
|
|
42
|
+
/** Create a function that converts a Node HTTP request into a fetch API `Request` object */
|
|
43
|
+
declare function createRequestAdapter(options?: NodeRequestAdapterOptions): (req: DecoratedRequest) => [request: Request, ip: string];
|
|
44
|
+
|
|
45
|
+
export { type DecoratedRequest, type NodeRequestAdapterOptions, createRequestAdapter };
|
package/dist/request.js
ADDED
package/dist/response.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ServerResponse } from 'node:http';
|
|
2
|
+
import { DecoratedRequest } from './native-fetch.js';
|
|
3
|
+
export { NodeAdapterOptions, createMiddleware, createServer } from './native-fetch.js';
|
|
4
|
+
import '@hattip/core';
|
|
5
|
+
import 'node:net';
|
|
6
|
+
import './request.js';
|
|
7
|
+
import 'node:buffer';
|
|
8
|
+
|
|
9
|
+
/** Connect/Express style request listener/middleware */
|
|
10
|
+
type NodeMiddleware = (req: DecoratedRequest, res: ServerResponse, next?: () => void) => void;
|
|
11
|
+
interface NodePlatformInfo {
|
|
12
|
+
request: DecoratedRequest;
|
|
13
|
+
response: ServerResponse;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export { DecoratedRequest, type NodeMiddleware, type NodePlatformInfo };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createMiddleware,
|
|
3
|
+
createServer
|
|
4
|
+
} from "./chunk-5VGN5WIU.js";
|
|
5
|
+
import "./chunk-NPSKJAQI.js";
|
|
6
|
+
import "./chunk-VWRNJC72.js";
|
|
7
|
+
import "./chunk-CDXJFGTO.js";
|
|
8
|
+
|
|
9
|
+
// src/whatwg-node.ts
|
|
10
|
+
import installWhatwgNodeFetch from "@hattip/polyfills/whatwg-node";
|
|
11
|
+
import installGetSetCookie from "@hattip/polyfills/get-set-cookie";
|
|
12
|
+
import installCrypto from "@hattip/polyfills/crypto";
|
|
13
|
+
installWhatwgNodeFetch();
|
|
14
|
+
installGetSetCookie();
|
|
15
|
+
installCrypto();
|
|
16
|
+
export {
|
|
17
|
+
createMiddleware,
|
|
18
|
+
createServer
|
|
19
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@universal-middleware/express",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "Express adapter for universal middlewares",
|
|
6
|
+
"files": [
|
|
7
|
+
"dist"
|
|
8
|
+
],
|
|
9
|
+
"exports": {
|
|
10
|
+
".": "./dist/index.js",
|
|
11
|
+
"./native-fetch": "./dist/native-fetch.js",
|
|
12
|
+
"./whatwg-node": "./dist/whatwg-node.js",
|
|
13
|
+
"./request": "./dist/request.js",
|
|
14
|
+
"./response": "./dist/response.js",
|
|
15
|
+
"./fast-fetch": "./dist/fast-fetch.js"
|
|
16
|
+
},
|
|
17
|
+
"typesVersions": {
|
|
18
|
+
"*": {
|
|
19
|
+
"*": [
|
|
20
|
+
"dist/*.d.ts"
|
|
21
|
+
]
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"author": "Joël Charles <joel.charles91@gmail.com>",
|
|
25
|
+
"contributors": [
|
|
26
|
+
"Fatih Aygün <cyco130@gmail.com>"
|
|
27
|
+
],
|
|
28
|
+
"repository": "https://github.com/hattipjs/hattip",
|
|
29
|
+
"license": "MIT",
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"@types/node": "^20.12.12",
|
|
32
|
+
"rimraf": "^5.0.7",
|
|
33
|
+
"tsup": "^8.0.2",
|
|
34
|
+
"typescript": "^5.4.5"
|
|
35
|
+
},
|
|
36
|
+
"dependencies": {
|
|
37
|
+
"@hattip/core": "^0.0.45",
|
|
38
|
+
"@hattip/polyfills": "^0.0.45",
|
|
39
|
+
"@hattip/walk": "^0.0.45"
|
|
40
|
+
},
|
|
41
|
+
"scripts": {
|
|
42
|
+
"build": "rimraf dist && tsup",
|
|
43
|
+
"dev": "tsup --watch",
|
|
44
|
+
"test": "pnpm test:typecheck",
|
|
45
|
+
"test:typecheck": "tsc -p tsconfig.json --noEmit"
|
|
46
|
+
}
|
|
47
|
+
}
|