@vercel/node 1.12.1 → 1.12.2-canary.11

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.
@@ -0,0 +1,4 @@
1
+ export declare function compile(filename: string, source: string): {
2
+ code: string;
3
+ map: any;
4
+ };
package/dist/bridge.js CHANGED
@@ -155,7 +155,8 @@ class Bridge {
155
155
  const { port } = await this.listening;
156
156
 
157
157
  const normalizedEvent = normalizeEvent(event);
158
- const { isApiGateway, method, path, headers, body } = normalizedEvent;
158
+ const { isApiGateway, method, headers, body } = normalizedEvent;
159
+ let { path } = normalizedEvent;
159
160
 
160
161
  if (this.shouldStoreEvents) {
161
162
  const reqId = `${this.reqIdSeed++}`;
@@ -165,6 +166,12 @@ class Bridge {
165
166
 
166
167
  // eslint-disable-next-line consistent-return
167
168
  return new Promise((resolve, reject) => {
169
+ // if the path is improperly encoded we need to encode it or
170
+ // http.request will throw an error (related check: https://github.com/nodejs/node/blob/4ece669c6205ec78abfdadfe78869bbb8411463e/lib/_http_client.js#L84)
171
+ if (path && /[^\u0021-\u00ff]/.test(path)) {
172
+ path = encodeURI(path);
173
+ }
174
+
168
175
  const opts = { hostname: '127.0.0.1', port, path, method };
169
176
  const req = request(opts, res => {
170
177
  const response = res;
@@ -0,0 +1,5 @@
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>;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,10 @@
1
+ /// <reference types="node" />
2
+ import { VercelRequest, VercelResponse } from './types';
3
+ import { Server } from 'http';
4
+ import type { Bridge } from '@vercel/node-bridge/bridge';
5
+ export declare class ApiError extends Error {
6
+ readonly statusCode: number;
7
+ constructor(statusCode: number, message: string);
8
+ }
9
+ export declare function sendError(res: VercelResponse, statusCode: number, message: string): void;
10
+ export declare function createServerWithHelpers(handler: (req: VercelRequest, res: VercelResponse) => void | Promise<void>, bridge: Bridge): Server;
package/dist/index.d.ts CHANGED
@@ -1,33 +1,10 @@
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 `any` 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;
1
+ import { Files, PrepareCacheOptions, BuildOptions, StartDevServerOptions, StartDevServerResult, shouldServe } from '@vercel/build-utils';
2
+ export { shouldServe };
3
+ export { NowRequest, NowResponse, VercelRequest, VercelResponse, } from './types';
4
+ export * from './types';
5
+ export declare const version = 3;
6
+ export declare function build({ files, entrypoint, workPath, repoRootPath, config, meta, }: BuildOptions): Promise<{
7
+ output: import("@vercel/build-utils").Lambda;
8
+ }>;
9
+ export declare function prepareCache({ workPath, }: PrepareCacheOptions): Promise<Files>;
10
+ export declare function startDevServer(opts: StartDevServerOptions): Promise<StartDevServerResult>;