generated from forge42dev/open-source-stack
-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
π¦ NEW: You can now use a custom node server (#14)
* π¦ NEW: You can now use a custom node server * π DOC: add example
- Loading branch information
Showing
5 changed files
with
101 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,42 @@ | ||
import { createSecureServer } from "node:http2"; | ||
import mkcert from "mkcert"; | ||
import { createHonoServer } from "react-router-hono-server/node"; | ||
|
||
import { exampleMiddleware } from "./middleware"; | ||
|
||
const getSSLConfig = async () => { | ||
const ca = await mkcert.createCA({ | ||
organization: "Development CA", | ||
countryCode: "US", | ||
state: "California", | ||
locality: "San Francisco", | ||
validity: 365, | ||
}); | ||
|
||
const cert = await mkcert.createCert({ | ||
domains: ["127.0.0.1", "localhost"], | ||
validity: 365, | ||
ca: { key: ca.key, cert: ca.cert }, | ||
}); | ||
|
||
return { cert: cert.cert, key: cert.key }; | ||
}; | ||
|
||
const cert = await getSSLConfig(); | ||
|
||
export const server = await createHonoServer({ | ||
buildDirectory: "dist", | ||
configure(server) { | ||
server.use("*", exampleMiddleware()); | ||
}, | ||
listeningListener(info) { | ||
console.log(`Server is listening on http://localhost:${info.port}`); | ||
console.log(`Server is listening on https://localhost:${info.port}`); | ||
}, | ||
customNodeServer: { | ||
createServer: createSecureServer, | ||
serverOptions: { | ||
cert: cert.cert, | ||
key: cert.key, | ||
}, | ||
}, | ||
}); |
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