From 008f30ac3879ef55e109fa2d565ab73756daa8aa Mon Sep 17 00:00:00 2001 From: Ben Fletcher Date: Tue, 13 Feb 2024 20:16:51 +0000 Subject: [PATCH] Added local guide --- RUNNING_LOCALLY.md | 67 ++++++++++++++++++++++++++++++++++++++++++++++ docker-compose.yml | 4 +-- 2 files changed, 69 insertions(+), 2 deletions(-) create mode 100644 RUNNING_LOCALLY.md diff --git a/RUNNING_LOCALLY.md b/RUNNING_LOCALLY.md new file mode 100644 index 00000000..b3824bf0 --- /dev/null +++ b/RUNNING_LOCALLY.md @@ -0,0 +1,67 @@ +# How to run the code locally + +Please ensure you have cloned/downloaded the repo locally. + +## Docker + +Within the docker-compose.yml file please add in a real times trains token. More information on getting this can be found below. + +You can build and run the site within docker using the following commands +```bash +docker-compose build +docker-compose up -d +``` + +this will run the website on port 9005 + +### Adding configurations + +You will need to add a config.xml file to this folder. This file can contain the following: + +```xml + + some-rather-long-string + + emailaddress + password + some-guid-token + + some-long-string + + +``` + +For docker you should edit the docker-compose.yml file and uncomment (remove hashes`#`) the following lines: + +```yaml +# volumes: +# - ./config.xml:/config.xml +``` + +This will mount the config.xml file into the docker container. + +## API Key Setup + +### Real Time Trains + +1. Go to [Real Time Trains](https://api.rtt.io/) and sign up for an account +2. Within the home page you should have a Username and Password listed. You will need to convert these into a token +3. You can use a website such as to convert the username and password into a token.
+You can do this by encoding the following format: `username:password` using the suggested website or alternative base64 encoding tool. + +### National Rail +Confusingly the National Rail API is 2 separate APIs. The first is the Knowledge api, which is used to get the station codes. The second is the Darwin API, which is used to get the departure board information. + +#### Knowledge API +> Used for getting the list of all the stations and their codes +> [More Info](https://www.nationalrail.co.uk/developers/knowledgebase-data-feeds/) +1. Go to [National Rail](https://opendata.nationalrail.co.uk/) and sign up for an account +2. Once you have an account you will need to subscribe to the Knowledge API. This can be done by going to Account -> Edit Details and then ensuring Knowledge API is ticked. +3. The username and password you used to create the account can then be added into the config.xml file (As seen above). + +#### Darwin API +> Used for getting live departure data when user has selected National Rail +> [More Info](https://www.nationalrail.co.uk/developers/darwin-data-feeds/) + +1. You will need to register an application with national rail in order to get an access token. This can be done by going to +2. Once your application is accepted then you should be emailed an access token. This can then be added into the config.xml file (As seen above). \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index e893f8e8..8ba9f29f 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -10,5 +10,5 @@ services: image: departure-board:latest ports: - "9005:80" - volumes: - - ./config.xml:/config.xml \ No newline at end of file +# volumes: +# - ./config.xml:/config.xml \ No newline at end of file