Skip to content

Commit

Permalink
feature: Better handling of missing environment variables in setupPro…
Browse files Browse the repository at this point in the history
…xy.js file. (#2956)

Signed-off-by: Artur Owczarek <[email protected]>
  • Loading branch information
arturowczarek authored Oct 28, 2024
1 parent 9e2e9b4 commit 2d163ce
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions web/setupProxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,23 @@ const { createProxyMiddleware } = require('http-proxy-middleware');
const express = require('express')
const router = express.Router()

const environmentVariable = (variableName) => {
const value = process.env[variableName]
if (!value) {
console.error(`Error: ${variableName} environment variable is not defined.`)
console.error(`Please set ${variableName} and restart the application.`)
process.exit(1)
}
return value
}

const apiOptions = {
target: `http://${process.env.MARQUEZ_HOST}:${process.env.MARQUEZ_PORT}/`
target: `http://${(environmentVariable("MARQUEZ_HOST"))}:${environmentVariable("MARQUEZ_PORT")}/`
}
const app = express()
const path = __dirname + '/dist'

const port = process.env.WEB_PORT
const port = environmentVariable("WEB_PORT")

app.use('/', express.static(path))
app.use('/datasets', express.static(path))
Expand Down

0 comments on commit 2d163ce

Please sign in to comment.