Using Foundry in your project

Your first session

Make sure to have Foundry installed first:

For Foundry to work it must have access to two files:

  1. The foundry.yaml configuration file

  2. The package.json file for your Cloud Functions

A structure of a project using Foundry might look like this:

+- functions/ # Directory containing all your Cloud Functions
+- node_modules/
+- package.json # package.json for your Cloud Functions
+- foundry.yaml # Foundry configuration file
+- index.js # Root index.js file with exports for all your Cloud Functions

Foundry uses the value of the main field in your package.json as a path to look for the file where are all your Cloud Functions exported. If your package.json doesn't specify the main field, Foundry expects that all your Cloud Functions are exported in the index.js file that is placed alongside your package.json file.

You use Foundry CLI to start your session and connect to your cloud development environment. Here's a basic example:

# Go to the directory where is package.json for your Cloud Functions
$ cd myproject/functions
# Run this only once to generate the initial foundry.yaml config file
$ foundry init
# Start your session and connect to your cloud development environment
$ foundry go

Foundry won't load your Cloud Functions without adding them into the foundry.yaml file. Please read "Defining Cloud Functions" to learn how to add your Cloud Functions into the foundry.yaml file.

However, Foundry won't be able to load your Firebase Cloud Functions just yet. To have your Cloud Functions loaded you must define them in the foundry.yaml configuration file.

To learn more on how to add your Cloud Functions into the configuration file please read:

To learn more on how to use Foundry CLI please read:

Read Starting your session to learn more how the session and interactive prompt works

What to do next?

Once your cloud environment is ready and the configuration file is set up, you can start coding. Foundry will install the dependencies during the first run. Then you will see that Foundry triggers all functions you specified in the configuration file each time you save your code.