in my js classes i have routes for express to use in the route property
my problem is that express starts listening before the routes are done loading via glob:
glob("pages/**/*.js", (error, file) => {
import("./" + file).then((page) => {
console.log(new page.default().route);
});
});
app.listen(config.port, () =>
console.log(`App listening on http://localhost:${config.port}`)
);
here is my console output:
node index.js
App listening on http://localhost:1337
{ uri: '/users' }
notice how the uri line comes AFTER app listening when it should be before
i've also tried using glob.sync and the same thing happens
how do i make the code wait for the route files to finish loading before app.listen fires?