Sunday, 16 August 2020

How do you structure a NextJS application without putting everything in the controller?

Creating a landing page with NextJS that has 2 api routes (i. create Stripe customer and ii. register user). The actual app will be hosted on a different server with a different front end.The 2 api routes require me to access the database and also use the Stripe library. I'd like to abstract those two functionalities outside NextJS's api controller, but am not sure where to put those files.My api routes are in ./pages/api. Would I just create a folder at the root of my project (ie, ./api/stripe/... and ./api/db/...)? How is everyone else doing it?

Submitted August 17, 2020 at 01:07AM by nickkang1

No comments:

Post a Comment