- Install node package manger (npm)
- Visual studio code (Optional - for visualizing SQLite database)
- SQLite Visual Studio Code Extension (Required if using Vscode to visualize database);
- Install Docker
- Clone repository to desired location
- Change directory into the project folder (i.e andrews-kangah)
- Make sure docker is running
- Run
docker-compose up
to start docker build and bring application up - You can also run
docker-compose up -d
to run application in background and rundocker ps
to see the process - Make requests to BASE_URL
- Change directory to project foler (i.e andrews-kangah)
- Make sure docker is running
- Run
docker build -t drones:latest .
to build latest image
- Change directory to project folder (i.e andrews-kangah)
- Run
npm install
to install dependencies - Run
npm run test
to run tests
-
api/v1/register: Registers a new drone in the fleet
-
serialNumber
: Serial number of drone e.g DRONE1model
: Drone model (Lightweight, Middleweight, Cruiserweight, Heavyweight)state
: Drone state (IDLE, LOADING, LOADED, DELIVERING, DELIVERED, RETURNING)weightLimit
: Maximum carrying weight of dronebatteryPercentage
: Current battery percent of drone
-
POST
-
-
api/v1/load: Loads specified medications onto specified drone
-
droneSerialNumber
: Serial number of drone to load e.g DRONE1medicationsNames
: List of medicine names to load onto drone e.g [Penycillin]
-
POST
-
-
api/v1/cargo: Returns a list of medications loaded on a specified drone
-
droneSerialNumber
: Serial of number of drone to get loaded medicatioins e.g DRONE1
-
GET
-
-
api/v1/available: Returns a list of available drones i.e drones in IDLE/LOADING state. Drones set in LOADING state by some other user can also be loaded by other users (Assumed design spec).
-
droneSerialNumber
: Serial of number of drone to get loaded medicatioins e.g DRONE1
-
GET
-
-
api/v1/battery: Returns the current battery percentage of specified drone
-
droneSerialNumber
: Serial of number of drone to get loaded medicatioins e.g DRONE1
-
GET
-
-
api/v1/dispatch: Sets specified drone's status to
LOADED
. Drones in loaded state are picked up by background simulation worker and simulated to deliver medications and return with battery status dropping. Drones in IDLE state get battery charged back to 100%-
droneSerialNumber
: Serial of number of drone to dispatch e.g DRONE1
-
POST
-
-
api/v1/medication/all: Returns all medications in database
-
GET
-
api/v1/drone/logs: Returns audit logs of drones. Audit logs are logs of drone status changes, drone battery changes and medicatioins carried on drones. Drones in
IDLE
orLOADING
state are not logged to reduce unnecessary loggin. AuditLog background worker generates these logs-
GET
-
api/v1/register: Registers a new drone in the fleet
-
name
: Name of medication (allowed only letters, numbers, ‘-‘, ‘_’) e.g Amoxicillinweight
: Weight of medication. Note: medication cannot weigh more than 500code
: Medication code (allowed only upper case letters, underscore and numbers) e.g AMOXI_9image
: Image of medication. (Appropriate image handler not implemented so set please setnull
)
-
POST
-
- Better error Handling at database wrapper
- Background workers run every 3 minutes for simulation and every 4 minutes for audit logs.
- If logs do not show at the start, retry after some few minutes.
- Alternatively, modify
SIMULATION_INTERVAL
andAUDIT_LOG_INTERVAL
in code to speed things up. - But also make sure
AUDIT_LOG_INTERVAL
is just a little slower thanSIMULATION_INTERVAL
as audit logs pickup after simulation chanages.