Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"version": "1.0.0",
"description": "",
"main": "index.js",
"type": "module",
"scripts": {
"dev": "vite",
"build": "vite build"
Expand Down
4 changes: 3 additions & 1 deletion app/src/services/ObsClient.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import { getEnvOrThrow } from '../utils/env';

class ObsClient {
private client: WebSocket;
private connected: boolean = false;

constructor() {
console.log('ObsClient constructor');
this.client = new WebSocket('ws://bc.talpa-world.com:4455');
this.client = new WebSocket(getEnvOrThrow('VITE_OBS_WEBSOCKET_URL'));

this.client.onopen = () => {
console.log('ObsClient connected');
Expand Down
5 changes: 5 additions & 0 deletions app/src/utils/env.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export const getEnvOrThrow = (key: string): string => {
const value = import.meta.env[key];
if (!value) throw new Error(`Missing environment variable: ${key}`);
return value;
};
5 changes: 3 additions & 2 deletions app/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
"compilerOptions": {
"esModuleInterop": true,
"jsx": "react",
"module": "NodeNext",
"module": "ESNext",
"moduleResolution": "Node",
"target": "ESNext"
"target": "ESNext",
"types": ["vite/client"]
}
}
4 changes: 4 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,16 @@ services:
- ./server/assets:/app/assets:rw
ports:
- "3000:3000"
environment:
- OBS_WEBSOCKET_URL=ws://bc.talpa-world.com:4455
front:
build:
context: app
dockerfile: Dockerfile
container_name: front
ports:
- "5173:5173"
environment:
- VITE_OBS_WEBSOCKET_URL=ws://bc.talpa-world.com:4455
depends_on:
- api
3 changes: 2 additions & 1 deletion server/src/services/ObsClient.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import WebSocket from "ws";
import { getEnvOrThrow } from "../utils/env";

class ObsClient {
public client: WebSocket;
Expand All @@ -7,7 +8,7 @@ class ObsClient {
async connect(): Promise<void> {
console.log("ObsClient connecting...");
return new Promise<void>((resolve, reject) => {
this.client = new WebSocket("ws://bc.talpa-world.com:4455");
this.client = new WebSocket(getEnvOrThrow("OBS_WEBSOCKET_URL"));

this.client.onopen = () => {
console.log("ObsClient connected");
Expand Down
5 changes: 5 additions & 0 deletions server/src/utils/env.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export const getEnvOrThrow = (key: string): string => {
const value = process.env[key];
if (!value) throw new Error(`Missing environment variable: ${key}`);
return value;
};