Skip to content

Commit

Permalink
CASPAR_HOST is not mandatory; use a fake Caspar if not set
Browse files Browse the repository at this point in the history
  • Loading branch information
toresbe committed Jul 6, 2023
1 parent e4af45f commit 40b861d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
8 changes: 3 additions & 5 deletions src/caspar/connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,15 @@ import { fakeCaspar } from "./mockCaspar.js";
import { log } from "../log.js";

const getConnection = () => {
if (CASPAR_HOST) {
return new CasparCG({
host: CASPAR_HOST,
});
} else {
if (!CASPAR_HOST) {
if (process.env["NODE_ENV"] === "production")
throw new Error("No CasparCG host configured");

log.warn("No CasparCG host configured, using fake connection");
return fakeCaspar;
}

return new CasparCG({ host: CASPAR_HOST });
};

export const connection = getConnection();
2 changes: 1 addition & 1 deletion src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const requireEnv = (envName: string, defaultValue?: string): string => {
export const GRAPHICS_URL = requireEnv("GRAPHICS_URL");
export const FK_API = process.env["FK_API"];
export const CASPAR_MEDIA_URL_PREFIX = requireEnv("CASPAR_MEDIA_URL_PREFIX");
export const CASPAR_HOST = requireEnv("CASPAR_HOST");
export const CASPAR_HOST = process.env["CASPAR_HOST"];

export const CHANNEL_FPS = 50 as const;

Expand Down

0 comments on commit 40b861d

Please sign in to comment.