Javascript 重构firebase函数index.ts代码,以便可以导入触发器

Javascript 重构firebase函数index.ts代码,以便可以导入触发器,javascript,firebase,firebase-authentication,Javascript,Firebase,Firebase Authentication,我正在使用https、auth和datastore触发器编写firebase函数,因此我想将它们分解到不同的文件中。我已经计算出了https函数,但我不确定如何计算出auth函数。我的索引.ts当前为: import * as express from 'express'; import * as functions from 'firebase-functions'; import { spiceAdmin } from './base'; import { spiceSer

我正在使用
https
auth
datastore
触发器编写firebase函数,因此我想将它们分解到不同的文件中。我已经计算出了
https
函数,但我不确定如何计算出
auth
函数。我的
索引.ts
当前为:

import * as express     from 'express';
import * as functions   from 'firebase-functions';
import  { spiceAdmin  } from './base';
import  { spiceServer } from './spiceServer'

import  { server }      from './api-routes/api'


exports.app = functions.https.onRequest(server);



/**
    @Use: send verification email on new user creation
*/
exports.onCreate = functions.auth.user().onCreate( user => {

    spiceAdmin.auth().createUser({
          email         : 'user-auth-ts@gmail.com'
        , emailVerified : false
        , password      : 'Sup3rSafe'
    }) 
    .then((userRecord : any) => console.log('created new user'))
    .catch((err : string) => console.log(`failed to create new user with ${err}`))

});
具体地说,如果我有一个带有触发器的文件
user_auth.ts
onCreate
onChange
,我将如何语法地编写这些函数,然后导出,然后在
index.ts?
中导出它们

import { myFunction } from './myfunction'
export const myFunction_export = myFunction
myfunction.ts

import * as functions from 'firebase-functions'
export const myFunction = functions.firestore.document(...).onCreate(...)
索引

import { myFunction } from './myfunction'
export const myFunction_export = myFunction
myfunction.ts

import * as functions from 'firebase-functions'
export const myFunction = functions.firestore.document(...).onCreate(...)