Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@remix-run/node

Package Overview
Dependencies
Maintainers
2
Versions
1030
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@remix-run/node - npm Package Compare versions

Comparing version 1.0.6 to 1.1.0

formData.d.ts

2

base64.js
/**
* @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

/**
* @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";
/**
* @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.

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc