Congratulations on your first production deployment! :)
There are multiple ways to run multiple "apps" from one Node (express) app. You're saying Angular apps, but it seems like Node.js is involved too, so I'll try to address some cases. If you have one very specific
TL;DR:
- if it's just angular apps, serve app.use('/app-virtual-path', express.static('/path/to/app'))
- if it's Node.js code as well, write those in their own modules, and export their routers (not the whole express apps), than mount the individual routers on a global express server.
If it's just multiple angular apps, than it's pretty simple - serve apps on different routes (or even domains/network interfaces/whatnot).
E.g. simplest way to serve those with Node on different paths, e.g.
etc.
app.use('/app1', express.static('/path/to/app1'));
app.use('/app2', express.static('/path/to/app2'));
// ...
app.use('/appN', express.static('/path/to/appN'));
Basically, every app is served in its own virtual path.
Alternatively, you can serve the angular apps on different subdomains, e.g.:
How to do this depends on your server setup. You can route it directly with node, using something like this:
https://www.npmjs.com/package/express-subdomain. Alternatively, you can use the simpler version above, but than use some rewrite rule on the reverse proxy that's in front of node (such as nginx, or IIS since you're on windows).
If you also need some server-side specific code, those separate routes handle the stuff, for you. For clarity, maybe just separate those in their own files/folders with their own routers, than mount it all on one global express router and handle routing properly. The added benefit of running it all on a single node instance is that you get to share common middleware like authentication or authorization, which is likely to be useful in an environment that you describe.
Example:
// app1.js
const router = require('express').Router();
router.use('/app-specific-endpoint', (req, res) => {
res.json({ message: 'Here is something that is specific for this app' });
});
router.use(express.static('/path/to/angular/code'));
module.exports = { router };helps a bit
// app2 -> the same, just for the different angular app.
const router = ...
module.exports = { router };
// global express app file, e.g. server.js
const express = require('express')
const app = express();
const middleware = require('./middleware/'); // optionally, if ou need it.
const router1 = require('./app1').router;
const router2 = require('./app2').router;
app.use(middleware.auth());
app.use('/angular-app-1', router1);
app.use('/angular-app-2', middleware.hasRole('admin')); // specific for app2, say, permissions check
app.use('/angular-app-2', router2);
const port = 8080;
app.listen(port, (err) => console.log(err || `Listening on ${port}`));
I hope this gives you ideas on how to start. If you share more details, maybe you can get more specific answers.