UNPKG

serverless-aws-lambda

Version:

AWS Application Load Balancer and API Gateway - Lambda dev tool for Serverless. Allows Express synthax in handlers. Supports packaging, local invoking and offline ALB, APG, S3, SNS, SQS, DynamoDB Stream server mocking.

111 lines (110 loc) 3.47 kB
import type { RawResponseContent } from "./request"; import type { CookieOptions } from "./cookies"; export type RedirectOptions = [code: number, path: string]; type Stringifiable = [] | { [key: string]: any; } | null | boolean; export interface IResponse { locals: { [key: string]: any; }; callbackWaitsForEmptyEventLoop: boolean; succeed: (content: any) => void; fail: (error: any) => void; done: (error: any, content: any) => void; callback: (error: any, content: any) => void; functionVersion: string; functionName: string; memoryLimitInMB: string; logGroupName: string; logStreamName: string; clientContext: any; identity: any; invokedFunctionArn: string; awsRequestId: string; getRemainingTimeInMillis: Function; /** * set response status code. */ status: (code: number) => this; sendStatus: (code: number) => void; send: (content?: string | Buffer) => void; /** * equivalent to handler `return value`. Ignores all previous set values */ end: (rawContent: any) => void; /** * set response Content-Type. */ type(contentType: string): this; json: (content: Stringifiable) => void; set: (header: string | { [key: string]: string; }, value?: string) => this; setHeader: (header: string | { [key: string]: string; }, value?: string) => this; get: (headerKey: string) => string; getHeader: (headerKey: string) => string; redirect: (...redirectOptions: RedirectOptions) => void; location(url: string): this; links(links: any): this; cookie: (name: string, value: string, options?: CookieOptions) => this; /** * cookies set by res.cookie(); */ cookies: string[]; /** * headers set by res.set() / res.setHeader(); */ headers: string[]; clearCookie(name: string, options?: CookieOptions): this; } export declare class _Response implements IResponse { #private; locals: { [key: string]: any; }; callbackWaitsForEmptyEventLoop: boolean; functionVersion: string; functionName: string; memoryLimitInMB: string; logGroupName: string; logStreamName: string; clientContext: any; identity: any; invokedFunctionArn: string; awsRequestId: string; getRemainingTimeInMillis: () => number; callback: (error: any, content: RawResponseContent) => void; responseObject: any; constructor(init: { context: any; resolve: Function; locals: any; req: any; previousResponse?: any; callback: (error: any, content: RawResponseContent) => void; }); succeed(content: any): void; done(err: any, content: any): void; fail(error: any): void; cookie(name: string, value: string, options?: CookieOptions): this; clearCookie(name: string, options?: CookieOptions): this; status(code: number): this; sendStatus(code: number): void; type(contentType: string): this; set(...args: any): this; setHeader: (...args: any) => this; get(headerKey: string): any; getHeader: (headerKey: string) => any; json(content: Stringifiable): void; send(content?: string | Buffer): void; end(rawContent: any): void; redirect(...args: RedirectOptions): void; location(url: string): this; links(links: any): this; get cookies(): string[]; get headers(): string[]; } export {};