Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed static configuration variable #204

Merged
merged 2 commits into from
Dec 22, 2023
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
4 changes: 2 additions & 2 deletions packages/backend/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { setupServer } from "./setupServer";
import { logger } from "@shared/logger";
import dotenv from "dotenv";
import { configuration } from "@shared/configuration";
import { getConfiguration } from "@shared/configuration";

dotenv.config();

const serverPort = configuration.backendUrl.port;
const serverPort = getConfiguration().backendUrl.port;

const server = setupServer();

Expand Down
4 changes: 2 additions & 2 deletions packages/backend/src/setupServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import cors, { CorsOptions } from "cors";
import { ClientToServerEvents, ServerToClientEvents } from "@shared/socket";
import { ConnectionStore } from "./store/ConnectionStore";
import { logger } from "@shared/logger";
import { configuration } from "@shared/configuration";
import { getConfiguration } from "@shared/configuration";

export function setupServer() {
const app = express();
Expand All @@ -15,7 +15,7 @@ export function setupServer() {
const connectionStore = new ConnectionStore();

const corsOptions: CorsOptions = {
origin: configuration.corsOrigins,
origin: getConfiguration().corsOrigins,
};

const io = new Server<ClientToServerEvents, ServerToClientEvents>(server, {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { GetServerSideProps } from "next";
import { ApplicationConfiguration, configuration } from "@shared/configuration";
import { ApplicationConfiguration, getConfiguration } from "@shared/configuration";

export interface GlobalGetServerSideProps {
configuration: ApplicationConfiguration;
Expand All @@ -8,6 +8,6 @@ export interface GlobalGetServerSideProps {
export const globalGetServerSideProps: GetServerSideProps<{
configuration: ApplicationConfiguration;
}> = async () => {
const parsedConfiguration = JSON.parse(JSON.stringify(configuration));
const parsedConfiguration = JSON.parse(JSON.stringify(getConfiguration()));
return { props: { configuration: parsedConfiguration } };
};
4 changes: 2 additions & 2 deletions packages/frontend/src/pages/api/config.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import type { NextApiRequest, NextApiResponse } from "next";
import { ApplicationConfiguration, configuration } from "@shared/configuration";
import { ApplicationConfiguration, getConfiguration } from "@shared/configuration";

export default function handler(
request: NextApiRequest,
response: NextApiResponse<ApplicationConfiguration>
) {
response.status(200).json(configuration);
response.status(200).json(getConfiguration());
}
1 change: 0 additions & 1 deletion packages/shared/configuration/src/configuration.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { ApplicationConfiguration, CorsOrigins, IceServerConfiguration, LogLevel } from "./types";
import { RetroAppUrl } from "./RetroAppUrl";
export const configuration = getConfiguration();

export function getConfiguration(): ApplicationConfiguration {
const backendUrl = new RetroAppUrl({
Expand Down
4 changes: 2 additions & 2 deletions packages/shared/logger/src/logger.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { createLogger as createWinstonLogger, format, transports } from "winston";
import { configuration } from "@shared/configuration";
import { getConfiguration } from "@shared/configuration";

const loggerFormat = format.combine(
format.timestamp({
Expand All @@ -11,7 +11,7 @@ const loggerFormat = format.combine(
);

export const logger = createLogger({
logLevel: configuration.logLevel,
logLevel: getConfiguration().logLevel,
});

export function createLogger({ withConsolePipe = true, logLevel }: CreateLoggerOptions) {
Expand Down
4 changes: 2 additions & 2 deletions packages/signaling/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import dotenv from "dotenv";
import { configuration } from "@shared/configuration";
import { getConfiguration } from "@shared/configuration";
import { spawn } from "child_process";
import { logger } from "@shared/logger";

dotenv.config();

const signalingServerPort = configuration.signalingServerUrl.port;
const signalingServerPort = getConfiguration().signalingServerUrl.port;

const peerServer = spawn("peerjs", ["--port", String(signalingServerPort)]);

Expand Down