Skip to content

Commit

Permalink
Handle route modules with default exports (#892)
Browse files Browse the repository at this point in the history
* fix: handle route modules with default exports

* test: handle route modules with default exports
  • Loading branch information
agerard-godaddy authored Sep 12, 2024
1 parent fb8a889 commit 5191e1a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/gasket-plugin-express/lib/create-servers.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ module.exports = async function createServers(gasket, serverOpts) {
if (routes) {
const files = await glob(`${ routes }.js`, { cwd: root });
for (const file of files) {
require(path.join(root, file))(app);
const route = require(path.join(root, file));
(route.default || route)(app);
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
function routes(app) {
app.use('/some/route', (req, res, next) => {
next(new Error('Not implemented'));
});
}

Object.defineProperty(exports, '__esModule', {
value: true
});
exports.default = routes;

0 comments on commit 5191e1a

Please sign in to comment.