Hi, General architecture of Nextjs and Prisma que...
# orm-help
m
Hi, General architecture of Nextjs and Prisma question: I have been trying to understand how to structure an application that fetches data from a third-party api (eg. Twitter API) on an interval, and save part of the information to a database. It has to run continuously. (Example: say I have a list of Book names, and needs to do a third-party api query on each of those names every 3 hours.) I am familiar with Nextjs and Prisma but doesn't quite understand if that is something I'd be able to do with Nextjs API Routes. As far as I understand, API Routes is built on serverless functions but am just starting dip my toes in the water. Alternative, I think I'd need a separate backend which handles all of that? Or am I missing something? My background is as a designer with some front-end experience. I hope this type of general question is ok here. Thanks 🙂
e
needs to do a third-party api query on each of those names every 3 hours
you'll need to setup a cron job for that. Next.js allows you to define a custom server https://nextjs.org/docs/advanced-features/custom-server you could build a custom express server and then use node-cron to do this and populate your db with fresh data from that third party api https://www.digitalocean.com/community/tutorials/nodejs-cron-jobs-by-examples With this, when your users arrive to the app, they'll see fresh an up to date data
b
Big fan of node-schedule, just a more popular / better maintained alternative to node-cron https://github.com/node-schedule/node-schedule
e
looks interesting @Ben Schwartz nice! I just found Bree that seems to be maintained too and the docs look great https://github.com/breejs/bree