@vercel/node 2.3.3 → 2.4.1
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/index.d.ts +33 -9
- package/dist/index.js +26 -9
- package/dist/utils.js +19 -1
- package/package.json +4 -4
- package/dist/babel.d.ts +0 -4
- package/dist/dev-server.d.ts +0 -8
- package/dist/types.d.ts +0 -33
- package/dist/typescript.d.ts +0 -43
- package/dist/utils.d.ts +0 -1
package/dist/index.d.ts
CHANGED
@@ -1,9 +1,33 @@
|
|
1
|
-
|
2
|
-
import
|
3
|
-
export
|
4
|
-
|
5
|
-
|
6
|
-
export declare
|
7
|
-
|
8
|
-
|
9
|
-
export declare
|
1
|
+
/// <reference types="node" />
|
2
|
+
import { ServerResponse, IncomingMessage } from 'http';
|
3
|
+
export declare type VercelRequestCookies = {
|
4
|
+
[key: string]: string;
|
5
|
+
};
|
6
|
+
export declare type VercelRequestQuery = {
|
7
|
+
[key: string]: string | string[];
|
8
|
+
};
|
9
|
+
export declare type VercelRequestBody = any;
|
10
|
+
export declare type VercelRequest = IncomingMessage & {
|
11
|
+
query: VercelRequestQuery;
|
12
|
+
cookies: VercelRequestCookies;
|
13
|
+
body: VercelRequestBody;
|
14
|
+
};
|
15
|
+
export declare type VercelResponse = ServerResponse & {
|
16
|
+
send: (body: any) => VercelResponse;
|
17
|
+
json: (jsonBody: any) => VercelResponse;
|
18
|
+
status: (statusCode: number) => VercelResponse;
|
19
|
+
redirect: (statusOrUrl: string | number, url?: string) => VercelResponse;
|
20
|
+
};
|
21
|
+
export declare type VercelApiHandler = (req: VercelRequest, res: VercelResponse) => void;
|
22
|
+
/** @deprecated Use VercelRequestCookies instead. */
|
23
|
+
export declare type NowRequestCookies = VercelRequestCookies;
|
24
|
+
/** @deprecated Use VercelRequestQuery instead. */
|
25
|
+
export declare type NowRequestQuery = VercelRequestQuery;
|
26
|
+
/** @deprecated Use VercelRequestBody instead. */
|
27
|
+
export declare type NowRequestBody = any;
|
28
|
+
/** @deprecated Use VercelRequest instead. */
|
29
|
+
export declare type NowRequest = VercelRequest;
|
30
|
+
/** @deprecated Use VercelResponse instead. */
|
31
|
+
export declare type NowResponse = VercelResponse;
|
32
|
+
/** @deprecated Use VercelApiHandler instead. */
|
33
|
+
export declare type NowApiHandler = VercelApiHandler;
|
package/dist/index.js
CHANGED
@@ -304511,6 +304511,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
304511
304511
|
};
|
304512
304512
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
304513
304513
|
exports.startDevServer = exports.prepareCache = exports.build = exports.version = exports.shouldServe = void 0;
|
304514
|
+
const url_1 = __importDefault(__webpack_require__(78835));
|
304514
304515
|
const child_process_1 = __webpack_require__(63129);
|
304515
304516
|
const fs_1 = __webpack_require__(35747);
|
304516
304517
|
const path_1 = __webpack_require__(85622);
|
@@ -304747,9 +304748,7 @@ const build = async ({ files, entrypoint, workPath, repoRootPath, config = {}, m
|
|
304747
304748
|
let routes;
|
304748
304749
|
let output;
|
304749
304750
|
const handler = renameTStoJS(path_1.relative(baseDir, entrypointPath));
|
304750
|
-
const
|
304751
|
-
? handler.substring(0, handler.length - 3)
|
304752
|
-
: handler;
|
304751
|
+
const outputPath = utils_1.entrypointToOutputPath(entrypoint, config.zeroConfig);
|
304753
304752
|
const isMiddleware = config.middleware === true;
|
304754
304753
|
// Will output an `EdgeFunction` for when `config.middleware = true`
|
304755
304754
|
// (i.e. for root-level "middleware" file) or if source code contains:
|
@@ -304774,9 +304773,7 @@ const build = async ({ files, entrypoint, workPath, repoRootPath, config = {}, m
|
|
304774
304773
|
routes = [
|
304775
304774
|
{
|
304776
304775
|
src,
|
304777
|
-
middlewarePath:
|
304778
|
-
? outputName
|
304779
|
-
: path_1.relative(baseDir, entrypointPath),
|
304776
|
+
middlewarePath: outputPath,
|
304780
304777
|
continue: true,
|
304781
304778
|
override: true,
|
304782
304779
|
},
|
@@ -304787,7 +304784,7 @@ const build = async ({ files, entrypoint, workPath, repoRootPath, config = {}, m
|
|
304787
304784
|
entrypoint: handler,
|
304788
304785
|
files: preparedFiles,
|
304789
304786
|
// TODO: remove - these two properties should not be required
|
304790
|
-
name:
|
304787
|
+
name: outputPath,
|
304791
304788
|
deploymentTarget: 'v8-worker',
|
304792
304789
|
});
|
304793
304790
|
}
|
@@ -304820,7 +304817,9 @@ const startDevServer = async (opts) => {
|
|
304820
304817
|
const staticConfig = static_config_1.getConfig(project, entrypointPath);
|
304821
304818
|
// Middleware is a catch-all for all paths unless a `matcher` property is defined
|
304822
304819
|
const matchers = new RegExp(utils_1.getRegExpFromMatchers(staticConfig?.matcher));
|
304823
|
-
|
304820
|
+
const parsed = url_1.default.parse(meta.requestUrl, true);
|
304821
|
+
if (typeof parsed.pathname !== 'string' ||
|
304822
|
+
!matchers.test(parsed.pathname)) {
|
304824
304823
|
// If the "matchers" doesn't say to handle this
|
304825
304824
|
// path then skip middleware invocation
|
304826
304825
|
return null;
|
@@ -305308,7 +305307,8 @@ function filterDiagnostics(diagnostics, ignore) {
|
|
305308
305307
|
"use strict";
|
305309
305308
|
|
305310
305309
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
305311
|
-
exports.getRegExpFromMatchers = void 0;
|
305310
|
+
exports.entrypointToOutputPath = exports.getRegExpFromMatchers = void 0;
|
305311
|
+
const path_1 = __webpack_require__(85622);
|
305312
305312
|
const path_to_regexp_1 = __webpack_require__(91786);
|
305313
305313
|
function getRegExpFromMatchers(matcherOrMatchers) {
|
305314
305314
|
if (!matcherOrMatchers) {
|
@@ -305330,6 +305330,23 @@ function getRegExpFromMatcher(matcher) {
|
|
305330
305330
|
const re = path_to_regexp_1.pathToRegexp(matcher);
|
305331
305331
|
return re.source;
|
305332
305332
|
}
|
305333
|
+
/**
|
305334
|
+
* If `zeroConfig`:
|
305335
|
+
* "api/foo.js" -> "api/foo.js"
|
305336
|
+
* "api/foo.ts" -> "api/foo.ts"
|
305337
|
+
*
|
305338
|
+
* If *NOT* `zeroConfig`:
|
305339
|
+
* "api/foo.js" -> "api/foo"
|
305340
|
+
* "api/foo.ts" -> "api/foo"
|
305341
|
+
*/
|
305342
|
+
function entrypointToOutputPath(entrypoint, zeroConfig) {
|
305343
|
+
if (zeroConfig) {
|
305344
|
+
const ext = path_1.extname(entrypoint);
|
305345
|
+
return entrypoint.slice(0, entrypoint.length - ext.length);
|
305346
|
+
}
|
305347
|
+
return entrypoint;
|
305348
|
+
}
|
305349
|
+
exports.entrypointToOutputPath = entrypointToOutputPath;
|
305333
305350
|
|
305334
305351
|
|
305335
305352
|
/***/ }),
|
package/dist/utils.js
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.getRegExpFromMatchers = void 0;
|
3
|
+
exports.entrypointToOutputPath = exports.getRegExpFromMatchers = void 0;
|
4
|
+
const path_1 = require("path");
|
4
5
|
const path_to_regexp_1 = require("path-to-regexp");
|
5
6
|
function getRegExpFromMatchers(matcherOrMatchers) {
|
6
7
|
if (!matcherOrMatchers) {
|
@@ -22,3 +23,20 @@ function getRegExpFromMatcher(matcher) {
|
|
22
23
|
const re = path_to_regexp_1.pathToRegexp(matcher);
|
23
24
|
return re.source;
|
24
25
|
}
|
26
|
+
/**
|
27
|
+
* If `zeroConfig`:
|
28
|
+
* "api/foo.js" -> "api/foo.js"
|
29
|
+
* "api/foo.ts" -> "api/foo.ts"
|
30
|
+
*
|
31
|
+
* If *NOT* `zeroConfig`:
|
32
|
+
* "api/foo.js" -> "api/foo"
|
33
|
+
* "api/foo.ts" -> "api/foo"
|
34
|
+
*/
|
35
|
+
function entrypointToOutputPath(entrypoint, zeroConfig) {
|
36
|
+
if (zeroConfig) {
|
37
|
+
const ext = path_1.extname(entrypoint);
|
38
|
+
return entrypoint.slice(0, entrypoint.length - ext.length);
|
39
|
+
}
|
40
|
+
return entrypoint;
|
41
|
+
}
|
42
|
+
exports.entrypointToOutputPath = entrypointToOutputPath;
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@vercel/node",
|
3
|
-
"version": "2.
|
3
|
+
"version": "2.4.1",
|
4
4
|
"license": "MIT",
|
5
5
|
"main": "./dist/index",
|
6
6
|
"homepage": "https://vercel.com/docs/runtimes#official-runtimes/node-js",
|
@@ -13,7 +13,7 @@
|
|
13
13
|
"build": "node build",
|
14
14
|
"test-integration-once": "yarn test test/integration.test.js",
|
15
15
|
"test": "jest --env node --verbose --bail --runInBand",
|
16
|
-
"test-unit": "yarn test test/prepare-cache.test.ts",
|
16
|
+
"test-unit": "yarn test test/prepare-cache.test.ts test/utils.test.ts",
|
17
17
|
"prepublishOnly": "node build"
|
18
18
|
},
|
19
19
|
"files": [
|
@@ -31,7 +31,7 @@
|
|
31
31
|
},
|
32
32
|
"dependencies": {
|
33
33
|
"@types/node": "*",
|
34
|
-
"@vercel/build-utils": "
|
34
|
+
"@vercel/build-utils": "5.0.1",
|
35
35
|
"@vercel/node-bridge": "3.0.0",
|
36
36
|
"@vercel/static-config": "2.0.1",
|
37
37
|
"edge-runtime": "1.0.1",
|
@@ -61,5 +61,5 @@
|
|
61
61
|
"source-map-support": "0.5.12",
|
62
62
|
"test-listen": "1.1.0"
|
63
63
|
},
|
64
|
-
"gitHead": "
|
64
|
+
"gitHead": "0a2af4fb94d71a7a23ffc72fb68748be1177f345"
|
65
65
|
}
|
package/dist/babel.d.ts
DELETED
package/dist/dev-server.d.ts
DELETED
@@ -1,8 +0,0 @@
|
|
1
|
-
/// <reference types="node" />
|
2
|
-
import { IncomingMessage, ServerResponse } from 'http';
|
3
|
-
import { Readable } from 'stream';
|
4
|
-
export declare function rawBody(readable: Readable): Promise<Buffer>;
|
5
|
-
export declare function onDevRequest(req: IncomingMessage, res: ServerResponse): Promise<void>;
|
6
|
-
export declare function fixConfigDev(config: {
|
7
|
-
compilerOptions: any;
|
8
|
-
}): void;
|
package/dist/types.d.ts
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
/// <reference types="node" />
|
2
|
-
import { ServerResponse, IncomingMessage } from 'http';
|
3
|
-
export declare type VercelRequestCookies = {
|
4
|
-
[key: string]: string;
|
5
|
-
};
|
6
|
-
export declare type VercelRequestQuery = {
|
7
|
-
[key: string]: string | string[];
|
8
|
-
};
|
9
|
-
export declare type VercelRequestBody = any;
|
10
|
-
export declare type VercelRequest = IncomingMessage & {
|
11
|
-
query: VercelRequestQuery;
|
12
|
-
cookies: VercelRequestCookies;
|
13
|
-
body: VercelRequestBody;
|
14
|
-
};
|
15
|
-
export declare type VercelResponse = ServerResponse & {
|
16
|
-
send: (body: any) => VercelResponse;
|
17
|
-
json: (jsonBody: any) => VercelResponse;
|
18
|
-
status: (statusCode: number) => VercelResponse;
|
19
|
-
redirect: (statusOrUrl: string | number, url?: string) => VercelResponse;
|
20
|
-
};
|
21
|
-
export declare type VercelApiHandler = (req: VercelRequest, res: VercelResponse) => void;
|
22
|
-
/** @deprecated Use VercelRequestCookies instead. */
|
23
|
-
export declare type NowRequestCookies = VercelRequestCookies;
|
24
|
-
/** @deprecated Use VercelRequestQuery instead. */
|
25
|
-
export declare type NowRequestQuery = VercelRequestQuery;
|
26
|
-
/** @deprecated Use VercelRequestBody instead. */
|
27
|
-
export declare type NowRequestBody = any;
|
28
|
-
/** @deprecated Use VercelRequest instead. */
|
29
|
-
export declare type NowRequest = VercelRequest;
|
30
|
-
/** @deprecated Use VercelResponse instead. */
|
31
|
-
export declare type NowResponse = VercelResponse;
|
32
|
-
/** @deprecated Use VercelApiHandler instead. */
|
33
|
-
export declare type NowApiHandler = VercelApiHandler;
|
package/dist/typescript.d.ts
DELETED
@@ -1,43 +0,0 @@
|
|
1
|
-
import _ts from 'typescript';
|
2
|
-
/**
|
3
|
-
* Registration options.
|
4
|
-
*/
|
5
|
-
interface Options {
|
6
|
-
basePath?: string;
|
7
|
-
pretty?: boolean | null;
|
8
|
-
logError?: boolean | null;
|
9
|
-
files?: boolean | null;
|
10
|
-
compiler?: string;
|
11
|
-
ignore?: string[];
|
12
|
-
project?: string;
|
13
|
-
compilerOptions?: _ts.CompilerOptions;
|
14
|
-
ignoreDiagnostics?: Array<number | string>;
|
15
|
-
readFile?: (path: string) => string | undefined;
|
16
|
-
fileExists?: (path: string) => boolean;
|
17
|
-
transformers?: _ts.CustomTransformers;
|
18
|
-
nodeVersionMajor?: number;
|
19
|
-
}
|
20
|
-
/**
|
21
|
-
* Return type for registering `ts-node`.
|
22
|
-
*/
|
23
|
-
export declare type Register = (code: string, fileName: string, skipTypeCheck?: boolean) => SourceOutput;
|
24
|
-
/**
|
25
|
-
* Register TypeScript compiler.
|
26
|
-
*/
|
27
|
-
export declare function register(opts?: Options): Register;
|
28
|
-
/**
|
29
|
-
* Do post-processing on config options to support `ts-node`.
|
30
|
-
*/
|
31
|
-
export declare function fixConfig(config: {
|
32
|
-
compilerOptions: any;
|
33
|
-
}, nodeVersionMajor?: number): {
|
34
|
-
compilerOptions: any;
|
35
|
-
};
|
36
|
-
/**
|
37
|
-
* Internal source output.
|
38
|
-
*/
|
39
|
-
declare type SourceOutput = {
|
40
|
-
code: string;
|
41
|
-
map: string;
|
42
|
-
};
|
43
|
-
export {};
|
package/dist/utils.d.ts
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
export declare function getRegExpFromMatchers(matcherOrMatchers: unknown): string;
|