Add domain config

This commit is contained in:
tedspare
2024-03-19 22:27:58 -04:00
parent 60b3960f52
commit ba1b5ec6a1
2 changed files with 10 additions and 5 deletions
+7 -4
View File
@@ -1,8 +1,7 @@
import { parseArgs } from "util";
const serverUrl = `ws://localhost:1234?new`;
async function main({ url }: { url: string }) {
async function main({ url, domain }: { url: string; domain?: string }) {
const serverUrl = `ws://${domain || "localhost:1234"}?new`;
const socket = new WebSocket(serverUrl);
socket.addEventListener("message", (event) => {
@@ -35,9 +34,13 @@ const { values } = parseArgs({
required: true,
short: "p",
},
domain: {
type: "string",
short: "d",
},
},
allowPositionals: true,
});
if (!values.port) throw "pass --port 3000";
main({ url: `localhost:${values.port}` });
main({ url: `localhost:${values.port}`, domain: values.domain });