express-mount-apps
A tiny utility for mounting multiple express apps to a single main app.
Install:
npm install express-mount-apps
Test:
make test
How:
This functionality is already built into express:
var express = require('express'),
app = express(),
blog = require('blog');
app.use('/blog', blog);
However, I want to define my modules in a config file:
{
apps: [
{
// name of the module to `require`
name: 'blog',
// route prefix for this module
path: '/blog'
},
{
name: 'auth',
path: '/login'
}
]
}
And in my express API:
var mount = require('express-mount-apps'),
config = require('config');
mount(config.apps, function (err) {
if (err) {
console.log(err);
process.exit(1);
}
});