@remix-run/express
Advanced tools
Comparing version 0.0.0-experimental-ab9dac4f to 0.0.0-experimental-b33ac4ef
/** | ||
* @remix-run/express v0.0.0-experimental-ab9dac4f | ||
* @remix-run/express v0.0.0-experimental-b33ac4ef | ||
* | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
/** | ||
* @remix-run/express v0.0.0-experimental-ab9dac4f | ||
* @remix-run/express v0.0.0-experimental-b33ac4ef | ||
* | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
{ | ||
"name": "@remix-run/express", | ||
"description": "Express server request handler for Remix", | ||
"version": "0.0.0-experimental-ab9dac4f", | ||
"version": "0.0.0-experimental-b33ac4ef", | ||
"license": "MIT", | ||
@@ -15,3 +15,4 @@ "repository": { | ||
"dependencies": { | ||
"@remix-run/node": "0.0.0-experimental-ab9dac4f" | ||
"@remix-run/node": "0.0.0-experimental-b33ac4ef", | ||
"@remix-run/server-runtime": "0.0.0-experimental-b33ac4ef" | ||
}, | ||
@@ -18,0 +19,0 @@ "peerDependencies": { |
import type * as express from "express"; | ||
import type { AppLoadContext, ServerBuild } from "@remix-run/server-runtime"; | ||
import { Headers as NodeHeaders, Request as NodeRequest } from "@remix-run/node"; | ||
import { AbortController, Headers as NodeHeaders, Request as NodeRequest } from "@remix-run/node"; | ||
/** | ||
@@ -25,2 +25,2 @@ * A function that returns the value to use as `context` in route `loader` and | ||
export declare function createRemixHeaders(requestHeaders: express.Request["headers"]): NodeHeaders; | ||
export declare function createRemixRequest(req: express.Request): NodeRequest; | ||
export declare function createRemixRequest(req: express.Request, abortController?: AbortController): NodeRequest; |
/** | ||
* @remix-run/express v0.0.0-experimental-ab9dac4f | ||
* @remix-run/express v0.0.0-experimental-b33ac4ef | ||
* | ||
@@ -42,6 +42,7 @@ * Copyright (c) Remix Software Inc. | ||
try { | ||
let request = createRemixRequest(req); | ||
let abortController = new node.AbortController(); | ||
let request = createRemixRequest(req, abortController); | ||
let loadContext = typeof getLoadContext === "function" ? getLoadContext(req, res) : undefined; | ||
let response = await handleRequest(request, loadContext); | ||
sendRemixResponse(res, response); | ||
sendRemixResponse(res, response, abortController); | ||
} catch (error) { | ||
@@ -71,3 +72,3 @@ // Express doesn't support async functions, so we have to pass along the | ||
} | ||
function createRemixRequest(req) { | ||
function createRemixRequest(req, abortController) { | ||
let origin = `${req.protocol}://${req.get("host")}`; | ||
@@ -77,3 +78,5 @@ let url = new URL(req.url, origin); | ||
method: req.method, | ||
headers: createRemixHeaders(req.headers) | ||
headers: createRemixHeaders(req.headers), | ||
signal: abortController === null || abortController === void 0 ? void 0 : abortController.signal, | ||
abortController | ||
}; | ||
@@ -87,6 +90,6 @@ | ||
return new node.Request(url.toString(), init); | ||
return new node.Request(url.href, init); | ||
} | ||
function sendRemixResponse(res, response) { | ||
function sendRemixResponse(res, response, abortController) { | ||
var _response$body; | ||
@@ -102,2 +105,6 @@ | ||
if (abortController.signal.aborted) { | ||
res.set("Connection", "close"); | ||
} | ||
if (Buffer.isBuffer(response.body)) { | ||
@@ -104,0 +111,0 @@ res.end(response.body); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
7670
159
3
+ Added@remix-run/server-runtime@0.0.0-experimental-b33ac4ef
+ Added@remix-run/node@0.0.0-experimental-b33ac4ef(transitive)
+ Added@remix-run/server-runtime@0.0.0-experimental-b33ac4ef(transitive)
+ Added@types/busboy@0.3.5(transitive)
+ Added@types/node@22.9.4(transitive)
+ Added@web-std/blob@3.0.5(transitive)
+ Added@web-std/file@3.0.3(transitive)
+ Added@web-std/stream@1.0.0(transitive)
+ Added@zxing/text-encoding@0.9.0(transitive)
+ Addedabort-controller@3.0.0(transitive)
+ Addedavailable-typed-arrays@1.0.7(transitive)
+ Addedblob@0.0.4(transitive)
+ Addedblob-stream@0.1.3(transitive)
+ Addedbusboy@0.3.1(transitive)
+ Addeddicer@0.3.0(transitive)
+ Addedevent-target-shim@5.0.1(transitive)
+ Addedfor-each@0.3.3(transitive)
+ Addedhas-tostringtag@1.0.2(transitive)
+ Addedis-arguments@1.1.1(transitive)
+ Addedis-callable@1.2.7(transitive)
+ Addedis-generator-function@1.0.10(transitive)
+ Addedis-typed-array@1.1.13(transitive)
+ Addedpossible-typed-array-names@1.0.0(transitive)
+ Addedstreamsearch@0.1.2(transitive)
+ Addedutil@0.12.5(transitive)
+ Addedweb-encoding@1.1.5(transitive)
+ Addedweb-streams-polyfill@3.3.3(transitive)
+ Addedwhich-typed-array@1.1.15(transitive)
- Removed@remix-run/node@0.0.0-experimental-ab9dac4f(transitive)
- Removed@remix-run/server-runtime@0.0.0-experimental-ab9dac4f(transitive)
- Removed@types/node@22.9.3(transitive)