TL/DR: Is there a way to combine two apps with express, and fall back to the second app if the first doesn't implement a route?
We currently have two express apps, a new well-factored app and an old, deprecated app. Going forward, our team will be slowly migrating everything in the old app to the new app.
I'm looking for a way to combine the two apps so they can both be called. I realized I can do something like this using app.use, but that requires the apps to be on separate subdomains or use separate base paths. My goal is to keep the routes the same, so a person calling the API is unaware of the changes happening under the hood.
For example, it would be great if I could do something like this:
const express = require('express');
let oldApp = express();
let newApp = express();
oldApp.get('/old', function (req, res) {
res.send("OLD");
});
newApp.get('/new', function (req, res) {
res.send("NEW");
});
express().use(oldApp, newAPp).listen(3000);
Then, I could call localhost:3000/old or localhost:3000/new and both endpoints would work.