Open camerow opened 7 years ago
just to confirm--do you get undefined
in your console.log
there? or is it just that the routes aren't registering with server.route
?
Yes, it was undefined. The solution for me was:
glob.sync('api/**/routes/*.js', {
cwd: __dirname // root -> cwd
}).forEach(file => {
console.log('file --', file);
const route = require(path.join(__dirname, file));
server.route(route);
});
gotcha, thanks for sharing. which version of glob do you have? and which platform are you running node on?
Platform is Ubuntu 16.04, "glob": "^7.1.1"
I have to say though, I love that implementation for importing routes!
Cool, it's possible something broke between glob 7.0 and 7.1 but I'm not sure. Would you want to open a PR with the fix?
And yes, using glob for this is much saner :) Things can get out of hand when we start getting a lot of routes.
I can open a PR for sure. I'll to do it later at home though.
@camerow any updates of that PR? :)
Glob.sync is returning an empty array for me. My tree looks the same as the sample:
and I have
my never runs.