Skip to content

Commit 4e51dbb

Browse files
committed
feat(extracttriggers): function name param to allow multi-trigger files
The extractTrigger function is now passed an additional param that indicates the current function name (if not deploying). In conjunction with customising funcNameFromRelPath, this could be used to allow a setup where more than one trigger per file is stored. This isn't the best for performance but we have decided to allow the flexibility. feat #6
1 parent f881efc commit 4e51dbb

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/export-functions.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,13 @@ export interface ExportFunctionsConfig {
9090
* the behaviour of es6 modules using `export default`. You may customise this behaviour.
9191
* @param inputModule This object is the required CommonJS module that will be passed
9292
* as the only argument to this function.
93+
* @param currentFunctionName this is only present if run during a function invocation
94+
* rather than during deployment. It is useful if customising BFF to find more than
95+
* one trigger per file.
9396
* @returns must return the actual function trigger to be exported to firebase functions.
9497
* @example exportFunctions({extractTrigger: (obj) => obj['default']})
9598
*/
96-
extractTrigger?: (inputModule: any) => any;
99+
extractTrigger?: (inputModule: any, currentFunctionName?: string) => any;
97100

98101
/**
99102
* Boolean value - wether to enable logging performance metrics
@@ -199,7 +202,7 @@ export function exportFunctions({
199202
try {
200203
// eslint-disable-next-line no-eval
201204
const mod = eval('require')(absPath); // This is to preserve require call in webpack
202-
funcTrigger = extractTrigger(mod);
205+
funcTrigger = extractTrigger(mod, getFunctionInstance());
203206
} catch (err) {
204207
console.error(err);
205208
continue;

0 commit comments

Comments
 (0)