Last active
March 17, 2020 04:42
-
-
Save krismuniz/e8497684c3108d59bd5735958ba491a8 to your computer and use it in GitHub Desktop.
Minimal Deno server.
This file contains hidden or 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
| import { serve, ServerRequest, Server } from "https://deno.land/[email protected]/http/server.ts"; | |
| type Handler = (req: ServerRequest) => void | |
| export default async function (port: number, handler: Handler) { | |
| const s: Server = serve({ port }); | |
| for await (const req of s) { | |
| handler(req) | |
| } | |
| return s | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment