import * as functions from "firebase-functions" ; import config from "./config" ; param handler param runtimeOpt export function https ( handler , runtimeOpt = { memory : '256MB' , timeoutSeconds : 60 } ) { return functions . runWith ( runtimeOpt ) . region ( ... config . regions ) . https . onCall ( async ( data , context ) => { const uid = await config . authenticator . authenticate ( data , context ) ; return handler ( uid , data , context ) ; } ) ; } export function storage ( bucket , handler , runtimeOpt = { memory : '256MB' , timeoutSeconds : 60 } ) { return functions . runWith ( runtimeOpt ) . region ( ... config . regions ) . storage . bucket ( bucket ) . object ( ) . onFinalize ( async ( object ) => { return handler ( object ) ; } ) ; }