Configure webdir using environment variable
This commit is contained in:
7
app.js
7
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) {
|
||||
|
Reference in New Issue
Block a user