@vercel/node 2.12.0 → 2.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{dev-server.js → dev-server.mjs} +20 -28
- package/dist/edge-functions/{edge-handler.js → edge-handler.mjs} +29 -53
- package/dist/edge-functions/{edge-node-compat-plugin.js → edge-node-compat-plugin.mjs} +12 -20
- package/dist/edge-functions/{edge-wasm-plugin.js → edge-wasm-plugin.mjs} +7 -12
- package/dist/fork-dev-server.js +7 -13
- package/dist/index.d.ts +13 -12
- package/dist/index.js +115 -193
- package/dist/serverless-functions/helpers.js +1 -1
- package/dist/serverless-functions/serverless-handler.mjs +65 -0
- package/dist/typescript.js +4 -4
- package/dist/utils.js +5 -5
- package/package.json +8 -9
- package/dist/edge-functions/edge-handler.d.ts +0 -4
- package/dist/edge-functions/edge-node-compat-plugin.d.ts +0 -15
- package/dist/edge-functions/edge-wasm-plugin.d.ts +0 -21
- package/dist/fork-dev-server.d.ts +0 -34
- package/dist/serverless-functions/dynamic-import.js +0 -13
- package/dist/serverless-functions/helpers.d.ts +0 -22
- package/dist/serverless-functions/serverless-handler.d.ts +0 -10
- package/dist/serverless-functions/serverless-handler.js +0 -70
@@ -1,44 +1,37 @@
|
|
1
|
-
"use strict";
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
-
};
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
-
exports.onDevRequest = void 0;
|
7
1
|
const entrypoint = process.env.VERCEL_DEV_ENTRYPOINT;
|
8
2
|
delete process.env.VERCEL_DEV_ENTRYPOINT;
|
9
3
|
if (!entrypoint) {
|
10
4
|
throw new Error('`VERCEL_DEV_ENTRYPOINT` must be defined');
|
11
5
|
}
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
const
|
21
|
-
const parseConfig = (entryPointPath) =>
|
6
|
+
import { join } from 'path';
|
7
|
+
import { createEdgeEventHandler } from './edge-functions/edge-handler.mjs';
|
8
|
+
import { createServer } from 'http';
|
9
|
+
import { createServerlessEventHandler } from './serverless-functions/serverless-handler.mjs';
|
10
|
+
import { EdgeRuntimes, isEdgeRuntime, logError } from './utils.js';
|
11
|
+
import { getConfig } from '@vercel/static-config';
|
12
|
+
import { Project } from 'ts-morph';
|
13
|
+
import asyncListen from 'async-listen';
|
14
|
+
const { default: listen } = asyncListen;
|
15
|
+
const parseConfig = (entryPointPath) => getConfig(new Project(), entryPointPath);
|
22
16
|
function getRuntime(runtime, entrypoint) {
|
23
|
-
if (runtime && !
|
24
|
-
throw new Error(`Invalid function runtime "${runtime}" for "${entrypoint}". Valid runtimes are: ${JSON.stringify(Object.values(
|
17
|
+
if (runtime && !isEdgeRuntime(runtime)) {
|
18
|
+
throw new Error(`Invalid function runtime "${runtime}" for "${entrypoint}". Valid runtimes are: ${JSON.stringify(Object.values(EdgeRuntimes))}. Learn more: https://vercel.link/creating-edge-functions`);
|
25
19
|
}
|
26
20
|
return runtime;
|
27
21
|
}
|
28
22
|
async function createEventHandler(entrypoint, config, options) {
|
29
|
-
const entrypointPath =
|
23
|
+
const entrypointPath = join(process.cwd(), entrypoint);
|
30
24
|
const staticConfig = parseConfig(entrypointPath);
|
31
25
|
const runtime = getRuntime(staticConfig?.runtime, entrypoint);
|
32
26
|
// `middleware.js`/`middleware.ts` file is always run as
|
33
27
|
// an Edge Function, otherwise needs to be opted-in via
|
34
28
|
// `export const config = { runtime: 'edge' }`
|
35
|
-
if (config.middleware === true ||
|
36
|
-
return
|
29
|
+
if (config.middleware === true || isEdgeRuntime(runtime)) {
|
30
|
+
return createEdgeEventHandler(entrypointPath, entrypoint, config.middleware || false, config.zeroConfig);
|
37
31
|
}
|
38
|
-
return
|
32
|
+
return createServerlessEventHandler(entrypointPath, {
|
39
33
|
mode: staticConfig?.supportsResponseStreaming ? 'streaming' : 'buffer',
|
40
34
|
shouldAddHelpers: options.shouldAddHelpers,
|
41
|
-
useRequire,
|
42
35
|
});
|
43
36
|
}
|
44
37
|
let handleEvent;
|
@@ -49,15 +42,15 @@ async function main() {
|
|
49
42
|
const buildEnv = JSON.parse(process.env.VERCEL_DEV_BUILD_ENV || '{}');
|
50
43
|
delete process.env.VERCEL_DEV_BUILD_ENV;
|
51
44
|
const shouldAddHelpers = !(config.helpers === false || buildEnv.NODEJS_HELPERS === '0');
|
52
|
-
const proxyServer =
|
53
|
-
await
|
45
|
+
const proxyServer = createServer(onDevRequest);
|
46
|
+
await listen(proxyServer, { host: '127.0.0.1', port: 0 });
|
54
47
|
try {
|
55
48
|
handleEvent = await createEventHandler(entrypoint, config, {
|
56
49
|
shouldAddHelpers,
|
57
50
|
});
|
58
51
|
}
|
59
52
|
catch (error) {
|
60
|
-
|
53
|
+
logError(error);
|
61
54
|
handlerEventError = error;
|
62
55
|
}
|
63
56
|
const address = proxyServer.address();
|
@@ -100,8 +93,7 @@ async function onDevRequest(req, res) {
|
|
100
93
|
res.end(error.stack);
|
101
94
|
}
|
102
95
|
}
|
103
|
-
exports.onDevRequest = onDevRequest;
|
104
96
|
main().catch(err => {
|
105
|
-
|
97
|
+
logError(err);
|
106
98
|
process.exit(1);
|
107
99
|
});
|
@@ -1,49 +1,25 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
}) : function(o, v) {
|
12
|
-
o["default"] = v;
|
13
|
-
});
|
14
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
15
|
-
if (mod && mod.__esModule) return mod;
|
16
|
-
var result = {};
|
17
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
18
|
-
__setModuleDefault(result, mod);
|
19
|
-
return result;
|
20
|
-
};
|
21
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
22
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
23
|
-
};
|
24
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
25
|
-
exports.createEdgeEventHandler = void 0;
|
26
|
-
const edge_wasm_plugin_1 = require("./edge-wasm-plugin");
|
27
|
-
const edge_node_compat_plugin_1 = require("./edge-node-compat-plugin");
|
28
|
-
const edge_runtime_1 = require("edge-runtime");
|
29
|
-
const node_fetch_1 = __importStar(require("node-fetch"));
|
30
|
-
const error_utils_1 = require("@vercel/error-utils");
|
31
|
-
const fs_1 = require("fs");
|
32
|
-
const utils_1 = require("../utils");
|
33
|
-
const esbuild_1 = __importDefault(require("esbuild"));
|
34
|
-
const exit_hook_1 = __importDefault(require("exit-hook"));
|
35
|
-
const url_1 = require("url");
|
1
|
+
import { createEdgeWasmPlugin } from './edge-wasm-plugin.mjs';
|
2
|
+
import { createNodeCompatPlugin, } from './edge-node-compat-plugin.mjs';
|
3
|
+
import { EdgeRuntime, runServer } from 'edge-runtime';
|
4
|
+
import fetch, { Headers } from 'node-fetch';
|
5
|
+
import { isError } from '@vercel/error-utils';
|
6
|
+
import { readFileSync } from 'fs';
|
7
|
+
import { serializeBody, entrypointToOutputPath, logError } from '../utils.js';
|
8
|
+
import esbuild from 'esbuild';
|
9
|
+
import exitHook from 'exit-hook';
|
10
|
+
import { fileURLToPath } from 'url';
|
36
11
|
const NODE_VERSION_MAJOR = process.version.match(/^v(\d+)\.\d+/)?.[1];
|
37
12
|
const NODE_VERSION_IDENTIFIER = `node${NODE_VERSION_MAJOR}`;
|
38
13
|
if (!NODE_VERSION_MAJOR) {
|
39
14
|
throw new Error(`Unable to determine current node version: process.version=${process.version}`);
|
40
15
|
}
|
41
|
-
const
|
16
|
+
const __dirname = fileURLToPath(new URL('.', import.meta.url));
|
17
|
+
const edgeHandlerTemplate = readFileSync(`${__dirname}/edge-handler-template.js`);
|
42
18
|
async function compileUserCode(entrypointFullPath, entrypointRelativePath, isMiddleware) {
|
43
|
-
const { wasmAssets, plugin: edgeWasmPlugin } =
|
44
|
-
const nodeCompatPlugin =
|
19
|
+
const { wasmAssets, plugin: edgeWasmPlugin } = createEdgeWasmPlugin();
|
20
|
+
const nodeCompatPlugin = createNodeCompatPlugin();
|
45
21
|
try {
|
46
|
-
const result = await
|
22
|
+
const result = await esbuild.build({
|
47
23
|
// bundling behavior: use globals (like "browser") instead
|
48
24
|
// of "require" statements for core libraries (like "node")
|
49
25
|
platform: 'browser',
|
@@ -60,8 +36,8 @@ async function compileUserCode(entrypointFullPath, entrypointRelativePath, isMid
|
|
60
36
|
name: 'import.meta.url',
|
61
37
|
setup({ onLoad }) {
|
62
38
|
onLoad({ filter: /\.[cm]?js$/, namespace: 'file' }, args => {
|
63
|
-
let code =
|
64
|
-
code = code.replace(/\bimport\.meta\.url\b/g, JSON.stringify(
|
39
|
+
let code = readFileSync(args.path, 'utf8');
|
40
|
+
code = code.replace(/\bimport\.meta\.url\b/g, JSON.stringify(import.meta.url));
|
65
41
|
return { contents: code };
|
66
42
|
});
|
67
43
|
},
|
@@ -108,8 +84,8 @@ async function compileUserCode(entrypointFullPath, entrypointRelativePath, isMid
|
|
108
84
|
// We can't easily show a meaningful stack trace from ncc -> edge-runtime.
|
109
85
|
// So, stick with just the message for now.
|
110
86
|
console.error(`Failed to compile user code for edge runtime.`);
|
111
|
-
if (
|
112
|
-
|
87
|
+
if (isError(error))
|
88
|
+
logError(error);
|
113
89
|
return undefined;
|
114
90
|
}
|
115
91
|
}
|
@@ -120,7 +96,7 @@ async function createEdgeRuntimeServer(params) {
|
|
120
96
|
}
|
121
97
|
const wasmBindings = await params.wasmAssets.getContext();
|
122
98
|
const nodeCompatBindings = params.nodeCompatBindings.getContext();
|
123
|
-
const runtime = new
|
99
|
+
const runtime = new EdgeRuntime({
|
124
100
|
initialCode: params.userCode,
|
125
101
|
extend: context => {
|
126
102
|
Object.assign(context, {
|
@@ -140,19 +116,19 @@ async function createEdgeRuntimeServer(params) {
|
|
140
116
|
return context;
|
141
117
|
},
|
142
118
|
});
|
143
|
-
const server = await
|
144
|
-
|
119
|
+
const server = await runServer({ runtime });
|
120
|
+
exitHook(() => server.close());
|
145
121
|
return server;
|
146
122
|
}
|
147
123
|
catch (error) {
|
148
124
|
// We can't easily show a meaningful stack trace from ncc -> edge-runtime.
|
149
125
|
// So, stick with just the message for now.
|
150
126
|
console.error('Failed to instantiate edge runtime.');
|
151
|
-
|
127
|
+
logError(error);
|
152
128
|
return undefined;
|
153
129
|
}
|
154
130
|
}
|
155
|
-
async function createEdgeEventHandler(entrypointFullPath, entrypointRelativePath, isMiddleware, isZeroConfig) {
|
131
|
+
export async function createEdgeEventHandler(entrypointFullPath, entrypointRelativePath, isMiddleware, isZeroConfig) {
|
156
132
|
const userCode = await compileUserCode(entrypointFullPath, entrypointRelativePath, isMiddleware);
|
157
133
|
const server = await createEdgeRuntimeServer(userCode);
|
158
134
|
return async function (request) {
|
@@ -162,12 +138,13 @@ async function createEdgeEventHandler(entrypointFullPath, entrypointRelativePath
|
|
162
138
|
// an error is thrown in the function
|
163
139
|
process.exit(1);
|
164
140
|
}
|
165
|
-
const headers = new
|
166
|
-
const body = await
|
141
|
+
const headers = new Headers(request.headers);
|
142
|
+
const body = await serializeBody(request);
|
167
143
|
if (body !== undefined)
|
168
144
|
headers.set('content-length', String(body.length));
|
169
145
|
const url = new URL(request.url ?? '/', server.url);
|
170
|
-
|
146
|
+
// @ts-expect-error
|
147
|
+
const response = await fetch(url, {
|
171
148
|
body,
|
172
149
|
headers,
|
173
150
|
method: request.method,
|
@@ -193,9 +170,8 @@ async function createEdgeEventHandler(entrypointFullPath, entrypointRelativePath
|
|
193
170
|
};
|
194
171
|
};
|
195
172
|
}
|
196
|
-
exports.createEdgeEventHandler = createEdgeEventHandler;
|
197
173
|
function entrypointToRequestPath(entrypointRelativePath, isZeroConfig) {
|
198
174
|
// ensure the path starts with a slash to match conventions used elsewhere,
|
199
175
|
// notably when rendering serverless function paths in error messages
|
200
|
-
return '/' +
|
176
|
+
return '/' + entrypointToOutputPath(entrypointRelativePath, isZeroConfig);
|
201
177
|
}
|
@@ -1,14 +1,8 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
exports.createNodeCompatPlugin = exports.NodeCompatBindings = void 0;
|
7
|
-
const buffer_1 = __importDefault(require("buffer"));
|
8
|
-
const events_1 = __importDefault(require("events"));
|
9
|
-
const async_hooks_1 = __importDefault(require("async_hooks"));
|
10
|
-
const assert_1 = __importDefault(require("assert"));
|
11
|
-
const util_1 = __importDefault(require("util"));
|
1
|
+
import BufferImplementation from 'buffer';
|
2
|
+
import EventsImplementation from 'events';
|
3
|
+
import AsyncHooksImplementation from 'async_hooks';
|
4
|
+
import AssertImplementation from 'assert';
|
5
|
+
import UtilImplementation from 'util';
|
12
6
|
const SUPPORTED_NODE_MODULES = [
|
13
7
|
'buffer',
|
14
8
|
'events',
|
@@ -26,14 +20,14 @@ function pick(obj, keys) {
|
|
26
20
|
}
|
27
21
|
const NativeModuleMap = () => {
|
28
22
|
const mods = {
|
29
|
-
buffer: pick(
|
23
|
+
buffer: pick(BufferImplementation, [
|
30
24
|
'constants',
|
31
25
|
'kMaxLength',
|
32
26
|
'kStringMaxLength',
|
33
27
|
'Buffer',
|
34
28
|
'SlowBuffer',
|
35
29
|
]),
|
36
|
-
events: pick(
|
30
|
+
events: pick(EventsImplementation, [
|
37
31
|
'EventEmitter',
|
38
32
|
'captureRejectionSymbol',
|
39
33
|
'defaultMaxListeners',
|
@@ -42,11 +36,11 @@ const NativeModuleMap = () => {
|
|
42
36
|
'on',
|
43
37
|
'once',
|
44
38
|
]),
|
45
|
-
async_hooks: pick(
|
39
|
+
async_hooks: pick(AsyncHooksImplementation, [
|
46
40
|
'AsyncLocalStorage',
|
47
41
|
'AsyncResource',
|
48
42
|
]),
|
49
|
-
assert: pick(
|
43
|
+
assert: pick(AssertImplementation, [
|
50
44
|
'AssertionError',
|
51
45
|
'deepEqual',
|
52
46
|
'deepStrictEqual',
|
@@ -67,7 +61,7 @@ const NativeModuleMap = () => {
|
|
67
61
|
'strictEqual',
|
68
62
|
'throws',
|
69
63
|
]),
|
70
|
-
util: pick(
|
64
|
+
util: pick(UtilImplementation, [
|
71
65
|
'_extend',
|
72
66
|
'callbackify',
|
73
67
|
'format',
|
@@ -79,7 +73,7 @@ const NativeModuleMap = () => {
|
|
79
73
|
return new Map(Object.entries(mods));
|
80
74
|
};
|
81
75
|
const NODE_COMPAT_NAMESPACE = 'vercel-node-compat';
|
82
|
-
class NodeCompatBindings {
|
76
|
+
export class NodeCompatBindings {
|
83
77
|
constructor() {
|
84
78
|
this.bindings = new Map();
|
85
79
|
}
|
@@ -107,13 +101,12 @@ class NodeCompatBindings {
|
|
107
101
|
return context;
|
108
102
|
}
|
109
103
|
}
|
110
|
-
exports.NodeCompatBindings = NodeCompatBindings;
|
111
104
|
/**
|
112
105
|
* Allows to enable Node.js compatibility by detecting namespaced `node:`
|
113
106
|
* imports and producing metadata to bind global variables for each.
|
114
107
|
* It requires from the consumer to add the imports.
|
115
108
|
*/
|
116
|
-
function createNodeCompatPlugin() {
|
109
|
+
export function createNodeCompatPlugin() {
|
117
110
|
const bindings = new NodeCompatBindings();
|
118
111
|
const plugin = {
|
119
112
|
name: 'vc-node-compat',
|
@@ -145,4 +138,3 @@ function createNodeCompatPlugin() {
|
|
145
138
|
bindings,
|
146
139
|
};
|
147
140
|
}
|
148
|
-
exports.createNodeCompatPlugin = createNodeCompatPlugin;
|
@@ -1,11 +1,8 @@
|
|
1
|
-
"use strict";
|
2
1
|
// copied from `edge-functions-bridge`:
|
3
2
|
// https://github.com/vercel/runtimes/blob/c076db9e3ce5635f7c2690396e3d9f791a0fd808/packages/edge-functions-bridge/src/get-edge-function-source.ts#L282-L317
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
const fs_1 = require("fs");
|
8
|
-
class WasmAssets {
|
3
|
+
import { createHash } from 'crypto';
|
4
|
+
import { promises as fs } from 'fs';
|
5
|
+
export class WasmAssets {
|
9
6
|
constructor() {
|
10
7
|
this.assets = new Map();
|
11
8
|
}
|
@@ -13,7 +10,7 @@ class WasmAssets {
|
|
13
10
|
* Declare a WebAssembly binding
|
14
11
|
*/
|
15
12
|
async declare(filePath) {
|
16
|
-
const hash = sha1(await
|
13
|
+
const hash = sha1(await fs.readFile(filePath));
|
17
14
|
const name = `wasm_${hash}`;
|
18
15
|
this.assets.set(name, filePath);
|
19
16
|
return name;
|
@@ -27,7 +24,7 @@ class WasmAssets {
|
|
27
24
|
const context = {};
|
28
25
|
for (const [name, filePath] of this.assets) {
|
29
26
|
promises.push((async () => {
|
30
|
-
const bytes = await
|
27
|
+
const bytes = await fs.readFile(filePath);
|
31
28
|
context[name] = await WebAssembly.compile(bytes);
|
32
29
|
})());
|
33
30
|
}
|
@@ -41,8 +38,7 @@ class WasmAssets {
|
|
41
38
|
return this.assets[Symbol.iterator]();
|
42
39
|
}
|
43
40
|
}
|
44
|
-
|
45
|
-
function createEdgeWasmPlugin() {
|
41
|
+
export function createEdgeWasmPlugin() {
|
46
42
|
const wasmAssets = new WasmAssets();
|
47
43
|
const plugin = {
|
48
44
|
name: 'vercel-wasm',
|
@@ -76,7 +72,6 @@ function createEdgeWasmPlugin() {
|
|
76
72
|
};
|
77
73
|
return { plugin, wasmAssets };
|
78
74
|
}
|
79
|
-
exports.createEdgeWasmPlugin = createEdgeWasmPlugin;
|
80
75
|
function sha1(data) {
|
81
|
-
return
|
76
|
+
return createHash('sha1').update(data).digest('hex');
|
82
77
|
}
|
package/dist/fork-dev-server.js
CHANGED
@@ -12,17 +12,12 @@ const path_1 = require("path");
|
|
12
12
|
function forkDevServer(options) {
|
13
13
|
let nodeOptions = process.env.NODE_OPTIONS;
|
14
14
|
const tsNodePath = options.require_.resolve('ts-node');
|
15
|
-
const esmLoader = url_1.pathToFileURL(path_1.join(tsNodePath, '..', '..', 'esm.mjs'));
|
16
|
-
const cjsLoader = path_1.join(tsNodePath, '..', '..', 'register', 'index.js');
|
17
|
-
const devServerPath = options.devServerPath || path_1.join(__dirname, 'dev-server.
|
15
|
+
const esmLoader = (0, url_1.pathToFileURL)((0, path_1.join)(tsNodePath, '..', '..', 'esm.mjs'));
|
16
|
+
const cjsLoader = (0, path_1.join)(tsNodePath, '..', '..', 'register', 'index.js');
|
17
|
+
const devServerPath = options.devServerPath || (0, path_1.join)(__dirname, 'dev-server.mjs');
|
18
18
|
if (options.maybeTranspile) {
|
19
19
|
if (options.isTypeScript) {
|
20
|
-
|
21
|
-
nodeOptions = `--loader ${esmLoader} ${nodeOptions || ''}`;
|
22
|
-
}
|
23
|
-
else {
|
24
|
-
nodeOptions = `--require ${cjsLoader} ${nodeOptions || ''}`;
|
25
|
-
}
|
20
|
+
nodeOptions = `--loader ${esmLoader} ${nodeOptions || ''}`;
|
26
21
|
}
|
27
22
|
else {
|
28
23
|
if (options.isEsm) {
|
@@ -36,9 +31,8 @@ function forkDevServer(options) {
|
|
36
31
|
const forkOptions = {
|
37
32
|
cwd: options.workPath,
|
38
33
|
execArgv: [],
|
39
|
-
env: build_utils_1.cloneEnv(process.env, options.meta.env, {
|
34
|
+
env: (0, build_utils_1.cloneEnv)(process.env, options.meta.env, {
|
40
35
|
VERCEL_DEV_ENTRYPOINT: options.entrypoint,
|
41
|
-
VERCEL_DEV_IS_ESM: options.isEsm ? '1' : undefined,
|
42
36
|
VERCEL_DEV_CONFIG: JSON.stringify(options.config),
|
43
37
|
VERCEL_DEV_BUILD_ENV: JSON.stringify(options.meta.buildEnv || {}),
|
44
38
|
TS_NODE_TRANSPILE_ONLY: '1',
|
@@ -48,7 +42,7 @@ function forkDevServer(options) {
|
|
48
42
|
NODE_OPTIONS: nodeOptions,
|
49
43
|
}),
|
50
44
|
};
|
51
|
-
const child = child_process_1.fork(devServerPath, [], forkOptions);
|
45
|
+
const child = (0, child_process_1.fork)(devServerPath, [], forkOptions);
|
52
46
|
checkForPid(devServerPath, child);
|
53
47
|
return child;
|
54
48
|
}
|
@@ -64,7 +58,7 @@ function checkForPid(path, process) {
|
|
64
58
|
* or it is listening to new requests, and we can start proxying requests.
|
65
59
|
*/
|
66
60
|
async function readMessage(child) {
|
67
|
-
const onMessage = once_1.default(child, 'message');
|
61
|
+
const onMessage = (0, once_1.default)(child, 'message');
|
68
62
|
const onExit = once_1.default.spread(child, 'close');
|
69
63
|
const result = await Promise.race([
|
70
64
|
onMessage.then(x => {
|
package/dist/index.d.ts
CHANGED
@@ -1,37 +1,38 @@
|
|
1
1
|
/// <reference types="node" />
|
2
|
+
/// <reference types="node" />
|
2
3
|
import { ServerResponse, IncomingMessage } from 'http';
|
3
4
|
import type { Headers } from 'node-fetch';
|
4
|
-
export
|
5
|
+
export type VercelRequestCookies = {
|
5
6
|
[key: string]: string;
|
6
7
|
};
|
7
|
-
export
|
8
|
+
export type VercelRequestQuery = {
|
8
9
|
[key: string]: string | string[];
|
9
10
|
};
|
10
|
-
export
|
11
|
-
export
|
11
|
+
export type VercelRequestBody = any;
|
12
|
+
export type VercelRequest = IncomingMessage & {
|
12
13
|
query: VercelRequestQuery;
|
13
14
|
cookies: VercelRequestCookies;
|
14
15
|
body: VercelRequestBody;
|
15
16
|
};
|
16
|
-
export
|
17
|
+
export type VercelResponse = ServerResponse & {
|
17
18
|
send: (body: any) => VercelResponse;
|
18
19
|
json: (jsonBody: any) => VercelResponse;
|
19
20
|
status: (statusCode: number) => VercelResponse;
|
20
21
|
redirect: (statusOrUrl: string | number, url?: string) => VercelResponse;
|
21
22
|
};
|
22
|
-
export
|
23
|
+
export type VercelApiHandler = (req: VercelRequest, res: VercelResponse) => void | Promise<void>;
|
23
24
|
/** @deprecated Use VercelRequestCookies instead. */
|
24
|
-
export
|
25
|
+
export type NowRequestCookies = VercelRequestCookies;
|
25
26
|
/** @deprecated Use VercelRequestQuery instead. */
|
26
|
-
export
|
27
|
+
export type NowRequestQuery = VercelRequestQuery;
|
27
28
|
/** @deprecated Use VercelRequestBody instead. */
|
28
|
-
export
|
29
|
+
export type NowRequestBody = any;
|
29
30
|
/** @deprecated Use VercelRequest instead. */
|
30
|
-
export
|
31
|
+
export type NowRequest = VercelRequest;
|
31
32
|
/** @deprecated Use VercelResponse instead. */
|
32
|
-
export
|
33
|
+
export type NowResponse = VercelResponse;
|
33
34
|
/** @deprecated Use VercelApiHandler instead. */
|
34
|
-
export
|
35
|
+
export type NowApiHandler = VercelApiHandler;
|
35
36
|
export interface VercelProxyResponse {
|
36
37
|
status: number;
|
37
38
|
headers: Headers;
|