mirror of
https://github.com/roleypoly/roleypoly-v1.git
synced 2025-06-15 18:09:09 +00:00
first sync
This commit is contained in:
parent
5d6f382c8a
commit
a4acc441ea
52 changed files with 28315 additions and 0 deletions
20
Server/api/index.js
Normal file
20
Server/api/index.js
Normal file
|
@ -0,0 +1,20 @@
|
|||
const log = new (require('../logger'))('api/index')
|
||||
const glob = require('glob')
|
||||
|
||||
module.exports = async (router, ctx) => {
|
||||
const apis = glob.sync('./api/**/!(index).js')
|
||||
log.debug('found apis', apis)
|
||||
|
||||
for (let a of apis) {
|
||||
if (a.endsWith('_test.js') !== null && process.env.NODE_ENV !== 'development') {
|
||||
log.debug(`skipping ${a}`)
|
||||
continue
|
||||
}
|
||||
log.debug(`mounting ${a}`)
|
||||
try {
|
||||
require(a.replace('api/', ''))(router, ctx)
|
||||
} catch (e) {
|
||||
log.error(`couldn't mount ${a}`, e)
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue