simov/express-admin — pull request #66 by knownasilya (2014-08-05 03:31:07+00:00)
Title: Add setupServer to allow for app.use('/admin', adminApp);

To merge with existing app do something like:

```js
var express = require('express');
var admin = require('express-admin');
var path = require('path');
var vhost = require('vhost');
var env = process.env.NODE_ENV || 'development';
var domain = (env === 'development' ? 'localhost' : 'mydomain.com');
var adminConfigPath = path.join(process.cwd(), 'server/admin/config');

// middleware here..

admin.setupServer(adminConfigPath, function (err, setup) {
if (err) {
throw err;
}

// to make it work in development
app.use(vhost('admin.' + domain, setup.app));
});
```

To make it work on `admin.localhost` add `127.0.0.1 admin.localhost` to `/etc/hosts`, see [here](http://www.hacksparrow.com/vhost-in-express-js.html).

Also uses `setupServer` internally.