Skip to content

Commit

Permalink
chore: update playground
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed Feb 24, 2024
1 parent 4e82c55 commit ced76fa
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion examples/h3/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createApp, createRouter } from "h3";
import { createApp } from "h3";
import { defineWebSocketHooks } from "crossws";

export const app = createApp();
Expand Down
2 changes: 1 addition & 1 deletion examples/h3/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ <h3>WebSocket Test Page</h3>
<br />
</div>

<div id="logs"></div>
<pre id="logs"></pre>

<script type="module">
const url = "ws://" + location.host + "/_ws";
Expand Down
6 changes: 4 additions & 2 deletions playground/_shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ import {
defineWebSocketHooks,
} from "../src/index.ts";

export const getIndexHTML = (params) =>
import("../examples/h3/index.html.ts").then((r) => r.html(params));
export const getIndexHTML = () =>
fetch(
"https://raw.githubusercontent.com/unjs/crossws/main/examples/h3/public/index.html",
).then((res) => res.text());

export function createDemo<T extends WebSocketAdapter>(
adapter: T,
Expand Down
2 changes: 1 addition & 1 deletion playground/node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const adapter = createDemo(nodeAdapter);

const server = createServer(async (req, res) => {
res.writeHead(200, { "Content-Type": "text/html" });
res.end(await getIndexHTML({ name: "node-ws" }));
res.end(await getIndexHTML());
});

server.on("upgrade", adapter.handleUpgrade);
Expand Down

0 comments on commit ced76fa

Please sign in to comment.