-
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.
Merge pull request #2 from BunnyWay/misc-update-description
Update description & remove sleep
- Loading branch information
Showing
3 changed files
with
28 additions
and
12 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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"es-return-json": patch | ||
--- | ||
|
||
Remove the useless sleep on request |
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,18 +1,13 @@ | ||
import * as BunnySDK from "https://esm.sh/@bunny.net/[email protected]"; | ||
import sample from "../assets/sample.json" with { type: "json" }; | ||
|
||
function sleep(ms: number): Promise<void> { | ||
return new Promise((resolve) => setTimeout(resolve, ms)); | ||
} | ||
|
||
console.log("Starting server..."); | ||
const listener = BunnySDK.net.tcp.unstable_new(); | ||
|
||
console.log("Listening on: ", BunnySDK.net.tcp.toString(listener)); | ||
BunnySDK.net.http.serve( | ||
async (req) => { | ||
(req: Request): Response | Promise<Response> => { | ||
console.log(`[INFO]: ${req.method} - ${req.url}`); | ||
await sleep(1); | ||
const json = JSON.stringify(sample); | ||
return new Response(json, { | ||
headers: { | ||
|