@swarmion/serverless-contracts
Version:
Generate and use type-safe contracts between your Serverless services.
26 lines • 1.37 kB
TypeScript
import Ajv from 'ajv';
import { APIGatewayProxyEvent, APIGatewayProxyEventV2, Handler } from 'aws-lambda';
import { GetApiGatewayHandlerOptions } from './lambdaHandler';
import { GenericApiGatewayContract } from '../apiGatewayContract';
import { SwarmionApiGatewayHandler } from '../types';
type Match<E> = [Handler<E>, E];
export declare class SwarmionRouter {
private consumers;
private ajv;
constructor({ ajv }?: {
ajv?: Ajv;
});
add<Contract extends GenericApiGatewayContract>(contract: Contract, options?: Omit<GetApiGatewayHandlerOptions, 'ajv'>): (handler: SwarmionApiGatewayHandler<Contract>) => void;
match(event: unknown): Match<APIGatewayProxyEvent | APIGatewayProxyEventV2> | null;
}
export declare const matchApiGatewayContract: (contract: GenericApiGatewayContract, event: unknown) => APIGatewayProxyEvent | APIGatewayProxyEventV2 | false;
export declare const matchHttpRoute: <E extends APIGatewayProxyEvent | APIGatewayProxyEventV2>({ contract, method, path, event, }: {
contract: GenericApiGatewayContract;
method: string;
path: string;
event: E;
}) => E | false;
export declare const isValidHttpApiGatewayEvent: (event: any) => event is APIGatewayProxyEventV2;
export declare const isValidRestApiGatewayEvent: (event: any) => event is APIGatewayProxyEvent;
export {};
//# sourceMappingURL=router.d.ts.map