Skip to content

Instantly share code, notes, and snippets.

@de314
Created February 26, 2019 16:01
Show Gist options
  • Save de314/5d2133d69886da24cf90e8743010db1d to your computer and use it in GitHub Desktop.
Save de314/5d2133d69886da24cf90e8743010db1d to your computer and use it in GitHub Desktop.
Admin Bro + FeathersJS
// Admin Bro
const AdminBro = require('admin-bro');
const AdminBroExpressjs = require('admin-bro-expressjs');
const logger = require('./logger');
AdminBro.registerAdapter(require('admin-bro-mongoose'));
module.exports = function(app) {
const adminBroSettings = app.get('adminBro');
const adminBroRootPath =
!!adminBroSettings && !!adminBroSettings.path
? adminBroSettings.path
: '/admin';
logger.info(`Mounting AdminBro to ${adminBroRootPath}`);
const adminBro = new AdminBro({
databases: [app.get('mongooseClient')],
// TODO: allow for overwriting defaults via configuration
// resources: Object.values(app.get('mongooseClient').models),
rootPath: adminBroRootPath,
});
Object.values(adminBro.resources).forEach(resource =>
logger.info(`\t- AdminBro adding resource ${resource.name()}`),
);
const router = AdminBroExpressjs.buildRouter(adminBro);
app.use(adminBroRootPath, router);
};
// ...
const adminBro = require('./adminBro');
// ...
// Admin Bro
// needs to be added AFTER services/channels and BEFORE `notFound` and `errorHandler` routers
app.configure(adminBro);
{
...
"adminBro": {
"path": "/admin-panel"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment