Best practices for running callable script #12548
-
Hello, I was just wondering what the recommended way to run a 'callable' script is, in my Next.js app? To be clear, this isn't really an API endpoint that gets/sets data, rather a Node.js script that I will run daily (via AWS Lambda or some a cron service) and add some records to the database. But it's also definitely not a 'page' that I want to be publicly searchable. I've so far just added the script to the Thanks in advance! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
It could be worth investigating migrating something like this to a dedicated GitHub action or external service. If you have this function as a page in |
Beta Was this translation helpful? Give feedback.
-
I also want to do this but for developer-centric scripts like seeding the database. I was trying to use my Mongoose models using a simple This is what I get when I try running the file using
Not really sure how to proceed... |
Beta Was this translation helpful? Give feedback.
It could be worth investigating migrating something like this to a dedicated GitHub action or external service. If you have this function as a page in
pages/api/
it's accessible to the internet, so you'd need some kind of authentication/authorization rules, or risk it getting spammed and doing a lot of extra work on your DB.