Compare commits
2 Commits
53eed67dfc
...
79e50ced0d
Author | SHA1 | Date | |
---|---|---|---|
79e50ced0d | |||
4de14b250d |
25
README.md
Normal file
25
README.md
Normal 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
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