From 4de14b250d8ca99a133e9e1bda6983119d6d2ae9 Mon Sep 17 00:00:00 2001 From: clerie Date: Sun, 6 Jul 2025 17:26:59 +0200 Subject: [PATCH] Configure webdir using environment variable --- app.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app.js b/app.js index 2e3c582..562ca88 100755 --- a/app.js +++ b/app.js @@ -8,9 +8,12 @@ import {profile as dbnavProfile} from 'db-vendo-client/p/dbnav/index.js'; import {mapRouteParsers} from 'db-vendo-client/lib/api-parsers.js'; import {createHafasRestApi as createApi} from 'hafas-rest-api'; +const webdir_from_module = path.join(path.dirname(fileURLToPath(import.meta.url)), 'web'); + const config = { hostname: process.env.HOSTNAME || 'localhost', port: process.env.PORT ? parseInt(process.env.PORT) : 3000, + webdir: process.env.WEBDIR || webdir_from_module, name: 'db-vendo-client', description: 'db-vendo-client', homepage: 'https://github.com/public-transport/db-vendo-client', @@ -26,8 +29,6 @@ const config = { }; const start = async () => { - const webdir = path.join(path.dirname(fileURLToPath(import.meta.url)), 'web'); - const app = express(); const vendo = createClient( @@ -38,7 +39,7 @@ const start = async () => { const api = await createApi(vendo, config); app.use("/api", api); - app.use('/', express.static(webdir)); + app.use('/', express.static(config.webdir)); app.listen(config.port, (err) => { if (err) {