@bitblit/epsilon
Version:
Tiny adapter to simplify building API gateway Lambda APIS
18 lines (17 loc) • 1.19 kB
TypeScript
/// <reference types="node" />
import { APIGatewayEvent, ProxyResult } from 'aws-lambda';
import { RouterConfig } from './route/router-config';
export declare class ResponseUtil {
private constructor();
static errorResponse(errorMessages: string[], statusCode: number, reqId: string): ProxyResult;
static redirect(target: string, code?: number, queryParams?: any): ProxyResult;
static buildHttpError(errorMessage: string, statusCode: number): Error;
static errorToProxyResult(error: Error, reqId: string, defaultErrorMessage?: string): ProxyResult;
static coerceToProxyResult(input: any): ProxyResult;
static addCORSToProxyResult(input: ProxyResult, cfg: RouterConfig, srcEvent: APIGatewayEvent): ProxyResult;
static buildReflectCorsAllowOrigin(srcEvent: APIGatewayEvent, defaultValue?: string): string;
static buildReflectCorsAllowHeaders(srcEvent: APIGatewayEvent, defaultValue?: string): string;
static buildReflectCorsAllowMethods(srcEvent: APIGatewayEvent, defaultValue?: string): string;
static applyGzipIfPossible(encodingHeader: string, proxyResult: ProxyResult): Promise<ProxyResult>;
static gzip(input: Buffer): Promise<Buffer>;
}