Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions types/aws-lambda-fastify/aws-lambda-fastify-tests.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import awsLambdaFastify from 'aws-lambda-fastify';
import fastify, { FastifyReply, FastifyRequest } from 'fastify';
import { Context, Callback } from 'aws-lambda/handler';
import { RouteGenericInterface } from 'fastify/types/route';
import { Server, IncomingMessage, ServerResponse } from 'node:http';

const app = fastify();
const proxy = awsLambdaFastify(app, { binaryMimeTypes: ['application/octet-stream'] });

const handler = proxy;
const handlerWithCallback = (event: FastifyRequest<RouteGenericInterface, Server, IncomingMessage>,
context: Context,
callback: Callback<FastifyReply<Server, IncomingMessage, ServerResponse, RouteGenericInterface, unknown>> | undefined) => proxy;
const handlerFunction = (event: FastifyRequest<RouteGenericInterface, Server, IncomingMessage>, context: Context) => proxy;
const handlerWithAsync = async (event: FastifyRequest<RouteGenericInterface, Server, IncomingMessage>, context: Context) => proxy;
24 changes: 24 additions & 0 deletions types/aws-lambda-fastify/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Type definitions for aws-lambda-fastify 1.4
// Project: https://github.com/fastify/aws-lambda-fastify
// Definitions by: Kang Chan <https://github.com/kentakang>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped

/// <reference types="node" />

import { Context, Callback } from 'aws-lambda';
import { FastifyInstance, FastifyRequest, FastifyReply } from 'fastify';

interface AwsLambdaFastifyOptions {
binaryMimeTypes?: string[];
callbackWaitsForEmptyEventLoop?: boolean;
}

type Handler<TEvent = FastifyRequest, TResult = FastifyReply> = (
event: TEvent,
context: Context,
callback?: Callback<TResult>,
) => void | Promise<TResult>;

declare function awsLambdaFastify(app: FastifyInstance, options?: AwsLambdaFastifyOptions): Handler;

export = awsLambdaFastify;
6 changes: 6 additions & 0 deletions types/aws-lambda-fastify/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"private": true,
"dependencies": {
"fastify": "^3.14.2"
}
}
24 changes: 24 additions & 0 deletions types/aws-lambda-fastify/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true,
"esModuleInterop": true
},
"files": [
"index.d.ts",
"aws-lambda-fastify-tests.ts"
]
}
1 change: 1 addition & 0 deletions types/aws-lambda-fastify/tslint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }