Created
February 26, 2019 16:01
-
-
Save de314/5d2133d69886da24cf90e8743010db1d to your computer and use it in GitHub Desktop.
Admin Bro + FeathersJS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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); | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ... | |
const adminBro = require('./adminBro'); | |
// ... | |
// Admin Bro | |
// needs to be added AFTER services/channels and BEFORE `notFound` and `errorHandler` routers | |
app.configure(adminBro); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
... | |
"adminBro": { | |
"path": "/admin-panel" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment