Skip to content

Commit

Permalink
use @tomphttp/bare-server-node in dev server
Browse files Browse the repository at this point in the history
  • Loading branch information
e9x committed Sep 25, 2022
1 parent a94db6c commit 3599406
Show file tree
Hide file tree
Showing 3 changed files with 97 additions and 0 deletions.
75 changes: 75 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"@testing-library/jest-dom": "^5.16.5",
"@testing-library/react": "^13.4.0",
"@testing-library/user-event": "^13.5.0",
"@tomphttp/bare-server-node": "^1.1.0",
"eslint": "^8.23.1",
"prettier": "^2.7.1",
"react": "^18.2.0",
Expand Down
21 changes: 21 additions & 0 deletions src/setupProxy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/**
*
* @param {import('express').Express} app
*/
function setupProxy(app) {
try {
const bareServer = import("@tomphttp/bare-server-node").then(
({ default: createBareServer }) => createBareServer("/bare/")
);

app.use(async (req, res, next) => {
if ((await bareServer).shouldRoute(req)) {
(await bareServer).routeRequest(req, res);
} else next();
});
} catch (e) {
console.error(e);
}
}

module.exports = setupProxy;

0 comments on commit 3599406

Please sign in to comment.