@remix-run/express
Advanced tools
Comparing version 0.0.0-experimental-935642c5 to 0.0.0-experimental-9aba8b51
/** | ||
* @remix-run/express v0.0.0-experimental-935642c5 | ||
* @remix-run/express v0.0.0-experimental-9aba8b51 | ||
* | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
/** | ||
* @remix-run/express v0.0.0-experimental-935642c5 | ||
* @remix-run/express v0.0.0-experimental-9aba8b51 | ||
* | ||
@@ -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-935642c5", | ||
"version": "0.0.0-experimental-9aba8b51", | ||
"license": "MIT", | ||
@@ -15,4 +15,3 @@ "repository": { | ||
"dependencies": { | ||
"@remix-run/node": "0.0.0-experimental-935642c5", | ||
"@remix-run/server-runtime": "0.0.0-experimental-935642c5" | ||
"@remix-run/node": "0.0.0-experimental-9aba8b51" | ||
}, | ||
@@ -19,0 +18,0 @@ "peerDependencies": { |
@@ -8,3 +8,3 @@ # Welcome to Remix! | ||
```sh | ||
$ npx create-remix@latest | ||
npx create-remix@latest | ||
``` | ||
@@ -11,0 +11,0 @@ |
import type * as express from "express"; | ||
import type { AppLoadContext, ServerBuild } from "@remix-run/server-runtime"; | ||
import type { AppLoadContext, ServerBuild, Response as NodeResponse } from "@remix-run/node"; | ||
import { AbortController, Headers as NodeHeaders, Request as NodeRequest } from "@remix-run/node"; | ||
@@ -12,15 +12,14 @@ /** | ||
*/ | ||
export interface GetLoadContextFunction { | ||
(req: express.Request, res: express.Response): AppLoadContext; | ||
} | ||
export declare type RequestHandler = ReturnType<typeof createRequestHandler>; | ||
export declare type GetLoadContextFunction = (req: express.Request, res: express.Response) => AppLoadContext; | ||
export declare type RequestHandler = (req: express.Request, res: express.Response, next: express.NextFunction) => Promise<void>; | ||
/** | ||
* Returns a request handler for Express that serves the response using Remix. | ||
*/ | ||
export declare function createRequestHandler({ build, getLoadContext, mode }: { | ||
export declare function createRequestHandler({ build, getLoadContext, mode, }: { | ||
build: ServerBuild; | ||
getLoadContext?: GetLoadContextFunction; | ||
mode?: string; | ||
}): (req: express.Request, res: express.Response, next: express.NextFunction) => Promise<void>; | ||
}): RequestHandler; | ||
export declare function createRemixHeaders(requestHeaders: express.Request["headers"]): NodeHeaders; | ||
export declare function createRemixRequest(req: express.Request, abortController?: AbortController): NodeRequest; | ||
export declare function sendRemixResponse(res: express.Response, nodeResponse: NodeResponse, abortController: AbortController): void; |
/** | ||
* @remix-run/express v0.0.0-experimental-935642c5 | ||
* @remix-run/express v0.0.0-experimental-9aba8b51 | ||
* | ||
@@ -16,3 +16,2 @@ * Copyright (c) Remix Software Inc. | ||
var stream = require('stream'); | ||
var serverRuntime = require('@remix-run/server-runtime'); | ||
var node = require('@remix-run/node'); | ||
@@ -37,6 +36,3 @@ | ||
}) { | ||
let platform = { | ||
formatServerError: node.formatServerError | ||
}; | ||
let handleRequest = serverRuntime.createRequestHandler(build, platform, mode); | ||
let handleRequest = node.createRequestHandler(build, mode); | ||
return async (req, res, next) => { | ||
@@ -62,3 +58,3 @@ try { | ||
if (Array.isArray(values)) { | ||
for (const value of values) { | ||
for (let value of values) { | ||
headers.append(key, value); | ||
@@ -92,10 +88,10 @@ } | ||
} | ||
function sendRemixResponse(res, nodeResponse, abortController) { | ||
var _nodeResponse$body; | ||
function sendRemixResponse(res, response, abortController) { | ||
var _response$body; | ||
res.statusMessage = nodeResponse.statusText; | ||
res.status(nodeResponse.status); | ||
res.status(response.status); | ||
for (let [key, values] of Object.entries(response.headers.raw())) { | ||
for (const value of values) { | ||
for (let [key, values] of Object.entries(nodeResponse.headers.raw())) { | ||
for (let value of values) { | ||
res.append(key, value); | ||
@@ -109,12 +105,7 @@ } | ||
res.flushHeaders(); | ||
if (Buffer.isBuffer(response.body)) { | ||
console.log("adapter", "buffer"); | ||
res.end(response.body); | ||
} else if ((_response$body = response.body) !== null && _response$body !== void 0 && _response$body.pipe) { | ||
console.log("adapter", "piping"); | ||
response.body.pipe(res); | ||
if (Buffer.isBuffer(nodeResponse.body)) { | ||
res.end(nodeResponse.body); | ||
} else if ((_nodeResponse$body = nodeResponse.body) !== null && _nodeResponse$body !== void 0 && _nodeResponse$body.pipe) { | ||
nodeResponse.body.pipe(res); | ||
} else { | ||
console.log("adapter", "end"); | ||
res.end(); | ||
@@ -127,1 +118,2 @@ } | ||
exports.createRequestHandler = createRequestHandler; | ||
exports.sendRemixResponse = sendRemixResponse; |
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
2
7715
156
+ Added@remix-run/node@0.0.0-experimental-9aba8b51(transitive)
+ Added@remix-run/server-runtime@0.0.0-experimental-9aba8b51(transitive)
+ Addedbuffer-from@1.1.2(transitive)
+ Addedsource-map@0.6.1(transitive)
+ Addedsource-map-support@0.5.21(transitive)
- Removed@remix-run/server-runtime@0.0.0-experimental-935642c5
- Removed@remix-run/node@0.0.0-experimental-935642c5(transitive)
- Removed@remix-run/server-runtime@0.0.0-experimental-935642c5(transitive)