#Re-use code from one nest app in another nest app

1 messages · Page 1 of 1 (latest)

loud ocean
#

Currently we have a single app that contains API and cron jobs. This setup is insufficient for current load and we can't process such amount of requests using only 1 app instance. We need to separate API and cron jobs to avoid any conflicts when running multiple instances of our app so we can scale API horizontally. The main problem for now, that we are trying to share entities and some use-cases between our main api and cron jobs service. Please, share your ideas in this thread how this can be achieved (Currently, we think about using monorepo and fully separate cron jobs from the main api, or just using separate bootstrap files and entry points for API and cron jobs service)

glad storm
#

Hard to say with what is given. Normally, you'd refactor shared things into their own module, so it can be a library. That way you can have two separate apps, which depend on the shared library. You need a monorepo to do this. And, it is better not to use Nest's monorepo mode, but rather a proper monorepo manager like Nx or Rush.

stuck magnet
#

Or just npm or yarn workspaces can be often enough (and are built right into the package manager)

proven obsidian
#

I'm using separate bootstrap files personally and am satisfied with the setup. You don't need monorepo for this if your concern is independent scaling

tawdry spoke
#

Create multiple apps and pull in the modules you want per app

#

The scaling you can run them as console apps and then build in a docker container to run wherever.