This repository has been archived by the owner on Jun 7, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2421871
commit 2fafc3b
Showing
15 changed files
with
2,209 additions
and
434 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,28 +1,10 @@ | ||
import express from "express"; | ||
import { fromNodeRequest } from "@borderless/site/node"; | ||
import { createHandler } from "@borderless/site/adapters/node"; | ||
import { server } from "./dist/server/server.js"; | ||
|
||
const app = express(); | ||
|
||
app.use(express.static("dist/client")); | ||
|
||
app.get("*", async (req, res, next) => { | ||
try { | ||
const response = await server(fromNodeRequest(req), {}); | ||
|
||
for (const [key, value] of response.headers.entries()) { | ||
res.setHeader(key, value); | ||
} | ||
|
||
if (typeof response.body === "object") { | ||
const stream = await response.body.nodeStream(); | ||
stream.pipe(res); | ||
} else { | ||
res.end(response.body); | ||
} | ||
} catch (err) { | ||
next(err); | ||
} | ||
}); | ||
app.use(createHandler(server, () => undefined)); | ||
|
||
app.listen(3000, () => console.log(`Server running at http://localhost:3000`)); |
Oops, something went wrong.