Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/torgeadelin/booking_go
BookingGo Technical Test
https://github.com/torgeadelin/booking_go
Last synced: 4 days ago
JSON representation
BookingGo Technical Test
- Host: GitHub
- URL: https://github.com/torgeadelin/booking_go
- Owner: torgeadelin
- Created: 2020-02-06T20:09:26.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2023-01-24T01:19:52.000Z (almost 2 years ago)
- Last Synced: 2024-10-31T07:34:03.915Z (about 2 months ago)
- Language: JavaScript
- Size: 864 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 13
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 🚕 BookingGo Techincal Test Submission
Command line application / script && simple REST API.
## 🛠 Build And Compile
- Install node if you don't have it already
- Clone the project using `git clone`
- Go to the project directory `cd booking_go`
- Run `npm install` in your terminal to install all dependencies
- Run `npm test` to run unit tests. Run `npm test -- --coverage` to check the coverage. You then can also open the test results by running `open coverage/lcov-report/index.html`##### 🔖 Note for `npm test`
The API seems to have a random behaviour and while testing the fetch functions one of the test might fail.
## 🏃 Run
### Part 1
1. To run the command line application use `node app.js {pickupLocation} {dropoffLocation} {minPassangers} {(optional)supplier}`
- `pickup` and `dropoff` have to be of the following format `latitude,longitude`. If you'd like to fetch data from a specific supplier add the {supplier} parameter as well.
- Available suppliers "**dave**", "**jeff**" or "**eric**". If no parameter is provided "**all**" will be used by default.2. The applcation will return the result and erros if there are any.
Example: `node app.js 51.470020,-0.454295 51.5112079,-0.1215334 3`
### Part 2
- To start a local server for the REST api run `node api.js`
- Open postman or your browser and make a GET request to `localhost:3000/endpoint` to test the API. The following endpoints are available| Endpoint | Query Parameters | Example Response |
| -------------------- | ----------------------------------------------------------------------- | ------------------------------------------------------------------------------------------- |
| `/fetchSupplier` | `{supplier: "string", pickup: "lat,lon", dropoff: "lat,lon", min: int}` | `{ "status": "unsuccessful/unsuccesfull" "code": 400, "value": "MINIBUS - dave - 145311" }` |
| `/fetchAllSuppliers` | `{pickup: "lat,lon", dropoff: "lat,lon", min: int}` | `{ "list": [...], "errors": [...]}` |Examples:
- `http://localhost:3000/fetchSupplier?supplier=dave&pickup=51.470020,-0.454295&dropoff=51.5112079,-0.1215334&min=3`
- `http://localhost:3000/fetchAllSuppliers?supplier=dave&pickup=51.470020,-0.454295&dropoff=51.5112079,-0.1215334&min=3`#### Implementation considerations
Part 1 has multiple tasks that build on top of each other, and therefore I created a single function that will allow to fetch all suppliers or just a specific one(including dave's).