diff --git a/demo/terminal/package-lock.json b/demo/terminal/package-lock.json index 32bf0a19..1196a220 100644 --- a/demo/terminal/package-lock.json +++ b/demo/terminal/package-lock.json @@ -8,7 +8,7 @@ "name": "vanjs-web-terminal", "version": "0.1.0", "devDependencies": { - "deno-bin": "^1.36.0", + "deno-bin": "^1.43.1", "vanjs-core": "^1.5.0" } }, @@ -22,40 +22,19 @@ } }, "node_modules/deno-bin": { - "version": "1.36.0", - "resolved": "https://registry.npmjs.org/deno-bin/-/deno-bin-1.36.0.tgz", - "integrity": "sha512-gJlrpILuliLlBTxM1Fo/304KI2lU/Nr/g0KZw6T7xhfG01BKTwUA+1amTg/m+8/4y2QnKwQC5tdHSuA9UllJJw==", + "version": "1.43.1", + "resolved": "https://registry.npmjs.org/deno-bin/-/deno-bin-1.43.1.tgz", + "integrity": "sha512-t9fnF9Q4p9wglc7NSPXjb53CZ0KKwFsZcl2thaJ+B1mXPLmdWve3o6Q5ZDRQ3v5AQiKkZJePPsZ9i71Qa+kfAQ==", "dev": true, "hasInstallScript": true, "dependencies": { - "adm-zip": "^0.5.4", - "follow-redirects": "^1.10.0" + "adm-zip": "^0.5.4" }, "bin": { "deno": "bin/deno.js", "deno-bin": "bin/deno.js" } }, - "node_modules/follow-redirects": { - "version": "1.15.2", - "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.2.tgz", - "integrity": "sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA==", - "dev": true, - "funding": [ - { - "type": "individual", - "url": "https://github.com/sponsors/RubenVerborgh" - } - ], - "engines": { - "node": ">=4.0" - }, - "peerDependenciesMeta": { - "debug": { - "optional": true - } - } - }, "node_modules/vanjs-core": { "version": "1.5.0", "resolved": "https://registry.npmjs.org/vanjs-core/-/vanjs-core-1.5.0.tgz", diff --git a/demo/terminal/package.json b/demo/terminal/package.json index 1fe91bcb..01049c64 100644 --- a/demo/terminal/package.json +++ b/demo/terminal/package.json @@ -7,7 +7,7 @@ "dev": "deno run --allow-net --allow-run --allow-read server.ts --allowRemote --skipLogin" }, "devDependencies": { - "deno-bin": "^1.36.0", + "deno-bin": "^1.43.1", "vanjs-core": "^1.5.0" } } diff --git a/demo/terminal/server.ts b/demo/terminal/server.ts index c5343c23..f727b319 100644 --- a/demo/terminal/server.ts +++ b/demo/terminal/server.ts @@ -47,8 +47,8 @@ const readFileOrError = async (path: string) => { } } -const serveHttp = async (conn: Deno.Conn, req: Request) => { - if (!flags.allowRemote && (conn.remoteAddr).hostname !== "127.0.0.1") +Deno.serve({port: Number(flags.port)}, async (req: Request, {remoteAddr}) => { + if (!flags.allowRemote && remoteAddr.hostname !== "127.0.0.1") return new Response( "Only local requests are allowed for security purposes", {status: 403}) const url = new URL(req.url) @@ -110,12 +110,7 @@ const serveHttp = async (conn: Deno.Conn, req: Request) => { } } return new Response("Unsupported HTTP method", {status: 404}) -} - -const serveConn = async (conn: Deno.Conn) => { - for await (const reqEvent of Deno.serveHttp(conn)) - (async () => reqEvent.respondWith(await serveHttp(conn, reqEvent.request)))() -} +}) console.log(`Visit http://localhost:${flags.port}/ in your browser`) if (!flags.skipLogin) { @@ -124,4 +119,3 @@ if (!flags.skipLogin) { console.log("%cFor security purposes, DO NOT share the key with anyone else", "color: red; font-weight: bold") } -for await (const conn of Deno.listen({port: Number(flags.port)})) serveConn(conn)