@remix-run/node
Advanced tools
Comparing version 0.0.0-experimental-f88eb375 to 0.0.0-experimental-fb9e523a
/** | ||
* @remix-run/node v0.0.0-experimental-f88eb375 | ||
* @remix-run/node v0.0.0-experimental-fb9e523a | ||
* | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
/** | ||
* @remix-run/node v0.0.0-experimental-f88eb375 | ||
* @remix-run/node v0.0.0-experimental-fb9e523a | ||
* | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
import type AbortController from "abort-controller"; | ||
import type { RequestInfo, RequestInit, Response } from "node-fetch"; | ||
import { Request as NodeRequest } 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"; | ||
interface RemixRequestInit extends RequestInit { | ||
interface NodeRequestInit extends RequestInit { | ||
abortController?: AbortController; | ||
} | ||
declare class RemixRequest extends NodeRequest { | ||
declare class NodeRequest extends BaseNodeRequest { | ||
private abortController?; | ||
constructor(input: RequestInfo, init?: RemixRequestInit | undefined); | ||
constructor(input: RequestInfo, init?: NodeRequestInit | undefined); | ||
formData(uploadHandler?: UploadHandler): Promise<FormData>; | ||
clone(): RemixRequest; | ||
clone(): NodeRequest; | ||
} | ||
export { RemixRequest as Request, RemixRequestInit as RequestInit }; | ||
export { NodeRequest as Request, NodeRequestInit as RequestInit }; | ||
/** | ||
@@ -18,0 +18,0 @@ * A `fetch` function for node that matches the web Fetch API. Based on |
/** | ||
* @remix-run/node v0.0.0-experimental-f88eb375 | ||
* @remix-run/node v0.0.0-experimental-fb9e523a | ||
* | ||
@@ -80,3 +80,3 @@ * Copyright (c) Remix Software Inc. | ||
class RemixRequest extends nodeFetch.Request { | ||
class NodeRequest extends nodeFetch.Request { | ||
constructor(input, init) { | ||
@@ -108,3 +108,3 @@ var _init; | ||
clone() { | ||
return new RemixRequest(super.clone()); | ||
return new NodeRequest(this); | ||
} | ||
@@ -149,3 +149,3 @@ | ||
}); | ||
exports.Request = RemixRequest; | ||
exports.Request = NodeRequest; | ||
exports.fetch = fetch; |
/** | ||
* @remix-run/node v0.0.0-experimental-f88eb375 | ||
* @remix-run/node v0.0.0-experimental-fb9e523a | ||
* | ||
@@ -53,3 +53,3 @@ * Copyright (c) Remix Software Inc. | ||
let arr = this._fields[name]; | ||
return arr && arr.slice(-1)[0] || null; | ||
return (arr === null || arr === void 0 ? void 0 : arr.slice(-1)[0]) ?? null; | ||
} | ||
@@ -56,0 +56,0 @@ |
/** | ||
* @remix-run/node v0.0.0-experimental-f88eb375 | ||
* @remix-run/node v0.0.0-experimental-fb9e523a | ||
* | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
export { AbortController } from "abort-controller"; | ||
export { formatServerError } from "./errors"; | ||
export type { HeadersInit, RequestInfo, RequestInit, ResponseInit } from "./fetch"; | ||
export type { HeadersInit, RequestInfo, RequestInit, ResponseInit, } from "./fetch"; | ||
export { Headers, Request, Response, fetch } from "./fetch"; | ||
export { FormData } from "./formData"; | ||
export type { UploadHandler, UploadHandlerArgs } from "./formData"; | ||
export { installGlobals } from "./globals"; | ||
export { parseMultipartFormData } from "./parseMultipartFormData"; | ||
export { parseMultipartFormData as unstable_parseMultipartFormData } from "./parseMultipartFormData"; | ||
export { createFileSessionStorage } from "./sessions/fileStorage"; | ||
export { createFileUploadHandler, NodeOnDiskFile } from "./upload/fileUploadHandler"; | ||
export { createMemoryUploadHandler } from "./upload/memoryUploadHandler"; | ||
export { createFileUploadHandler as unstable_createFileUploadHandler, NodeOnDiskFile, } from "./upload/fileUploadHandler"; | ||
export { createMemoryUploadHandler as unstable_createMemoryUploadHandler } from "./upload/memoryUploadHandler"; |
15
index.js
/** | ||
* @remix-run/node v0.0.0-experimental-f88eb375 | ||
* @remix-run/node v0.0.0-experimental-fb9e523a | ||
* | ||
@@ -15,4 +15,4 @@ * Copyright (c) Remix Software Inc. | ||
var sourceMapSupport = require('source-map-support'); | ||
var abortController = require('abort-controller'); | ||
var errors = require('./errors.js'); | ||
var fetch = require('./fetch.js'); | ||
@@ -27,4 +27,8 @@ var formData = require('./formData.js'); | ||
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } | ||
var sourceMapSupport__default = /*#__PURE__*/_interopDefaultLegacy(sourceMapSupport); | ||
sourceMapSupport__default["default"].install(); | ||
Object.defineProperty(exports, 'AbortController', { | ||
@@ -34,3 +38,2 @@ enumerable: true, | ||
}); | ||
exports.formatServerError = errors.formatServerError; | ||
exports.Request = fetch.Request; | ||
@@ -40,7 +43,7 @@ exports.fetch = fetch.fetch; | ||
exports.installGlobals = globals.installGlobals; | ||
exports.parseMultipartFormData = parseMultipartFormData.parseMultipartFormData; | ||
exports.unstable_parseMultipartFormData = parseMultipartFormData.parseMultipartFormData; | ||
exports.createFileSessionStorage = fileStorage.createFileSessionStorage; | ||
exports.NodeOnDiskFile = fileUploadHandler.NodeOnDiskFile; | ||
exports.createFileUploadHandler = fileUploadHandler.createFileUploadHandler; | ||
exports.createMemoryUploadHandler = memoryUploadHandler.createMemoryUploadHandler; | ||
exports.unstable_createFileUploadHandler = fileUploadHandler.createFileUploadHandler; | ||
exports.unstable_createMemoryUploadHandler = memoryUploadHandler.createMemoryUploadHandler; | ||
Object.defineProperty(exports, 'Headers', { | ||
@@ -47,0 +50,0 @@ enumerable: true, |
{ | ||
"name": "@remix-run/node", | ||
"description": "Node.js platform abstractions for Remix", | ||
"version": "0.0.0-experimental-f88eb375", | ||
"version": "0.0.0-experimental-fb9e523a", | ||
"license": "MIT", | ||
@@ -15,3 +15,3 @@ "repository": { | ||
"dependencies": { | ||
"@remix-run/server-runtime": "0.0.0-experimental-f88eb375", | ||
"@remix-run/server-runtime": "0.0.0-experimental-fb9e523a", | ||
"@types/busboy": "^0.3.1", | ||
@@ -26,9 +26,10 @@ "@types/node-fetch": "^2.5.12", | ||
"node-fetch": "^2.6.1", | ||
"source-map": "^0.7.3" | ||
"source-map-support": "^0.5.21" | ||
}, | ||
"devDependencies": { | ||
"@types/blob-stream": "^0.1.30", | ||
"@types/cookie-signature": "^1.0.3" | ||
"@types/cookie-signature": "^1.0.3", | ||
"@types/source-map-support": "^0.5.4" | ||
}, | ||
"sideEffects": false | ||
} |
/// <reference types="node" /> | ||
import type { Readable } from "stream"; | ||
import { Readable } from "stream"; | ||
import type { UploadHandler } from "./formData"; | ||
import { FormData as NodeFormData } from "./formData"; | ||
/** | ||
* Allows you to handle multipart forms (file uploads) for your app. | ||
* | ||
* @see https://remix.run/api/remix#parsemultipartformdata-node | ||
*/ | ||
export declare function parseMultipartFormData(request: Request, uploadHandler: UploadHandler): Promise<FormData>; | ||
export declare function internalParseFormData(contentType: string, stream: Readable, abortController?: AbortController, uploadHandler?: UploadHandler): Promise<NodeFormData>; | ||
export declare function internalParseFormData(contentType: string, body: string | Buffer | Readable, abortController?: AbortController, uploadHandler?: UploadHandler): Promise<NodeFormData>; |
/** | ||
* @remix-run/node v0.0.0-experimental-f88eb375 | ||
* @remix-run/node v0.0.0-experimental-fb9e523a | ||
* | ||
@@ -15,2 +15,3 @@ * Copyright (c) Remix Software Inc. | ||
var stream = require('stream'); | ||
var Busboy = require('busboy'); | ||
@@ -23,8 +24,22 @@ var formData = require('./formData.js'); | ||
/** | ||
* Allows you to handle multipart forms (file uploads) for your app. | ||
* | ||
* @see https://remix.run/api/remix#parsemultipartformdata-node | ||
*/ | ||
function parseMultipartFormData(request, uploadHandler) { | ||
return request.formData(uploadHandler); | ||
} | ||
async function internalParseFormData(contentType, stream, abortController, uploadHandler) { | ||
async function internalParseFormData(contentType, body, abortController, uploadHandler) { | ||
let formData$1 = new formData.FormData(); | ||
let fileWorkQueue = []; | ||
let stream$1; | ||
if (typeof body === "string" || Buffer.isBuffer(body)) { | ||
stream$1 = stream.Readable.from(body.toString()); | ||
} else { | ||
stream$1 = body; | ||
} | ||
await new Promise(async (resolve, reject) => { | ||
@@ -42,4 +57,4 @@ let busboy = new Busboy__default["default"]({ | ||
aborted = true; | ||
stream.unpipe(); | ||
stream.removeAllListeners(); | ||
stream$1.unpipe(); | ||
stream$1.removeAllListeners(); | ||
busboy.removeAllListeners(); | ||
@@ -87,7 +102,7 @@ abortController === null || abortController === void 0 ? void 0 : abortController.abort(); | ||
}); | ||
stream.on("error", abort); | ||
stream.on("aborted", abort); | ||
stream$1.on("error", abort); | ||
stream$1.on("aborted", abort); | ||
busboy.on("error", abort); | ||
busboy.on("finish", resolve); | ||
stream.pipe(busboy); | ||
stream$1.pipe(busboy); | ||
}); | ||
@@ -94,0 +109,0 @@ await Promise.all(fileWorkQueue); |
@@ -18,4 +18,6 @@ import type { SessionStorage, SessionIdStorageStrategy } from "@remix-run/server-runtime"; | ||
* files may contain much more data than cookies. | ||
* | ||
* @see https://remix.run/api/remix#createfilesessionstorage-node | ||
*/ | ||
export declare function createFileSessionStorage({ cookie, dir }: FileSessionStorageOptions): SessionStorage; | ||
export declare function createFileSessionStorage({ cookie, dir, }: FileSessionStorageOptions): SessionStorage; | ||
export {}; |
/** | ||
* @remix-run/node v0.0.0-experimental-f88eb375 | ||
* @remix-run/node v0.0.0-experimental-fb9e523a | ||
* | ||
@@ -46,2 +46,4 @@ * Copyright (c) Remix Software Inc. | ||
* files may contain much more data than cookies. | ||
* | ||
* @see https://remix.run/api/remix#createfilesessionstorage-node | ||
*/ | ||
@@ -48,0 +50,0 @@ function createFileSessionStorage({ |
@@ -46,3 +46,3 @@ /// <reference types="node" /> | ||
}; | ||
export declare function createFileUploadHandler({ directory, avoidFileConflicts, file, filter, maxFileSize }: FileUploadHandlerOptions): UploadHandler; | ||
export declare function createFileUploadHandler({ directory, avoidFileConflicts, file, filter, maxFileSize, }: FileUploadHandlerOptions): UploadHandler; | ||
export declare class NodeOnDiskFile implements File { | ||
@@ -49,0 +49,0 @@ private filepath; |
/** | ||
* @remix-run/node v0.0.0-experimental-f88eb375 | ||
* @remix-run/node v0.0.0-experimental-fb9e523a | ||
* | ||
@@ -17,3 +17,3 @@ * Copyright (c) Remix Software Inc. | ||
var fs = require('fs'); | ||
var fsp = require('fs/promises'); | ||
var promises = require('fs/promises'); | ||
var os = require('os'); | ||
@@ -34,3 +34,3 @@ var path = require('path'); | ||
for (let i = 1; await fsp.stat(uniqueFilepath).then(() => true).catch(() => false); i++) { | ||
for (let i = 1; await promises.stat(uniqueFilepath).then(() => true).catch(() => false); i++) { | ||
uniqueFilepath = (ext ? filepath.slice(0, -ext.length) : filepath) + `-${new Date().getTime()}${ext}`; | ||
@@ -94,3 +94,3 @@ } | ||
await fsp.mkdir(path.dirname(filepath), { | ||
await promises.mkdir(path.dirname(filepath), { | ||
recursive: true | ||
@@ -111,3 +111,3 @@ }).catch(() => {}); | ||
writeFileStream.removeAllListeners(); | ||
await fsp.rm(filepath, { | ||
await promises.rm(filepath, { | ||
force: true | ||
@@ -157,3 +157,3 @@ }).catch(() => {}); | ||
text() { | ||
return fsp.readFile(this.filepath, "utf-8"); | ||
return promises.readFile(this.filepath, "utf-8"); | ||
} | ||
@@ -160,0 +160,0 @@ |
@@ -21,2 +21,2 @@ import type { UploadHandler } from "../formData"; | ||
}; | ||
export declare function createMemoryUploadHandler({ filter, maxFileSize }: MemoryUploadHandlerOptions): UploadHandler; | ||
export declare function createMemoryUploadHandler({ filter, maxFileSize, }: MemoryUploadHandlerOptions): UploadHandler; |
/** | ||
* @remix-run/node v0.0.0-experimental-f88eb375 | ||
* @remix-run/node v0.0.0-experimental-fb9e523a | ||
* | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
/** | ||
* @remix-run/node v0.0.0-experimental-f88eb375 | ||
* @remix-run/node v0.0.0-experimental-fb9e523a | ||
* | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
3
37988
3
28
1053
+ Addedsource-map-support@^0.5.21
+ Added@remix-run/server-runtime@0.0.0-experimental-fb9e523a(transitive)
+ Addedbuffer-from@1.1.2(transitive)
+ Addedsource-map@0.6.1(transitive)
+ Addedsource-map-support@0.5.21(transitive)
- Removedsource-map@^0.7.3
- Removed@remix-run/server-runtime@0.0.0-experimental-f88eb375(transitive)
Updated@remix-run/server-runtime@0.0.0-experimental-fb9e523a