Files
vercel/packages/node-bridge/types.ts
JJ Kasper 6b2a1c3866 [node-bridge][build-utils] Add multi payload lambda handling in node-bridge (#7507)
### Related Issues

x-ref: https://github.com/vercel/next.js/pull/34935

### 📋 Checklist

<!--
  Please keep your PR as a Draft until the checklist is complete
-->

#### Tests

- [ ] The code changed/added as part of this PR has been covered with tests
- [ ] All tests pass locally with `yarn test-unit`

#### Code Review

- [ ] This PR has a concise title and thorough description useful to a reviewer
- [ ] Issue from task tracker has a link to this PR
2022-03-06 08:57:45 +00:00

64 lines
1.5 KiB
TypeScript

/// <reference types="node" />
import {
Server,
IncomingHttpHeaders,
OutgoingHttpHeaders,
ServerResponse,
IncomingMessage,
} from 'http';
export interface VercelProxyEvent {
Action: string;
body: string;
}
export interface VercelProxyRequest {
isApiGateway?: boolean;
method: string;
path: string;
headers: IncomingHttpHeaders;
body: Buffer;
payloads?: Array<VercelProxyRequest>;
}
export interface VercelProxyResponse {
statusCode: number;
headers: OutgoingHttpHeaders;
body: string;
encoding: BufferEncoding;
}
export interface ServerLike {
timeout?: number;
listen: (
opts: {
host?: string;
port?: number;
},
callback: (this: Server | null) => void
) => Server | void;
}
export type LauncherConfiguration = {
entrypointPath: string;
bridgePath: string;
helpersPath: string;
sourcemapSupportPath: string;
shouldAddHelpers?: boolean;
shouldAddSourcemapSupport?: boolean;
awsLambdaHandler?: string;
useRequire?: boolean;
};
export type VercelRequestCookies = { [key: string]: string };
export type VercelRequestQuery = { [key: string]: string | string[] };
export type VercelRequestBody = any;
export type VercelRequest = IncomingMessage & {
query: VercelRequestQuery;
cookies: VercelRequestCookies;
body: VercelRequestBody;
};
export type VercelResponse = ServerResponse & {
send: (body: any) => VercelResponse;
json: (jsonBody: any) => VercelResponse;
status: (statusCode: number) => VercelResponse;
redirect: (statusOrUrl: string | number, url?: string) => VercelResponse;
};