-
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: bring uwebsockets adapter back to working order (#117)
- Loading branch information
Showing
7 changed files
with
71 additions
and
129 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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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,14 +1,23 @@ | ||
// @ts-check | ||
import { createServer } from "@hattip/adapter-uwebsockets"; | ||
import { createServer } from "@hattip/adapter-uwebsockets/native-fetch"; | ||
import { walk } from "@hattip/walk"; | ||
import handler from "./index.js"; | ||
import { createStaticMiddleware } from "@hattip/static"; | ||
import { createFileReader } from "@hattip/static/fs"; | ||
|
||
createServer(handler, { | ||
staticDir: "./public", | ||
}).listen(3000, (success) => { | ||
if (!success) { | ||
console.error("Failed to listen on port 3000"); | ||
process.exit(1); | ||
} | ||
const root = new URL("./public", import.meta.url); | ||
const files = walk(root); | ||
const reader = createFileReader(root); | ||
const staticMiddleware = createStaticMiddleware(files, reader); | ||
|
||
console.log("Server listening on http://127.0.0.1:3000"); | ||
}); | ||
createServer((ctx) => staticMiddleware(ctx) || handler(ctx)).listen( | ||
3000, | ||
(success) => { | ||
if (!success) { | ||
console.error("Failed to listen on port 3000"); | ||
process.exit(1); | ||
} | ||
|
||
console.log("Server listening on http://127.0.0.1:3000"); | ||
}, | ||
); |
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