Compare commits

...

2 Commits

Author SHA1 Message Date
79e50ced0d Add README 2025-07-06 17:32:43 +02:00
4de14b250d Configure webdir using environment variable 2025-07-06 17:26:59 +02:00
2 changed files with 29 additions and 3 deletions

25
README.md Normal file
View File

@@ -0,0 +1,25 @@
# Traveldrafter
Keep track over multiple different connections while traveling trains.
## Run
```
nix run git+https://git.clerie.de/clerie/traveldrafter.git
```
The web frontend is served under <https://localhost:3000/>.
In production you probably would want to serve dir `web` directory as the service root from a webserver like nginx directly and only proxy the `api` route to the application.
## Development
Pass the path to the directory of the frontend scripts as `WEBDIR` environemnt var.
```
git clone https://git.clerie.de/clerie/traveldrafter.git
cd traveldrafter
WEBDIR=web nix run
```

7
app.js
View File

@@ -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) {