@swarmion/serverless-contracts
Version:
Generate and use type-safe contracts between your Serverless services.
27 lines • 2.5 kB
TypeScript
import Ajv from 'ajv';
import { GenericApiGatewayContract } from '../apiGatewayContract';
import { ApiGatewayHandler, BodyType, CustomRequestContextType, HeadersType, InternalSwarmionApiGatewayHandler, OutputType, PathParametersType, QueryStringParametersType } from '../types';
import { ApiGatewayAuthorizerType, ApiGatewayIntegrationType } from '../types/constants';
export type GetApiGatewayHandlerOptions = {
ajv: Ajv;
validateInput?: boolean;
validateOutput?: boolean;
returnValidationErrors?: boolean;
} | {
ajv?: Ajv;
validateInput: false;
validateOutput: false;
returnValidationErrors: false;
};
export declare const getApiGatewayHandler: <Contract extends GenericApiGatewayContract, IntegrationType extends ApiGatewayIntegrationType = Contract["integrationType"], AuthorizerType extends ApiGatewayAuthorizerType = Contract["authorizerType"], PathParameters = PathParametersType<Contract>, QueryStringParameters = QueryStringParametersType<Contract>, Headers = HeadersType<Contract>, CustomRequestContext = CustomRequestContextType<Contract>, Body = BodyType<Contract>, Output extends {
statusCode: number | string | symbol;
body: unknown;
} = OutputType<Contract>>(contract: Contract, options: GetApiGatewayHandlerOptions) => <AdditionalArgs extends unknown[] = never[]>(handler: InternalSwarmionApiGatewayHandler<IntegrationType, AuthorizerType, PathParameters, QueryStringParameters, Headers, CustomRequestContext, Body, Output, AdditionalArgs>) => ApiGatewayHandler<IntegrationType, AuthorizerType, Output, AdditionalArgs>;
/**
* A wrapper to get the proper typing for a lambda handler.
* This does not include parsing and validation.
*
* Use `getHandler` for a more advanced usage
*/
export declare const getLambdaHandler: <Contract extends GenericApiGatewayContract, IntegrationType extends ApiGatewayIntegrationType = Contract["integrationType"], AuthorizerType extends ApiGatewayAuthorizerType = Contract["authorizerType"], PathParameters = PathParametersType<Contract>, QueryStringParameters = QueryStringParametersType<Contract>, Headers = HeadersType<Contract>, CustomRequestContext = CustomRequestContextType<Contract>, Body = BodyType<Contract>, Output = OutputType<Contract>, Handler = InternalSwarmionApiGatewayHandler<IntegrationType, AuthorizerType, PathParameters, QueryStringParameters, Headers, CustomRequestContext, Body, Output>>(_contract: Contract) => (handler: Handler) => Handler;
//# sourceMappingURL=lambdaHandler.d.ts.map