Skip to content

r1g023/FitnessApiNode

Repository files navigation

Anywhere Fitness Api

POST REGISTER

POST https://rlfitnessapi.herokuapp.com/api/auth/register

  1. role_id: Enter 1 for instructor, enter 2 for student
  2. your form should have INPUT option 1 || 2, MUST be a NUMBER value
  3. After successful register, generate a token to login
{
  username: "user";
  password: "password";
  email: "[email protected]";
  role_id: 1 || 2;
}

POST LOGIN

POST https://rlfitnessapi.herokuapp.com/api/auth/login

  1. Use username and password from register and login
{
  username: "user";
  password: "password";
}
  1. On login you will receive the token to see protected endpoints
{
    logged_in: "Welcome `${user}`, have a cookie",
    id: 1,
    instructor: true || false,
    token:"eyJhbGciOey.iOiIxMjM0NT.SflKx6POk6yJV_adQssw5c"
}

GET USERS, GET USER BY ID, UPDATE EMAIL ONLY, DELETE USER

  1. Instructor or Users can see array of list of users
  2. GET https://rlfitnessapi.herokuapp.com/api/users/
[
  {
    id: 1,
    username: "username",
    email: "[email protected]",
    role: "student || instructor",
  },
];
  1. GET BY ID https://rlfitnessapi.herokuapp.com/api/users/:id
  2. PATCH https://rlfitnessapi.herokuapp.com/api/users/:id > can only update by email address
    {
        email: "[email protected]",
    },
  1. DELETE http://localhost:5000/api/users/:id

GET CLASSES /api/classes

  1. Instructor or Users can see array of list of classes, but only an instructor can UPDATE, DELETE, ADD a class
  2. GET https://rlfitnessapi.herokuapp.com/api/classes/
{
    "id": 1,
    "name": "MMA Training",
    "type": "Kickboxing",
    "class_date": "1 / 4 / 2021",
    "start_time": "8:00 AM",
    "duration": 1.5,
    "intensity": "High",
    "location": "Seattle",
    "registered_students": 10,
    "max_students": 23,
    "created_at": "2021-01-05 00:27:27", > automatically generated by database, DO NOT add to form
    "updated_at": "2021-01-05 00:27:27"  > automatically generated by database, DO NOT add to form
  },
  1. GET BY ID https://rlfitnessapi.herokuapp.com/api/classes/:id
  2. POST https://rlfitnessapi.herokuapp.com/api/classes INSTRUCTOR ONLY
{
    "name": "MMA Training",
    "type": "Kickboxing",
    "class_date": "1 / 4 / 2021",
    "start_time": "8:00 AM",
    "duration": 1.5,
    "intensity": "High",
    "location": "Seattle",
    "registered_students": 10,
    "max_students": 23,
}
  1. PUT https://rlfitnessapi.herokuapp.com/api/classes/:id *INSTRUCTOR ONLY_can edit all properties
{
    "name": "MMA Training--",
    "type": "Kickboxing--",
    "class_date": "1 / 4 / 2021--",
    "start_time": "9:00 AM--",
    "duration": 1.8,
    "intensity": "High--",
    "location": "Seattle--"
    "registered_students": 11,
    "max_students": 22,
}
  1. DELETE https://rlfitnessapi.herokuapp.com/api/users/:id INSTRUCTOR ONLY

SEE LIST OF CLASSES JOINED BY USER ID / JOIN A CLASS

  1. GET https://rlfitnessapi.herokuapp.com/api/users/:id/userClasses Instructors and Users can see this

User can see all classes they joined by class_id

"list_of_classes": [
    {
      "user_id": 1,
      "class_id": 1,
      "username": "user",
      "start_time": "11:00 AM",
      "class_date": " 1 / 7 / 2021",
      "duration": 1.5,
      "type": "Treadmill",
      "intensity": "High",
      "location": "New York City"
    },
    {
      "user_id": 1,
      "class_id": 10,
      "username": "user",
      "start_time": "9:00 AM",
      "class_date": " 1 / 4 / 2021",
      "duration": 1.8,
      "type": "Treadmill",
      "intensity": "High",
      "location": "Seattle"
    },
]
  1. POST https://rlfitnessapi.herokuapp.com/api/users/:id/joinClass
    • User_id is the Id of the user logged in, if joining a class, use user_id && class_id
    • To join the class, enter the class_id # into the body to target that class
    • entering user_id: 1, class_id: 6 will have you join class id of # 6, etc..
    • MUST ENTER a number for user_id and class_id
{
	"user_id": 1,
	"class_id": 6
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published