How do you implement event-triggered functions?

I’d like to create a function that runs only once every time my site is deployed. This function would make some API requests and write the response to a database (Firestore) from which my React app can retrieve and use the data without making additional/unnecessary API calls. After reading the docs I still don’t understand how to implement such a function. Also, since I’d like to update my database once a day, are there any limits to how many times I can deploy my site?


What I did was create a NodeJS script and that then added a script to my package.json to run it.

"scripts": {
    "build": "npm run fetch-missing-images && gatsby build",
    "build:prod": "npm run build; npm run lambda-build",
    "lambda-build": "netlify-lambda build functions",
    "fetch-missing-images": "node fetchMissingImages.js"

Then I changed the build command in my deploy settings to be build:prod which triggers build which then runs my node app to update my db with missing images.

Hope that helps,
Travis Ballard

@nicmeriano, about build limits (meaning: “how many times I can deploy my site”), at this time we do not limit build counts. Deploying once a day would not be an issue.

We do limit build concurrency based on the plan level. There is more information about build concurrency limits here.