Project Objective: The weight lifting journal aims to give the users the ability to track, and monitor, their progress in the gym. Users can create an account, add workouts, and perform CRUD operations to view, add, edit, and delete exercises for each workout.
Group Trello Board: https://trello.com/b/X4AIenFs/weight-lifting-project
Technologies Used:
- Node.js
- Express.js
- Knex.js
- PostgreSQL
- JWT Authentication
BASE URL https://weight-lift-journal-dev.herokuapp.com/
- Attach endpoints to the end of the base URL in order to make HTTP Requests.
Endpoints that do not require authentication (Not Protected):
Requests | Endpoints |
---|---|
POST Registration | /api/auth/register |
POST Login | /api/auth/login |
Endpoints that DO require authentication (Protected):
Requests | Endpoints |
---|---|
GET Users | /api/users |
GET User By ID | /api/users/:id |
GET User By Username | /api/users/getby/:username |
GET User Profile With JWT | /api/users/profile |
GET User's workouts | /api/users/:id/workouts |
POST Add a workout to a user | /api/users/:id/workouts |
GET All workouts | /api/workouts |
GET Workout by ID | /api/workouts/:id |
PUT Edit a workout | /api/workouts/:id |
DELETE Delete a workout | /api/workouts/:id |
POST Add exercise to a workout | /api/workouts/:id/exercises |
PUT Edit a workout's exercise | /api/workouts/:workout_id/exercises/:id |
DELETE Delete a workout's exercise | /api/workouts/exercises/:id |
URL: https://weight-lift-journal-dev.herokuapp.com/api/auth/registration
Input (Case Sensitive) | Input Type |
---|---|
name (required) | string (4+ characters) |
password (required) | string (4+ characters) |
email (required) | string |
An example of how the body should appear:
{
"username": "exampleuser",
"password": "exampleuser",
"email": "exampleuser@gmail.com"
}
You will receive the user object an a JWT.
{
"user": {
"id": 5,
"username": "exampleuser",
"email": "exampleuser@gmail.com",
"created_at": "2019-11-18T16:09:18.017Z",
"updated_at": "2019-11-18T16:09:18.017Z"
},
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6ImV4YW1wbGV1c2VyIiwiaWF0IjoxNTc0MDkzMzU3LCJleHAiOjE1NzQxMjIxNTd9.hbL6AISkyQP6IF0PF6_VuUka3fsHLCCO3SfAhvw0AEw"
}
URL: https://weight-lift-journal-dev.herokuapp.com/api/auth/login
Input (Case Sensitive) | Input Type |
---|---|
name (required) | string (4+ characters) |
password (required) | string (4+ characters) |
An example of how the body should appear:
{
"username": "exampleuser",
"password": "exampleuser"
}
You will receive the user object, and a JWT.
{
"message": "Success! You are logged in!",
"user": {
"id": 6,
"username": "testdude",
"email": "testdude@gmail.com",
"created_at": "2019-11-19 20:28:57",
"updated_at": "2019-11-19 20:28:57",
"workouts": []
},
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6NiwidXNlcm5hbWUiOiJ0ZXN0ZHVkZSIsImlhdCI6MTU3NDE5NTM4OSwiZXhwIjoxNTc0MjgxNzg5fQ.Cf3CLHMwKIy_IMMifdCeDmo6t8DQM5kOBnPuHTyx70w"
}
URL: https://weight-lift-journal-dev.herokuapp.com/api/users
An array of all users within the database.
[
{
"id": 1,
"username": "test",
"email": "test@gmail.com",
"created_at": "2019-11-18T15:35:00.800Z",
"updated_at": "2019-11-18T15:35:00.800Z"
},
{
"id": 2,
"username": "clifford",
"email": "clifford@gmail.com",
"created_at": "2019-11-18T15:35:00.800Z",
"updated_at": "2019-11-18T15:35:00.800Z"
},
{
"id": 3,
"username": "testuser",
"email": "testuser@gmail.com",
"created_at": "2019-11-18T15:56:55.695Z",
"updated_at": "2019-11-18T15:56:55.695Z"
},
{
"id": 4,
"username": "yeeehaww",
"email": "yeehaww@gmail.com",
"created_at": "2019-11-18T16:06:19.693Z",
"updated_at": "2019-11-18T16:06:19.693Z"
},
{
"id": 5,
"username": "exampleuser",
"email": "exampleuser@gmail.com",
"created_at": "2019-11-18T16:09:18.017Z",
"updated_at": "2019-11-18T16:09:18.017Z"
}
]
URL: https://weight-lift-journal-dev.herokuapp.com/api/users/getby/:id
NOTE: Be sure to include the id
of an existing user on the end of the endpoint.
An object of the user information.
{
"id": 3,
"username": "testing",
"email": "testing@gmai.com",
"created_at": "2019-11-19 19:17:42",
"updated_at": "2019-11-19 19:17:42",
"workouts": [
{
"id": 7,
"workout_name": "Bodybuilding",
"exercises": 5
},
{
"id": 8,
"workout_name": "Powerlifting",
"exercises": 5
},
{
"id": 9,
"workout_name": "Regular Workout",
"exercises": 5
}
]
}
URL: https://weight-lift-journal-dev.herokuapp.com/api/users/getby/name/:username
NOTE: Be sure to include the username
of an existing user on the end of the endpoint.
An object of the user information.
{
"id": 3,
"username": "testing",
"email": "testing@gmai.com",
"created_at": "2019-11-19 19:17:42",
"updated_at": "2019-11-19 19:17:42",
"workouts": [
{
"id": 7,
"workout_name": "Bodybuilding",
"exercises": 5
},
{
"id": 8,
"workout_name": "Powerlifting",
"exercises": 5
},
{
"id": 9,
"workout_name": "Regular Workout",
"exercises": 5
}
]
}
URL: https://weight-lift-journal-dev.herokuapp.com/api/users/profile
NOTE: This endpoint will provide you with the current user object. This only works as long as a JWT token is presented. The endpoint uses this JWT to justify which user is logged in.
An object of the currently logged in user information.
{
"id": 3,
"username": "testing",
"email": "testing@gmai.com",
"created_at": "2019-11-19 19:17:42",
"updated_at": "2019-11-19 19:17:42",
"workouts": [
{
"id": 7,
"workout_name": "Bodybuilding",
"exercises": 5
},
{
"id": 8,
"workout_name": "Powerlifting",
"exercises": 5
},
{
"id": 9,
"workout_name": "Regular Workout",
"exercises": 5
}
]
}
URL: https://weight-lift-journal-dev.herokuapp.com/api/users/:id/workouts
NOTE: Be sure to include the id
of an existing user in the endpoint.
An array containing objects of the workout information, and the user that it belongs to.
[
{
"workout_id": 7,
"workout_name": "Bodybuilding",
"user_id": 3,
"username": "testing",
"exercises": [
{
"user_exercise_id": 31,
"exercise_id": 1,
"exercise_name": "Squats",
"region": "Quads",
"sets": 10,
"reps": 10
},
{
"user_exercise_id": 32,
"exercise_id": 2,
"exercise_name": "Curls",
"region": "Biceps",
"sets": 10,
"reps": 10
},
{
"user_exercise_id": 33,
"exercise_id": 3,
"exercise_name": "Pushups",
"region": "Chest",
"sets": 10,
"reps": 10
},
{
"user_exercise_id": 34,
"exercise_id": 4,
"exercise_name": "Lunges",
"region": "Hamstrings",
"sets": 10,
"reps": 10
},
{
"user_exercise_id": 35,
"exercise_id": 5,
"exercise_name": "Pull Ups",
"region": "Back",
"sets": 10,
"reps": 10
}
]
}
]
URL: https://weight-lift-journal-dev.herokuapp.com/api/users/:id/workouts
NOTE: Be sure to include the id
of an existing user in the endpoint.
Input (Case Sensitive) | Input Type |
---|---|
name (required) | string |
An example of how the body should appear:
{
"name": "Powerlifting Insanity!!"
}
You will receive an array containing the ID of the newly created workout.
[
10
]
URL: https://weight-lift-journal-dev.herokuapp.com/api/workouts
An array containing objects of all the existing workouts, and the user's id that they belong to.
[
{
"id": 1,
"name": "stronk",
"date": null,
"user_id": 1
},
{
"id": 2,
"name": "Intense Workout",
"date": null,
"user_id": 1
},
{
"id": 3,
"name": "Daily Workout",
"date": null,
"user_id": 1
},
{
"id": 4,
"name": "Adrenaline Pumping",
"date": null,
"user_id": 2
},
{
"id": 5,
"name": "P50X",
"date": null,
"user_id": 2
}
]
URL: https://weight-lift-journal-dev.herokuapp.com/api/workouts/:id
NOTE: Be sure to include the id
of an existing user on the end of the endpoint.
An object containing the workout information, and an array of ALL exercises associated with that workout.
{
"workout_id": 1,
"workout_name": "stronk",
"exercises": [
{
"user_exercise_id": 1,
"exercise_id": 1,
"exercise_name": "Squats",
"region": "Quads",
"sets": 10,
"reps": 10
},
{
"user_exercise_id": 2,
"exercise_id": 2,
"exercise_name": "Curls",
"region": "Biceps",
"sets": 10,
"reps": 10
},
{
"user_exercise_id": 3,
"exercise_id": 3,
"exercise_name": "Pushups",
"region": "Chest",
"sets": 10,
"reps": 10
},
{
"user_exercise_id": 4,
"exercise_id": 4,
"exercise_name": "Lunges",
"region": "Hamstrings",
"sets": 10,
"reps": 10
},
{
"user_exercise_id": 5,
"exercise_id": 5,
"exercise_name": "Pull Ups",
"region": "Back",
"sets": 10,
"reps": 10
}
]
}
URL: https://weight-lift-journal-dev.herokuapp.com/api/workouts/:id
NOTE: Be sure to include the id
of an existing workout on the end of the endpoint.
Input (Case Sensitive) | Input Type |
---|---|
name (required) | string |
An example of how the body should appear:
{
"name": "New Workout!"
}
You will receive the number of records updated. You should expect to see 1
returned if successful.
1
URL: https://weight-lift-journal-dev.herokuapp.com/api/workouts/:id
NOTE: Be sure to include the id
of an existing workout on the end of the endpoint.
You will receive a message confirming the workout was removed.
{
"message": "The selected workout was removed"
}
URL: https://weight-lift-journal-dev.herokuapp.com/api/workouts/:id/exercises
NOTE: Be sure to include the id
of an existing workout in the endpoint.
NOTE: This is used for adding an exercise to a workout.
Input (Case Sensitive) | Input Type |
---|---|
name (required) | string |
region (required) | string |
reps (required) | integer |
sets (required) | integer |
An example of how the body should appear:
{
"name": "Bench Press",
"region": "Chest",
"reps": 12,
"sets": 2
}
You will receive an object containing the workout's list of exercises which the object was added to. For example, if you add the exercise to the workout with ID of 3, you will receive the entire workout object with the ID of 3, with the new exercise added to the exercises array.
{
"workout_id": 3,
"workout_name": "Daily Workout",
"exercises": [
{
"user_exercise_id": 11,
"exercise_id": 1,
"exercise_name": "Squats",
"region": "Quads",
"sets": 10,
"reps": 10
},
{
"user_exercise_id": 12,
"exercise_id": 2,
"exercise_name": "Curls",
"region": "Biceps",
"sets": 10,
"reps": 10
},
{
"user_exercise_id": 13,
"exercise_id": 3,
"exercise_name": "Pushups",
"region": "Chest",
"sets": 10,
"reps": 10
},
{
"user_exercise_id": 46,
"exercise_id": 6,
"exercise_name": "Bench Press",
"region": "Chest",
"sets": 2,
"reps": 12
}
]
}
URL: https://weight-lift-journal-dev.herokuapp.com/api/workouts/:workout_id/exercises/:id
NOTE: Be sure to include the id
of an existing WORKOUT, workout_id
, in the endpoint.
NOTE: Be sure to include the id
of an existing EXERCISE, id
, at the end of the endpoint.
Input (Case Sensitive) | Input Type |
---|---|
name (required) | string |
region (required) | string |
reps (required) | integer |
sets (required) | integer |
An example of how the body should appear:
{
"name": "One handed pushups",
"region": "chest",
"sets": 3,
"reps": 4
}
You will receive the number of records updated. You should expect to see 1
returned if successful.
1
URL: https://weight-lift-journal-dev.herokuapp.com/api/workouts/exercises/:id
NOTE: Be sure to include the id
of an existing EXERCISE, id
, at the end of the endpoint.
You will receive a message confirming the exercise was successfully deleted.
{
"message": "The exercise was successfully removed from the workout"
}