This is the backend for the My Tab app. Front end code can be seen here.
The base url is https://my-tab-api.herokuapp.com/
.
GET /drinks
- Returns all drinks for the current user.
- Includes metadata about total number of standard drinks and average per day across the time period.
- Can receive optional query parameters of start and end date
POST /drinks
- Creates a drink record.
- Must include
oz
,percent
, andimbibed_on
JSON in request body.
DELETE /drinks/{id}
- Deletes a drink record.
- Only returns server errors, if any.
POST /signup
- Creates a user record.
- Must include
username
andpassword
JSON in request body. - Returns JWT token for user.
POST /login
- Finds user record by
username
andpassword
. - Returns JWT token for user.
- To access resources, include the following as the
Authorization
header:Bearer your-json-web-token
. - Drink resources are restricted to those that belong to the current user, as determined by the JWT.
-
One standard drink is 0.6 oz of pure alcohol - 12 oz at 5% ABV (beer), 5 oz at 12% (wine), or 1.5 oz at 40% (liquor) would all be one standard drink.
-
The
stddrink
library is a helper for determining standard drinks across time. The functions are model-agnostic, so can be used outside of this API. -
Public methods include:
Calculate
, determine number of standard drinks for a given oz/percent- 'StddrinksPerDay', given a time range and group of standard drinks (
float64
s), determine drinks per day TotalStdDrinks
, given a group of standard drinks (float64
s), determine the grand total.
If you wanted to run this locally, you'd need the following:
- Go
- RSA public & private keys.
- Postgresql. Create the
my_tab
database and add the tables included intables.sql
.
- More test coverage
MIT