Strada-copy-cat is a two endpoints REST API that can give you statistics on your runs.
The first endpoint (POST /addRun) lets you add one of your run to the system.
The second endpoint (GET /statsBetween) lets you get statistics about all the runs you made between a start_date and an end_date. If a run is not fully included in the interval, the run will still be counted, the number of kilometers and of calories will be interpolate linearly.
Endpoint | Method | Query | Return |
---|---|---|---|
/addRun | POST | start_date :: UnixEpoch, end_date :: UnixEpoch, kilo :: PositiveNumber, calo :: PositiveNumber | {id :: PositiveInteger} |
/statsBetween | GET | start_date :: UnixEpoch, end_date :: UnixEpoch | {average_kilo :: PositiveNumber, average_calo :: PositiveNumber} |
To test the api run :
yarn test
To run on your computer :
yarn start
To deploy, you will need to have git and docker and then to run :
make
This app is divided into three parts : Endpoints management and data validation (main-middleware.js), App logic (api.js and run.js), Database interface (mockup-db.js).
Each part can be mocked or replaced considering that the module interfaces and functionalities remain the same.