lighthouse.js/server/utils/routesLoader.js
Fillerino 1bcc272e0b Added the basic structure and fixed some issues!
Added the basic structure and fixed some issues!
Fixes #2, fixes # 3
2017-08-16 19:49:27 +02:00

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);
});
});
}