1bcc272e0b
Added the basic structure and fixed some issues! Fixes #2, fixes # 3
19 lines
481 B
JavaScript
19 lines
481 B
JavaScript
import glob from 'glob';
|
|
|
|
export default function (dirname) {
|
|
return new Promise((resolve, reject) => {
|
|
const routes = [];
|
|
glob(`${dirname}/*`, {
|
|
ignore: '**/index.js',
|
|
}, (err, files) => {
|
|
if (err) {
|
|
return reject(err);
|
|
}
|
|
files.forEach((file) => {
|
|
const route = require(file); // eslint-disable-line global-require, import/no-dynamic-require
|
|
routes.push(route);
|
|
});
|
|
return resolve(routes);
|
|
});
|
|
});
|
|
}
|