You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
$ cd workout_api # navigate to project's root directory
$ npm i # install the packages listed in package.json
From the command line, set the value of the jwt_private_key environment variable (this private key is used to create the JSON Web tokens that allow users to securely log in to the application.)
Example (Mac): $ export workout_api_jwt_private_key=your_private_key
$ npm test # Run tests
$ npm start # start server
$ mongod # run the Mongo daemon
$ node seed_db # seed the database with muscles and exercises
Done. You can now use a command line tool like $ curl, or an application like Postman to test the API endpoints.
$ npm outdated # check for outdated packages
$ npm update # update packages
App Structure
Entity Relationship Diagram
Routes and Resources
Users Resource
URL
HTTP verb
Result
Admin only?
/api/users
POST
create a new user
No
/api/users
GET
return all users
Yes
/api/users/me
GET
return current user
No
/api/users/me
PUT
update current user
No
/api/users/:id
DELETE
delete a user
Yes
Workouts Resource
URL
HTTP verb
Result
Admin only?
/api/workouts
POST
create a new workout
No
/api/workouts
GET
return all workouts for current user
No
/api/workouts/:id
GET
return a specific workout for current user
No
/api/workouts/:id
PUT
update a specific workout for current user
No
/api/workouts/:id
DELETE
delete a specific workout for current user
No
/api/workouts/:id/completed_exercises
POST
create a new completed_workout for a specific workout for current user
No
Completed_Exercises Resource
URL
HTTP verb
Result
Admin only?
/api/completed_exercises/:id
GET
return a specific completed_exercise for current user
No
/api/completed_exercises/:id
PUT
update a specific completed_exercise for current user
No
/api/completed_exercises/:id
DELETE
delete a specific completed_exercise for current user
No
Exercises Resource
URL
HTTP verb
Result
Admin only?
/api/exercises
POST
create a new exercise
Yes
/api/exercises
GET
return all exercises
No
/api/exercises/:id
GET
return a specific exercise
Yes
/api/exercises/:id
PUT
update a specific exercises
Yes
/api/exercises/:id
DELETE
delete a specific exercise
Yes
Muscles Resource
URL
HTTP verb
Result
Admin only?
/api/muscles
POST
create a new muscle
Yes
/api/muscles
GET
return all muscles
No
/api/muscles/:id
GET
return a specific muscle
Yes
/api/muscles/:id
PUT
update a specific muscle
Yes
/api/muscles/:id
DELETE
delete a specific muscle
Yes
Login Resource
URL
HTTP verb
Result
Admin only?
/api/login
POST
return a new JSON web token that can be used to identify the current user
No
About
This is a simple API for tracking workouts, created with Node.js and Express.