@remix-run/node
Advanced tools
Comparing version 1.0.6 to 1.1.0
/** | ||
* @remix-run/node v1.0.6 | ||
* @remix-run/node v1.1.0 | ||
* | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
/** | ||
* @remix-run/node v1.0.6 | ||
* @remix-run/node v1.1.0 | ||
* | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
/** | ||
* @remix-run/node v1.0.6 | ||
* @remix-run/node v1.1.0 | ||
* | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
@@ -0,10 +1,17 @@ | ||
import type AbortController from "abort-controller"; | ||
import type { RequestInfo, RequestInit, Response } from "node-fetch"; | ||
import { Request as NodeRequest } from "node-fetch"; | ||
import { RemixFormData } from "./form-data"; | ||
export type { HeadersInit, RequestInfo, RequestInit, ResponseInit } from "node-fetch"; | ||
import { Request as BaseNodeRequest } from "node-fetch"; | ||
import type { UploadHandler } from "./formData"; | ||
export type { HeadersInit, RequestInfo, ResponseInit } from "node-fetch"; | ||
export { Headers, Response } from "node-fetch"; | ||
export declare class Request extends NodeRequest { | ||
constructor(input: RequestInfo, init?: RequestInit | undefined); | ||
formData(): Promise<RemixFormData>; | ||
interface NodeRequestInit extends RequestInit { | ||
abortController?: AbortController; | ||
} | ||
declare class NodeRequest extends BaseNodeRequest { | ||
private abortController?; | ||
constructor(input: RequestInfo, init?: NodeRequestInit | undefined); | ||
formData(uploadHandler?: UploadHandler): Promise<FormData>; | ||
clone(): NodeRequest; | ||
} | ||
export { NodeRequest as Request, NodeRequestInit as RequestInit }; | ||
/** | ||
@@ -11,0 +18,0 @@ * A `fetch` function for node that matches the web Fetch API. Based on |
112
fetch.js
/** | ||
* @remix-run/node v1.0.6 | ||
* @remix-run/node v1.1.0 | ||
* | ||
@@ -15,19 +15,97 @@ * Copyright (c) Remix Software Inc. | ||
var stream = require('stream'); | ||
var FormStream = require('form-data'); | ||
var nodeFetch = require('node-fetch'); | ||
var formData = require('./form-data.js'); | ||
var formData = require('./formData.js'); | ||
var parseMultipartFormData = require('./parseMultipartFormData.js'); | ||
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } | ||
var FormStream__default = /*#__PURE__*/_interopDefaultLegacy(FormStream); | ||
var nodeFetch__default = /*#__PURE__*/_interopDefaultLegacy(nodeFetch); | ||
class Request extends nodeFetch.Request { | ||
function formDataToStream(formData$1) { | ||
let formStream = new FormStream__default["default"](); | ||
function toNodeStream(input) { | ||
// The input is either a Node stream or a web stream, if it has | ||
// a `on` method it's a node stream so we can just return it | ||
if (typeof (input === null || input === void 0 ? void 0 : input.on) === "function") { | ||
return input; | ||
} | ||
let passthrough = new stream.PassThrough(); | ||
let stream$1 = input; | ||
let reader = stream$1.getReader(); | ||
reader.read().then(async ({ | ||
done, | ||
value | ||
}) => { | ||
while (!done) { | ||
passthrough.push(value); | ||
({ | ||
done, | ||
value | ||
} = await reader.read()); | ||
} | ||
passthrough.push(null); | ||
}).catch(error => { | ||
passthrough.emit("error", error); | ||
}); | ||
return passthrough; | ||
} | ||
for (let [key, value] of formData$1.entries()) { | ||
if (typeof value === "string") { | ||
formStream.append(key, value); | ||
} else if (formData.isFile(value)) { | ||
let stream = toNodeStream(value.stream()); | ||
formStream.append(key, stream, { | ||
filename: value.name, | ||
contentType: value.type, | ||
knownLength: value.size | ||
}); | ||
} else { | ||
let file = value; | ||
let stream = toNodeStream(file.stream()); | ||
formStream.append(key, stream, { | ||
filename: "unknown" | ||
}); | ||
} | ||
} | ||
return formStream; | ||
} | ||
class NodeRequest extends nodeFetch.Request { | ||
constructor(input, init) { | ||
var _init; | ||
if (((_init = init) === null || _init === void 0 ? void 0 : _init.body) instanceof formData.FormData) { | ||
init = { ...init, | ||
body: formDataToStream(init.body) | ||
}; | ||
} | ||
super(input, init); | ||
let anyInput = input; | ||
let anyInit = init; | ||
this.abortController = (anyInput === null || anyInput === void 0 ? void 0 : anyInput.abortController) || (anyInit === null || anyInit === void 0 ? void 0 : anyInit.abortController); | ||
} | ||
async formData() { | ||
let body = await this.clone().text(); | ||
return new formData.RemixFormData(body); | ||
async formData(uploadHandler) { | ||
let contentType = this.headers.get("Content-Type"); | ||
if (contentType) { | ||
return await parseMultipartFormData.internalParseFormData(contentType, this.body, this.abortController, uploadHandler); | ||
} | ||
throw new Error("Invalid MIME type"); | ||
} | ||
clone() { | ||
return new NodeRequest(this); | ||
} | ||
} | ||
@@ -43,9 +121,19 @@ /** | ||
function fetch(input, init) { | ||
// Default to { compress: false } so responses can be proxied through more | ||
var _init2; | ||
init = { | ||
compress: false, | ||
...init | ||
}; | ||
if (((_init2 = init) === null || _init2 === void 0 ? void 0 : _init2.body) instanceof formData.FormData) { | ||
init = { ...init, | ||
body: formDataToStream(init.body) | ||
}; | ||
} // Default to { compress: false } so responses can be proxied through more | ||
// easily in loaders. Otherwise the response stream encoding will not match | ||
// the Content-Encoding response header. | ||
return nodeFetch__default["default"](input, { | ||
compress: false, | ||
...init | ||
}); | ||
return nodeFetch__default["default"](input, init); | ||
} | ||
@@ -61,3 +149,3 @@ | ||
}); | ||
exports.Request = Request; | ||
exports.Request = NodeRequest; | ||
exports.fetch = fetch; |
@@ -5,5 +5,10 @@ import type { InternalSignFunctionDoNotUseMe, InternalUnsignFunctionDoNotUseMe } from "@remix-run/server-runtime/cookieSigning"; | ||
namespace NodeJS { | ||
interface ProcessEnv { | ||
NODE_ENV: "development" | "production" | "test"; | ||
} | ||
interface Global { | ||
atob: typeof atob; | ||
btoa: typeof btoa; | ||
Blob: typeof Blob; | ||
File: typeof File; | ||
Headers: typeof Headers; | ||
@@ -13,2 +18,3 @@ Request: typeof Request; | ||
fetch: typeof fetch; | ||
FormData: typeof FormData; | ||
sign: InternalSignFunctionDoNotUseMe; | ||
@@ -15,0 +21,0 @@ unsign: InternalUnsignFunctionDoNotUseMe; |
/** | ||
* @remix-run/node v1.0.6 | ||
* @remix-run/node v1.1.0 | ||
* | ||
@@ -15,5 +15,7 @@ * Copyright (c) Remix Software Inc. | ||
var file = require('@web-std/file'); | ||
var base64 = require('./base64.js'); | ||
var cookieSigning = require('./cookieSigning.js'); | ||
var fetch = require('./fetch.js'); | ||
var formData = require('./formData.js'); | ||
var nodeFetch = require('node-fetch'); | ||
@@ -24,2 +26,4 @@ | ||
global.btoa = base64.btoa; | ||
global.Blob = file.Blob; | ||
global.File = file.File; | ||
global.Headers = nodeFetch.Headers; | ||
@@ -29,2 +33,3 @@ global.Request = fetch.Request; | ||
global.fetch = fetch.fetch; | ||
global.FormData = formData.FormData; | ||
global.sign = cookieSigning.sign; | ||
@@ -31,0 +36,0 @@ global.unsign = cookieSigning.unsign; |
@@ -0,5 +1,10 @@ | ||
export { AbortController } from "abort-controller"; | ||
export { formatServerError } from "./errors"; | ||
export type { HeadersInit, RequestInfo, RequestInit, ResponseInit } from "./fetch"; | ||
export { Headers, Request, Response, fetch } from "./fetch"; | ||
export { FormData } from "./formData"; | ||
export { installGlobals } from "./globals"; | ||
export { parseMultipartFormData as unstable_parseMultipartFormData } from "./parseMultipartFormData"; | ||
export { createFileSessionStorage } from "./sessions/fileStorage"; | ||
export { createFileUploadHandler as unstable_createFileUploadHandler, NodeOnDiskFile } from "./upload/fileUploadHandler"; | ||
export { createMemoryUploadHandler as unstable_createMemoryUploadHandler } from "./upload/memoryUploadHandler"; |
16
index.js
/** | ||
* @remix-run/node v1.0.6 | ||
* @remix-run/node v1.1.0 | ||
* | ||
@@ -15,6 +15,11 @@ * Copyright (c) Remix Software Inc. | ||
var abortController = require('abort-controller'); | ||
var errors = require('./errors.js'); | ||
var fetch = require('./fetch.js'); | ||
var formData = require('./formData.js'); | ||
var globals = require('./globals.js'); | ||
var parseMultipartFormData = require('./parseMultipartFormData.js'); | ||
var fileStorage = require('./sessions/fileStorage.js'); | ||
var fileUploadHandler = require('./upload/fileUploadHandler.js'); | ||
var memoryUploadHandler = require('./upload/memoryUploadHandler.js'); | ||
var nodeFetch = require('node-fetch'); | ||
@@ -24,7 +29,16 @@ | ||
Object.defineProperty(exports, 'AbortController', { | ||
enumerable: true, | ||
get: function () { return abortController.AbortController; } | ||
}); | ||
exports.formatServerError = errors.formatServerError; | ||
exports.Request = fetch.Request; | ||
exports.fetch = fetch.fetch; | ||
exports.FormData = formData.FormData; | ||
exports.installGlobals = globals.installGlobals; | ||
exports.unstable_parseMultipartFormData = parseMultipartFormData.parseMultipartFormData; | ||
exports.createFileSessionStorage = fileStorage.createFileSessionStorage; | ||
exports.NodeOnDiskFile = fileUploadHandler.NodeOnDiskFile; | ||
exports.unstable_createFileUploadHandler = fileUploadHandler.createFileUploadHandler; | ||
exports.unstable_createMemoryUploadHandler = memoryUploadHandler.createMemoryUploadHandler; | ||
Object.defineProperty(exports, 'Headers', { | ||
@@ -31,0 +45,0 @@ enumerable: true, |
@@ -1,1 +0,1 @@ | ||
export { createFileSessionStorage } from "@remix-run/node"; | ||
export { createFileSessionStorage, unstable_createFileUploadHandler, unstable_createMemoryUploadHandler, unstable_parseMultipartFormData } from "@remix-run/node"; |
/** | ||
* @remix-run/node v1.0.6 | ||
* @remix-run/node v1.1.0 | ||
* | ||
@@ -20,4 +20,16 @@ * Copyright (c) Remix Software Inc. | ||
Object.defineProperty(exports, 'createFileSessionStorage', { | ||
enumerable: true, | ||
get: function () { return node.createFileSessionStorage; } | ||
enumerable: true, | ||
get: function () { return node.createFileSessionStorage; } | ||
}); | ||
Object.defineProperty(exports, 'unstable_createFileUploadHandler', { | ||
enumerable: true, | ||
get: function () { return node.unstable_createFileUploadHandler; } | ||
}); | ||
Object.defineProperty(exports, 'unstable_createMemoryUploadHandler', { | ||
enumerable: true, | ||
get: function () { return node.unstable_createMemoryUploadHandler; } | ||
}); | ||
Object.defineProperty(exports, 'unstable_parseMultipartFormData', { | ||
enumerable: true, | ||
get: function () { return node.unstable_parseMultipartFormData; } | ||
}); |
{ | ||
"name": "@remix-run/node", | ||
"description": "Node.js platform abstractions for Remix", | ||
"version": "1.0.6", | ||
"version": "1.1.0", | ||
"license": "MIT", | ||
"repository": { | ||
@@ -14,5 +15,11 @@ "type": "git", | ||
"dependencies": { | ||
"@remix-run/server-runtime": "1.0.6", | ||
"@remix-run/server-runtime": "1.1.0", | ||
"@types/busboy": "^0.3.1", | ||
"@types/node-fetch": "^2.5.12", | ||
"@web-std/file": "^3.0.0", | ||
"abort-controller": "^3.0.0", | ||
"blob-stream": "^0.1.3", | ||
"busboy": "^0.3.1", | ||
"cookie-signature": "^1.1.0", | ||
"form-data": "^4.0.0", | ||
"node-fetch": "^2.6.1", | ||
@@ -22,2 +29,3 @@ "source-map": "^0.7.3" | ||
"devDependencies": { | ||
"@types/blob-stream": "^0.1.30", | ||
"@types/cookie-signature": "^1.0.3" | ||
@@ -24,0 +32,0 @@ }, |
/** | ||
* @remix-run/node v1.0.6 | ||
* @remix-run/node v1.1.0 | ||
* | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
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
41456
30
1149
11
2
5
+ Added@types/busboy@^0.3.1
+ Added@web-std/file@^3.0.0
+ Addedabort-controller@^3.0.0
+ Addedblob-stream@^0.1.3
+ Addedbusboy@^0.3.1
+ Addedform-data@^4.0.0
+ Added@remix-run/server-runtime@1.1.0(transitive)
+ Added@types/busboy@0.3.5(transitive)
+ Added@types/node@22.10.0(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)
+ Addedcall-bind@1.0.7(transitive)
+ Addeddefine-data-property@1.1.4(transitive)
+ Addeddicer@0.3.0(transitive)
+ Addedes-define-property@1.0.0(transitive)
+ Addedes-errors@1.3.0(transitive)
+ Addedevent-target-shim@5.0.1(transitive)
+ Addedfor-each@0.3.3(transitive)
+ Addedfunction-bind@1.1.2(transitive)
+ Addedget-intrinsic@1.2.4(transitive)
+ Addedgopd@1.0.1(transitive)
+ Addedhas-property-descriptors@1.0.2(transitive)
+ Addedhas-proto@1.0.3(transitive)
+ Addedhas-symbols@1.0.3(transitive)
+ Addedhas-tostringtag@1.0.2(transitive)
+ Addedhasown@2.0.2(transitive)
+ Addedinherits@2.0.4(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)
+ Addedset-function-length@1.2.2(transitive)
+ Addedstreamsearch@0.1.2(transitive)
+ Addedundici-types@6.20.0(transitive)
+ Addedutil@0.12.5(transitive)
+ Addedweb-encoding@1.1.5(transitive)
+ Addedweb-streams-polyfill@3.3.3(transitive)
+ Addedwhich-typed-array@1.1.16(transitive)
- Removed@remix-run/server-runtime@1.0.6(transitive)
- Removed@types/node@22.9.3(transitive)
- Removedundici-types@6.19.8(transitive)