0

I'm writing GCP functions in a npm repository, here is the structure of my files:

$  root .
└── package.json
    └── src
        └── index.ts
        └── functions
            └── fct1.ts
            └── fct2.ts
            └── ...

I have multiple function declaration in this index.ts, including http functions and event functions. One of them is serving a NestJs application that needs to initialise NestJs on cold start but since they all are in the same file (index.ts) NestJs is in scope for all the functions, including the event functions and other http functions which is delaying the cold start of all of them.

I am currently deploying all the functions in a github action doing firebase deploy --only functions.

Is there a way to split the functions declarations in different files?

I found this resource: https://firebase.google.com/docs/functions/organize-functions?gen=2nd but I don't really want to create npm repositories for each function that has a different scope. Furthermore, all the functions share resources like models, apis, services, ...

Thanks for the help

Doug Stevenson
  • 297,357
  • 32
  • 422
  • 441
  • Since you didn't show any code, I just marked duplicates for all sorts of different similar questions. Also in the future, consider doing a web search before posting, and make an attempt using what you learn there. Then if that doesn't work, show what doesn't work the way you expect. – Doug Stevenson Aug 11 '23 at 02:15
  • Also read: https://medium.com/firebase-developers/organize-cloud-functions-for-max-cold-start-performance-and-readability-with-typescript-and-9261ee8450f0 – Doug Stevenson Aug 11 '23 at 02:16
  • @DougStevenson I did search but couldn't find a solution. Thanks for the duplicate, I'll have a look, it seems to solve my issue at first sight. – Antoine ALEJANDRO Aug 11 '23 at 02:49

0 Answers0