From 3d258ba126cc976d967aa16012960e5185b6e6d2 Mon Sep 17 00:00:00 2001 From: dkundel Date: Sun, 7 Jul 2019 21:25:32 -0700 Subject: [PATCH] feat(types): add ServerlessFunctionSignature types --- packages/serverless-runtime-types/types.d.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/packages/serverless-runtime-types/types.d.ts b/packages/serverless-runtime-types/types.d.ts index 92479828..4f9ac6a8 100644 --- a/packages/serverless-runtime-types/types.d.ts +++ b/packages/serverless-runtime-types/types.d.ts @@ -1,6 +1,10 @@ import twilio from 'twilio'; import { ServiceContext } from 'twilio/lib/rest/sync/v1/service'; +export type EnvironmentVariables = { + [key: string]: string | undefined; +}; + export type ResourceMap = { [name: string]: { path: string; @@ -17,3 +21,17 @@ export type Context = { getTwilioClient(): twilio.Twilio; DOMAIN_NAME: string; } & T; + +export type ServerlessCallback = ( + error: null | Error, + payload?: object +) => void; + +export type ServerlessFunctionSignature< + T extends EnvironmentVariables = {}, + U extends {} = {} +> = ( + context: Context, + event: U, + callback: ServerlessCallback +) => void | Promise;