Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Example of how a main express app can mount sub-applications on a mount point with app.use('/mount-point', subapp); If you GET /, you'll see the main_app's '/' response. If you GET /ep_app, you'll see the ep_app's '/' response.
var express = require("express");
var app = express();
app.get('/', function (req, res) {
res.send("This is the '/' route in ep_app");
});
module.exports = app;
#!/usr/bin/env node
var express = require("express");
var app = express();
var ep_app = require("./ep_app");
app.use('/ep_app', ep_app);
app.get('/', function (req, res) {
res.send("This is the '/' route in main_app");
});
app.listen(3000);
@xdriyad

This comment has been minimized.

Copy link

commented Jan 25, 2018

I was looking for a perfect example of subapp and you're the savior! thank you!

@woodardj

This comment has been minimized.

Copy link

commented Jan 13, 2019

Are there negative (memory?) implications of building apps like this v. using a Router?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.