mirror of
https://github.com/Permissionless-Software-Foundation/ipfs-bch-wallet-consumer.git
synced 2026-09-21 16:52:03 -07:00
Register controllers from glob
This commit is contained in:
@@ -25,6 +25,7 @@
|
||||
"babel-preset-es2015": "^6.5.0",
|
||||
"babel-preset-stage-0": "^6.5.0",
|
||||
"bcrypt": "^0.8.5",
|
||||
"glob": "^7.0.0",
|
||||
"jsonwebtoken": "^5.5.4",
|
||||
"koa": "^2.0.0-alpha.3",
|
||||
"koa-bodyparser": "^2.0.1",
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
import users from './users'
|
||||
import auth from './auth'
|
||||
import { Glob } from 'glob'
|
||||
|
||||
exports = module.exports = function Controllers(app) {
|
||||
app
|
||||
.use(auth.routes())
|
||||
.use(auth.allowedMethods())
|
||||
new Glob(`${__dirname}/*.js`, { ignore: '**/index.js' }, (err, matches) => {
|
||||
if (err) { throw err }
|
||||
|
||||
.use(users.routes())
|
||||
.use(users.allowedMethods())
|
||||
matches.forEach((file) => {
|
||||
const controller = require(file).default
|
||||
app
|
||||
.use(controller.routes())
|
||||
.use(controller.allowedMethods())
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user