BRAWNDO is a workout journal for the connected age. Schedule future workouts, review past workouts, and even bring STRONGR into the gym with you to track your performance on every exercise in your routine.
- Building Locally
- Deploying
- Config Variables
- User Routes
- Progress Routes
- Routine Routes
- Exercise Routes
- Workout Routes
- Performance Routes
The repo contains two main directories: server
and client
. You will need to build each to run the app for local development. Commands for each directory assume you start at the route of that directory.
Server:
npm install && npm start
Client:
npm install && npm start
The standard method for deploying the app is Zeit's Now service, and the package.json
s in each main directory provide now-start
scripts for automatic deploy configuration. Note that the dotenv
code in the repo requires that for the backend/server, either the config vars be set through the Now app or CLI, or that a .env
be included with the deploy through the --dotenv
flag.
A daily deploy is currently being maintained at strongr.tech
(and strongr-server.tech
for the back-end).
USERNAME should be a username for an mLab database.
PASSWORD should correspond to USERNAME
SECRET is an arbitrary string, used to sign JWTs.
SENDGRID_API_KEY is used to send password recovery emails through Sendgrid
MAILER_EMAIL_ID is the SendGrid mailer ID, which will determine the email address those emails are sent from.
STRIPE_API_KEY_TEST is the test key used to process payments though Stripe (there will be a STRIPE_API_KEY) for production
-
/register
- POST
{ username, password, email }
- Creates a new User document and responds with its token.
Request:
{ "username": "exampleuser", "password": "examplepass", "email": "[email protected]" }
- POST
-
/login
- POST
{ username, password }
- Searches for a User document and responds with its token if one is found.
Request:
{ "username": "exampleuser", "password": "examplepass" }
- POST
-
/forgot_password
- POST
{ email }
- Uses SendGrid to send a password recovery email with a unique token for request verification.
Request:
{ "email": "[email protected]" }
- POST
-
/reset_password
- POST
{ token, newPassword, confirmNewPassword }
- Finds the user with the provided reset token and update their password.
Request:
{ "newPassword":"newexamplepass", "confirmNewPassword": "newexamplepass", "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYW1lIjoiYXFjdXMiLCJpYXQiOjE1MzY5NDIyNzYsImV4cCI6MTUzNjk0NDA3Nn0._EHg-GGv_z7RsXZCwInDBUM0ZgZSHUZ_jw6hQmi-TRM" }
- POST
-
/auto-login
- GET
- No request body, but route requires a valid JWT in the "x-access-token" header.
- Checks a provided token for validity, responding with the token and an OK status if the token is good. For an example of usage, see the
AccessControl
component.
- GET
-
/settings_password
- POST
{ username, password, newPassword, confirmNewPassword }
- Searches for the user via the username, if the provided current password is correct, the password will be changed.
Request:
{ "username": "exampleuser", "password": "examplepass", "newPassword": "newexamplepass", "confirmNewPassword": "newexamplepass" }
- POST
-
/settings_email
-
POST
{ username, newEmail }
- Searches for the user with the provided username, then changes the email.
Request:
{ "username": "exampleuser", "newEmail": "[email protected]" }
-
-
/charge
- POST
{ id, token }
- Uses Stripe to process a payment
- Changes the user status of premiumUser from false to true.
- The token is generated on the client side via a Stripe function
createToken
- For more information on using Stripe with React and Express visit the Stripe Docs
Request:
{ "id": "5bb7652a75d9aa8b8805046d", "token": "tokenGeneratedFromStripe" }
- POST
-
/progress
-
POST
{ weight, hips, waist, r_arm, l_arm, r_leg, l_leg, user }
- Add a progress entry to the User's history.
Request:
{ "weight": 180, "hips": 40, "waist": 40, "r_arm": 15, "l_arm": 15, "r_leg": 20, "l_leg": 20, "user": "5bb7652a75d9aa8b8805046d" }
- GET
- Retrieves a User's progress history.
-
-
/progress/:id
-
PUT
{ weight, hips, waist, r_arm, l_arm, r_leg, l_leg, user }
- Finds the progress document by id and updates it.
Request:
{ "weight": 160, "hips": 40, "waist": 40, "r_arm": 15, "l_arm": 15, "r_leg": 20, "l_leg": 20, "user": "5bb7652a75d9aa8b8805046d" }
- DELETE
- Finds the progress by id and deletes it from the Progress Collection and deletes the corresponding reference in the User collection.
-
-
/new-routine
- POST
{ title }
- Creates a new Routine for a User, i.e. "Arm Day"
Request:
{ "title": "Arm Day" }
- POST
-
/routine
-
GET
{ routineId }
- Retrieves a routine document by the given id.
Request:
{ "routineId": "5bb773923fc6b98e25713139" }
-
PUT
{ routineId, title }
- Returns the document with the update applied.
Request:
{ "title": "Get Ripped", "routineId": "5bb773923fc6b98e25713139" }
- DELETE
{ routineId }
- Finds the routine by id and deletes it from the Routine Collection and deletes the corresponding reference in the User collection.
Request:
{ "routineId": "5bb773923fc6b98e25713139" }
-
-
/routines
- GET
- Retrieves a list of the User's routines hydrated/populated with Exercise documents.
- GET
-
/routine-rich
- POST
{ routineId }
- Retrieves a routine by the routine id hydrated/populated with Excercise documents
Request:
{ "routineId": "5bb773923fc6b98e25713139" }
- POST
-
/new-exercise
- POST
{ name, currentWeight, currentReps, currentSets }
currentWeight
default:10
, optionalcurrentReps
default:5
, optionalcurrentSets
default:3
, optional- Creates a new Exercise for a User, i.e. "Bench Press"
Request:
{ "name": "Bench Press" }
- POST
-
/add-exercise
- POST
{ routineId, exerciseId }
- Adds an Exercise to a particular Routine, i.e. add "2k Run" to "Cardio"
Request:
{ "routineId": "5bb773923fc6b98e25713139", "exerciseId": "5bb78b4ba2e99b92619b4d97" }
- POST
-
/exercise
-
GET
{ exerciseId }
- Retrieves an exercise by the exercise id
Request:
{ "exerciseId": "5bb78b4ba2e99b92619b4d97" }
-
PUT
{ exerciseId, name, currentWeight, currentReps, currentSets }
- Finds an exercise document by id and returns it with update applied
Request:
{ "exerciseId": "5bb78b4ba2e99b92619b4d97", "name": "Bench Press", "currentWeight": 5, "currentReps": 5, "currentSets": 5 }
- DELETE
{ exerciseId }
- Finds the exercise by id and deletes it from the Exercise Collection and deletes the corresponding reference in the User collection.
Request:
{ "exerciseId": "5bb78b4ba2e99b92619b4d97" }
-
-
/schedule-workout
- POST
{ routineId, userId, date, note }
note
, optional- Creates a new Workout with the provided date.
- Creates a new Performance of each Exercise referenced in the provided Routine, with the provided date.
- Each Performance document for a specific performance of an exercise is referenced in the document for the Workout. Each Performance document is also referenced in the corresponding Exercise document.
- Finally, the Workout document is referenced in the provided User document in the
calendar
property, providing an entry point to get from the User level to more specific records.
Request:
{ "routineId": "5bb78ff2a2e99b92619b4d98", "date": "2018-10-04T22:00:00.000Z" }
- POST
-
/fetch-workout
- POST
{ workoutId }
- Retrieves a workout by the workout id
Request:
{ "workoutId": "5bb7910aa2e99b92619b4d99" }
- POST
-
/workouts
- GET
- Retrieves a list of all workouts associated with the user id
- GET
-
/workouts/:id
- DELETE
- Finds the workout by id and deletes it from the Workout Collection and deletes the corresponding reference in the User collection and Routine collection
- DELETE
-
/workouts-copy
- POST
{ startDate, endDate, shiftDistance }
- Finds user by id and populates calendar workouts
- Filters calendar entries from the start and end dates.
- For each workout in range schedules new workouts to the shiftDistance (milliseconds) selected which is turned into a new Date.
Request:
{ "startDate": "2018-10-03T22:00:00.000Z", "endDate": "2018-10-05T22:00:00.000Z", "shiftDistance": 604800000 }
- POST
-
/performance/:id
- PUT
- Toggles the completed property of the associated Performance document
- PUT
-
/performances
- GET
- Retrieves a list of all performances associated with the user id
- GET