You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
23 lines
650 B
23 lines
650 B
interface RuntimeRepository {
|
|
openWebsocket(): WebSocket
|
|
}
|
|
|
|
export default function runtimeRepo(): RuntimeRepository {
|
|
switch (import.meta.env.VITE_MODE) {
|
|
case "webapp":
|
|
const port = window.location.port !== "5173" ? window.location.port : "8080";
|
|
return makeRuntimeRepo(`${window.location.hostname}:${port}`);
|
|
case "chrome-plugin":
|
|
return makeRuntimeRepo("127.0.0.1:9999");
|
|
default:
|
|
throw new Error("Not implemented");
|
|
}
|
|
}
|
|
|
|
function makeRuntimeRepo(host: string): RuntimeRepository {
|
|
return {
|
|
openWebsocket(): WebSocket {
|
|
return new WebSocket(`ws://${host}/api/workouts/active`);
|
|
},
|
|
};
|
|
}
|