Wanting to save some data every 30 days from an external game server on my t3 app server database.

So I have a function that gets the 'total accounts' from an external api, every 30 days I want to save that number to my prisma database (running on the create-t3-app server), what would be a smart way to save this data I am thinking I would need to check if its been 30 days since the last data save, if yes then insert a new value with the date If not then wait ? But I am not sure how to do this properly
8 Replies
pach
pach15mo ago
node-cron maybe?
whatplan
whatplan15mo ago
Introducing Vercel Cron Jobs – Vercel
Automate repetitive tasks using Vercel Cron Jobs and Vercel Functions. Available today in beta.
pach
pach15mo ago
i hate to say im not using vercel but im not using vercel
whatplan
whatplan15mo ago
There’s a bunch of CRON providers outside of vervet I feel like Theo had mentioned some he liked specifically in the past Im trying to find where but can’t seem to do so
pach
pach15mo ago
going to setup my app in vercel now and give it a go anyway but i did find this and this might work https://nextjs.org/docs/advanced-features/custom-server
Advanced Features: Custom Server | Next.js
Start a Next.js app programmatically using a custom server.
whatplan
whatplan15mo ago
Best of luck
jordanmckoy
jordanmckoy15mo ago
If you dont want to setup someone sort of outside cron jobs, you could use https://www.npmjs.com/package/node-cron
npm
node-cron
A simple cron-like task scheduler for Node.js. Latest version: 3.0.2, last published: 7 months ago. Start using node-cron in your project by running npm i node-cron. There are 896 other projects in the npm registry using node-cron.
jordanmckoy
jordanmckoy15mo ago
I do recommend dedicated crons though 🙂