Skip to content

Commit

Permalink
fix: conditional default export
Browse files Browse the repository at this point in the history
  • Loading branch information
svedova committed Nov 17, 2022
1 parent bf5c78a commit aa78b14
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/utils/callbacks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ export const handleApi = (
const file = matchPath(cachedFiles, requestPath, req.method);

if (file) {
return require(path.join(file.path, file.name)).default(req, res);
const mod = require(path.join(file.path, file.name));
return mod.default ? mod.default(req, res) : mod(req, res);
}

res.writeHead(404, "Not found");
Expand Down

0 comments on commit aa78b14

Please sign in to comment.