I have a Next.js (pages) app, with many API routes in the /api folder. I am hosting this on Vercel, where there is a 10 second execution limit.
I have some API routes that take a long time to process data, and I want to move these to a standalone serverfull Express.js application, so they can take as long as they need.
I'm wondering how I can have both the Express.js server and the Next.js application in a monorepo? And then how do I host the Next.js portion of the monorepo on Vercel, and the Express.js portion on Railway? I want to have shared types and interfaces between the Next.js app and the Express.js app (e.g., re-use some util functions in the express app).
Currently, I have a completely seperate Express.js server where I've essentially re-written many of the types, interfaces and functions that could otherwise be shared if it was in a mono-repo.
I have tried to use nx, but my issue is that I already have the Next.js application, and I'm not sure how to integrate that into a monorepo, and then generate an express application using the nx CLI.