From 0e5b1417eac1cdb9a042925c81f9d6abaf976f53 Mon Sep 17 00:00:00 2001 From: Sebastian Kreft Date: Sun, 31 May 2020 15:46:57 -0400 Subject: [PATCH] fix: onRequest type definitions onRequest basically defines a handler for express routes, which allow async handlers. However at the moment the types only allowed to have non-async definitions. Note that async support does work today in production. --- src/cloud-functions.ts | 2 +- src/providers/https.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cloud-functions.ts b/src/cloud-functions.ts index ea4acd7a2..72dddc073 100644 --- a/src/cloud-functions.ts +++ b/src/cloud-functions.ts @@ -280,7 +280,7 @@ export interface Runnable { * arguments. */ export type HttpsFunction = TriggerAnnotated & - ((req: Request, resp: Response) => void); + ((req: Request, resp: Response) => void | Promise); /** * The Cloud Function type for all non-HTTPS triggers. This should be exported diff --git a/src/providers/https.ts b/src/providers/https.ts index 605c633f0..cd9f1745d 100644 --- a/src/providers/https.ts +++ b/src/providers/https.ts @@ -39,7 +39,7 @@ export interface Request extends express.Request { * same signature as an Express app. */ export function onRequest( - handler: (req: Request, resp: express.Response) => void + handler: (req: Request, resp: express.Response) => void | Promise ): HttpsFunction { return _onRequestWithOptions(handler, {}); } @@ -56,7 +56,7 @@ export function onCall( /** @hidden */ export function _onRequestWithOptions( - handler: (req: Request, resp: express.Response) => void, + handler: (req: Request, resp: express.Response) => void | Promise, options: DeploymentOptions ): HttpsFunction { // lets us add __trigger without altering handler: