Skip to content

Commit

Permalink
SOF-2202 Able to set REST port by env variable
Browse files Browse the repository at this point in the history
  • Loading branch information
LindvedKrvang committed Sep 10, 2024
1 parent 55702d0 commit 5859644
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions packages/playout-gateway/src/connector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { InfluxConfig } from './influxdb'
import { PeripheralDeviceId } from '@sofie-automation/shared-lib/dist/core/model/Ids'
import * as Koa from 'koa'
import * as KoaRouter from 'koa-router'
import * as process from 'node:process'

export interface Config {
process: ProcessConfig
Expand Down Expand Up @@ -101,11 +102,14 @@ export class Connector {
this.setupDevicesMakeReadyEndpoint(koaRouter)
this.setupDevicesStandDownEndpoint(koaRouter)

const port: number = 3009
const koaApp: Koa = new Koa()

koaApp.use(koaRouter.routes()).use(koaRouter.allowedMethods())
koaApp.listen(port, () => {})
koaApp.listen(this.getRestPort(), () => {})
}

private getRestPort(): number {
const envPort: number = parseInt(process.env.REST_PORT ?? '')
return isNaN(envPort) ? 3009 : envPort
}

/* eslint-disable @typescript-eslint/prefer-as-const */
Expand Down

0 comments on commit 5859644

Please sign in to comment.