UNPKG

firebase-functions

Version:
25 lines (24 loc) 1.31 kB
import * as express from "express"; import { CallableContext, FunctionsErrorCode, HttpsError, type CorsOption, Request } from "../../common/providers/https"; import { HttpsFunction, Runnable } from "../cloud-functions"; export { HttpsError }; export type { Request, CallableContext, FunctionsErrorCode }; export interface HttpsOptions { /** * If true, allows CORS on requests to this function. * If this is a `string` or `RegExp`, allows requests from domains that match the provided value. * If this is an `Array`, allows requests from domains matching at least one entry of the array. */ cors?: CorsOption; } /** * Handle HTTP requests. * @param optsOrHandler Options or a function that takes a request and response object, * same signature as an Express app. */ export declare function onRequest(optsOrHandler: HttpsOptions | ((req: Request, resp: express.Response) => void | Promise<void>), handler?: (req: Request, resp: express.Response) => void | Promise<void>): HttpsFunction; /** * Declares a callable method for clients to call using a Firebase SDK. * @param handler A method that takes a data and context and returns a value. */ export declare function onCall(handler: (data: any, context: CallableContext) => any | Promise<any>): HttpsFunction & Runnable<any>;