Skip to content

build-week-apis/anywhere-fitness

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

70 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Anywhere Fitness v1.0.0

Backend Project for Lambda's Build Week API Repository, deployed Link is https://lambda-anywhere-fitness.herokuapp.com/

Auth

Logs an User In

Logs an User In

POST /api/auth/login

Parameters

Name Type Description
username String

Username of the User

password String

Password of the User

Success Response

Success-Response:

{
"message": "Welcome back don!",
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE1NzE2MTI3MjcsImV4cCI6MTU3MTY5OTEyN30.FKIekAwXBPHRAf6ImjKHM_rKN9GrqLHcXMrpD4RpIB0",
"user": {
  "id": 3,
  "firstName": null,
  "lastName": null,
  "email": null,
  "username": "don",
  "created_at": "2019-10-20T22:59:45.794Z",
  "updated_at": "2019-10-20T22:59:45.794Z",
  "roleId": 1
}
}

Error Response

Username-Not-Found-Response

{
     "message": "Username is not in the system."
}

Incorrect-Password

{
     "message": "Incorrect Password"
}

Registers a New User

Registers a New User

POST /api/auth/register

Parameters

Name Type Description
username String

The New Users username *Required

password String

The New Users password *Required

firstName String

The New Users first name

lastName String

The New Users last name

email String

The New Users email

roleId Integer

The Users Role, 1 for Instructor, 2 for Client *Required

Success Response

Success-Response:

{
 "id": 3,
 "firstName": null,
 "lastName": null,
 "email": null,
 "username": "don",
 "created_at": "2019-10-20T22:59:45.794Z",
 "updated_at": "2019-10-20T22:59:45.794Z",
 "roleId": 1
}

Error Response

Username-Already-Taken

{
     "message": "Username is already taken"
}

Categories

Deletes Category based on provided Id

DELETE /api/category/:id

Parameters

Name Type Description
id integer

The ID is passed in the URL

Returns all categories

GET /api/category

Success Response

Success-Response:

[
{
  "id": 1,
  "name": "Pilates",
  "description": null,
  "created_at": "2019-10-20T22:59:34.197Z",
  "updated_at": "2019-10-20T22:59:34.197Z"
},
{
  "id": 2,
  "name": "Yoga",
  "description": null,
  "created_at": "2019-10-20T22:59:34.197Z",
  "updated_at": "2019-10-20T22:59:34.197Z"
},
{
  "id": 3,
  "name": "Lagree",
  "description": null,
  "created_at": "2019-10-20T22:59:34.197Z",
  "updated_at": "2019-10-20T22:59:34.197Z"
},
{
  "id": 4,
  "name": "Barre",
  "description": null,
  "created_at": "2019-10-20T22:59:34.197Z",
  "updated_at": "2019-10-20T22:59:34.197Z"
},
{
  "id": 5,
  "name": "Spin",
  "description": null,
  "created_at": "2019-10-20T22:59:34.197Z",
  "updated_at": "2019-10-20T22:59:34.197Z"
},
{
  "id": 6,
  "name": "Zumba",
  "description": null,
  "created_at": "2019-10-20T22:59:34.197Z",
  "updated_at": "2019-10-20T22:59:34.197Z"
}
]

Error Response

Unauthorized-Response:

{
    "message": "Unauthroized"
}

Add New Category

POST /api/category

Parameters

Name Type Description
name String

Category Name *Required

description String

Description of the Category

Success Response

Success-Response:

{
 "id": 9,
 "name": "Test Category2",
 "description": null,
 "created_at": "2019-10-21T01:19:39.287Z",
 "updated_at": "2019-10-21T01:19:39.287Z"
}

Error Response

Unauthorized-Response:

{
    "message": "Unauthroized"
}

BadRequest-Response

{
     "message": "The Category Name: ${req.body.name} is already taken"
}

Updates Category based on provided Id

PUT /api/category/:id

Parameters

Name Type Description
id Integer

The ID is passed in the URL

name String

Category Name *Required

description String

Description of the Category

Success Response

Success-Response:

{
  "id": 7,
  "name": "Test Category",
  "description": "Testing Update Router",
  "created_at": "2019-10-21T01:17:05.085Z",
  "updated_at": "2019-10-21T01:17:05.085Z"
}

Classes

Deletes Class based on provided Id

DELETE /api/classes/:id

Parameters

Name Type Description
id integer

The ID is passed in the URL

Returns all classes

GET /api/classes

Success Response

Success-Response:

[
 {
   "id": 1,
   "title": "Yoga",
   "instructorId": 1,
   "categoryId": 1,
   "scheduleTime": null,
   "address": null,
   "city": null,
   "state": null,
   "zipCode": null,
   "created_at": "2019-10-21T12:51:44.173Z",
   "updated_at": "2019-10-21T12:51:44.173Z"
 },
 {
   "id": 2,
   "title": "Water Aerobics",
   "instructorId": 1,
   "categoryId": 2,
   "scheduleTime": null,
   "address": null,
   "city": null,
   "state": null,
   "zipCode": null,
   "created_at": "2019-10-21T12:51:44.173Z",
   "updated_at": "2019-10-21T12:51:44.173Z"
 }
]

Error Response

Unauthorized-Response:

{
    "message": "Unauthroized"
}

Add New Class

POST /api/classes

Parameters

Name Type Description
title String

Class Title *Required

instructorId Integer

The Id of the Instructor *Required

categoryId Integer

The Id of the Category *Required

scheduleTime Date

The Date and Time of the class

address String

The Street Address of the class

city String

The City of the class

state String

The State of the class

zipCode String

The ZipCode fo the class

Success Response

Success-Response:

{
 "id": 3,
 "title": "A New Class",
 "instructorId": 1,
 "categoryId": 1,
 "scheduleTime": null,
 "address": null,
 "city": null,
 "state": null,
 "zipCode": null,
 "created_at": "2019-10-21T13:23:39.281Z",
 "updated_at": "2019-10-21T13:23:39.281Z"
}

Error Response

Unauthorized-Response:

{
    "message": "Unauthroized"
}

Updated Class with provided Id

PUT /api/classes/:id

Parameters

Name Type Description
title String

Class Title *Required

instructorId Integer

The Id of the Instructor *Required

categoryId Integer

The Id of the Category *Required

scheduleTime Date

The Date and Time of the class

address String

The Street Address of the class

city String

The City of the class

state String

The State of the class

zipCode String

The ZipCode fo the class

Success Response

Success-Response:

{
 "id": 3,
 "title": "An Updated Class",
 "instructorId": 1,
 "categoryId": 1,
 "scheduleTime": null,
 "address": null,
 "city": null,
 "state": null,
 "zipCode": null,
 "created_at": "2019-10-21T13:23:39.281Z",
 "updated_at": "2019-10-21T13:23:39.281Z"
}

Error Response

Unauthorized-Response:

{
    "message": "Unauthroized"
}

User

Updates the Current Logged In User

Updates the current logged in user

PUT /api/user

Parameters

Name Type Description
username String

The Users username

password String

The Users password

firstName String

The Users first name

lastName String

The Users last name

email String

The Users email

roleId Integer

The Users Role, 1 for Instructor, 2 for Client

Success Response

Success-Response:

{
 "id": 3,
 "firstName": "Donald",
 "lastName": null,
 "email": null,
 "username": "don",
 "created_at": "2019-10-20T22:59:45.794Z",
 "updated_at": "2019-10-20T22:59:45.794Z",
 "roleId": 1
}

Error Response

Unauthorized-Response:

{
    "message": "Unauthroized"
}

Deletes the Current Logged In User

Deletes the current logged in user

DELETE /api/user

Success Response

Success-Response:

1

Error Response

Unauthorized-Response:

{
    "message": "Unauthroized"
}

Retrieve all Classes that the Current User is signed up for

Retrieves the Current Users Signed up Classes

GET /api/user/classes

Success Response

Success-Response:

[
 {
   "classId": 1,
   "clientId": 3,
   "created_at": "2019-10-21T16:56:56.379Z",
   "updated_at": "2019-10-21T16:56:56.379Z"
 }
]

Error Response

Unauthorized-Response:

{
    "message": "Unauthroized"
}

Signs the User up for the Provided Class Id

Signs an user up for a class based on the provided class Id

POST /api/user/classes/:id

Success Response

Success-Response:

{
 "classId": 2,
 "clientId": 3,
 "created_at": "2019-10-21T19:00:55.322Z",
 "updated_at": "2019-10-21T19:00:55.322Z"
}

Error Response

Unauthorized-Response:

{
    "message": "Unauthroized"
}

Removes the User from the Provided Class Id

Removes the User from the provided Class Id

DELETE /api/user/classes/:id

Success Response

Success-Response:

1

Error Response

Unauthorized-Response:

{
    "message": "Unauthroized"
}

About

No description, website, or topics provided.

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published