diff --git a/README.md b/README.md index 1baae88..824f3ae 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,29 @@ Alternatively, it is possible to use your own mysql database, and run the code l 4. Run `npm run build` to build the nestjs application 5. Run `npm run start:prod` to start the nestjs application +After starting the application will run on http://localhost:3000/ + +## Documentation + +The full endpoint documentation can be found on http://localhost:3000/api. +Here you can find which endpoints there are, and how to authenticate. + +### Authentication +For the Authentication I went with an base64 encoded authentication string consisting of 2 parts. +The first part is the ApiKey, which is stored in the authentication database. +The second part is a secret that is being used as a password. + +In the database we have stored 2 values, the ApiKey and a digest. +This digest is creating by using HMAC with the api secret as password, using a sha256 to hash the ApiKey. + +This way there is no full api key stored in the database. + +#### Demo example +In this demo you can use `eG5nVnZGaWtCMFN6NjRRaWQ2TUJsUTJWaDpjeGg1R3FKRUl0UTlzSGRQdElGMGg0bFJp` for the requests. + +This decodes to `xngVvFikB0Sz64Qid6MBlQ2Vh:cxh5GqJEItQ9sHdPtIF0h4lRi`. +The first part `xngVvFikB0Sz64Qid6MBlQ2Vh` is stored in the database, but the second part is not stored anywhere. + ## Receiving Tracking information When receiving Tracking information, the following steps need to be completed to process the data ```mermaid @@ -27,8 +50,7 @@ flowchart TD sendNotification[/Send notification\] - receiveTracking -- "` - **Tracking data** + receiveTracking -- "`**Tracking data** carrierName:**string** destinationUnLoCode:**string** departureDate:**string[_datetime_]** diff --git a/docker-compose.yml b/docker-compose.yml index 4edb992..63474bb 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,7 +2,7 @@ services: api: build: . ports: - - "3001:3000" + - "3000:3000" command: "npm run start:prod" depends_on: - database