-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: adding bun serve and removing http-server
- Loading branch information
1 parent
ee38a8d
commit a74c48b
Showing
10 changed files
with
22 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export const playwrightConstants = { | ||
host: `http://localhost:${process.env.SERVER_PORT || 8080}/index.html`, | ||
}; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,18 @@ | ||
import type { MatchedRoute } from "bun"; | ||
import { file } from "bun"; | ||
|
||
const PORT = process.env.SERVER_PORT || 8080; | ||
const router = new Bun.FileSystemRouter({ | ||
style: "nextjs", | ||
dir: "./dist/", | ||
}); | ||
|
||
Bun.serve({ | ||
fetch(req) { | ||
const match = router.match(req) as MatchedRoute; | ||
const page = require(match.filePath); | ||
return new page(req, match.query, match.params); | ||
const url = new URL(req.url); | ||
const pathname = url.pathname === "/" ? "/index.html" : url.pathname; | ||
const filePath = `./dist${pathname}`; | ||
|
||
try { | ||
return new Response(file(filePath)); | ||
} catch (e) { | ||
return new Response("Not Found", { status: 404 }); | ||
} | ||
}, | ||
port: PORT, | ||
}); |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters