- Node.js (v8.12.0) server that supports the APIs.
- MongoDB (v3.4.18) the database layer.
- Docker as the container service to isolate the environment.
- Clone/Download the project
- Set Google Distance Matrix API key in .env file, key:
GOOGLE_API_KEY
- Execute the start.sh bash file via
./start.sh
to start the project. This will:- Start the docker environment. Internally within the docker environment it will:
- Build the Node.js image
- Download the mongo image
- Start the Node.js server
- After docker-compose has built and started the project, automated test cases will start running.
- Start the docker environment. Internally within the docker environment it will:
- Set the API key in .env file, key:
GOOGLE_API_KEY
- Clone/Download the project
- Run
docker-compose up
from terminal - APIs will be accessible at
http://localhost:8080/orders
- After starting the project with
docker-compose up
, run:- Interation tests:
docker exec -it app npm run e2e
- Unit tests:
docker exec -it app npm test
- Interation tests:
-
GET
/orders?page=:page&limit=:limit
: Fetch paginated orders- Response:
[ { distance: 1199398, status: "TAKEN", id: "5bebba7c1c2c2d001c3e92f3" }, { distance: 2000, status: "UNASSIGNED", id: "5bebba7c1c2c2d001c3e92f1" } ]
- Response:
-
POST
/orders
: Create a new order- Request:
{ origin: ["28.704060", "77.102493"], destination: ["28.535517", "77.391029"] }
- Response:
{ id: "5bebcf381c2c2d001c3e92f4", distance: 1071, status: "UNASSIGNED" }
- Request:
-
PATCH
/orders/:id
: Update the status of a particular order using it's id-
Request:
{ "status": "TAKEN" }
-
Response:
{ "status": "SUCCESS" }
-
/src/orders/config
- Includes the project specific constants and configurations.
/src/orders
- Separate orders folder to maintain modularity of code.
controllers
contains order related controllers to control basic flow of order related functionalitiesmodels
has the model definition of orders.services
has the service defintions for order management.order-routes
is what has the order specific routes
/src/shared/services
maps-client.js
has functionality for google map api.db-connection.js
contains functions for managing mongoose database connections.
/src/shared/utils
error-handler.js
contains functions for handling error routes, managing error logging, parsing error and sending error to the client.api-error.js
class that is used to throw the custom error throught the application
/e2e
- Has the automated integration tests which can be run to verify the project.
/app.js
- The initiator file, that starts the server and initiated all configurations.
- Swagger documentation can be found at
/swagger.yaml
- Linting configuration available at
/.eslintrc.