Context is: having several lambda functions added to our function folder and needing to run two of those on deploy-succeeded event.
They need to remain as standalone serverless functions and also be part of the deploy-succeeded.js file in order for Netlify to run them after deploy.
Is there a recommended way to achieve this considering (I think) any serverless function file can only have one exports.handler and I would rather avoid copying/pasting too much code
Apology in advance if the above does not make sense, I’m a serverless/node beginner
I am also a beginner at functions, but wondering: can you call those functions asynchronously? Or does the response matter? If asynchronously, you could just call them from that function (since you don’t need to wait for them to finish and for your main code to run in the function), using their direct paths (https://yoursite/.netlify/functions/name)
Wow awesome Thanks a lot for that, I’ll study it closely.
Which make me think… it does not seem you need node-fetch in your package.json for netlify to ship it as dep of your lambda?
I did not see it in your repo.
Hi, I’m trying to understand how to create a function that runs once on deploy-succeeded event. My function fetches data from an API and pushes it to a database and I’d like to have it triggered for every deploy and then trigger a deploy once a day. Would this be possible?
Sure, but we don’t have any automatic way to do it “once a day” - so you have to automate that somehow, perhaps with a Scheduled Zap or a cron server you run to hit an incoming webhook to trigger a build?
Then we’ll always run your deploy-succeeded.js function for you if you configure one, so limiting your deploys to once a day will meet that requirement.
So is it possible to write nodejs Schduler inside a netlify function …
On hit of schduler netlify function , schduler is turned on
once a week , it does my job ( logic on trigger )
then repeats after a week
since functions run only for 10 seconds, doing anything “for a week” will obviously not work. I think that as I advised in August, you’ll need some external service (that isn’t Netlify) to handle scheduled runs at the moment