Backend Project for Lambda's Build Week API Repository, deployed Link is https://lambda-anywhere-fitness.herokuapp.com/
Logs an User In
POST /api/auth/login
Name | Type | Description |
---|---|---|
username | String | Username of the User |
password | String | Password of the User |
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
}
}
Username-Not-Found-Response
{
"message": "Username is not in the system."
}
Incorrect-Password
{
"message": "Incorrect Password"
}
Registers a New User
POST /api/auth/register
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 |
String | The New Users email |
|
roleId | Integer | The Users Role, 1 for Instructor, 2 for Client *Required |
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
}
Username-Already-Taken
{
"message": "Username is already taken"
}
DELETE /api/category/:id
Name | Type | Description |
---|---|---|
id | integer | The ID is passed in the URL |
GET /api/category
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"
}
]
Unauthorized-Response:
{
"message": "Unauthroized"
}
POST /api/category
Name | Type | Description |
---|---|---|
name | String | Category Name *Required |
description | String | Description of the Category |
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"
}
Unauthorized-Response:
{
"message": "Unauthroized"
}
BadRequest-Response
{
"message": "The Category Name: ${req.body.name} is already taken"
}
PUT /api/category/:id
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:
{
"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"
}
DELETE /api/classes/:id
Name | Type | Description |
---|---|---|
id | integer | The ID is passed in the URL |
GET /api/classes
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"
}
]
Unauthorized-Response:
{
"message": "Unauthroized"
}
POST /api/classes
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:
{
"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"
}
Unauthorized-Response:
{
"message": "Unauthroized"
}
PUT /api/classes/:id
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:
{
"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"
}
Unauthorized-Response:
{
"message": "Unauthroized"
}
Updates the current logged in user
PUT /api/user
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 |
String | The Users email |
|
roleId | Integer | The Users Role, 1 for Instructor, 2 for Client |
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
}
Unauthorized-Response:
{
"message": "Unauthroized"
}
Deletes the current logged in user
DELETE /api/user
Success-Response:
1
Unauthorized-Response:
{
"message": "Unauthroized"
}
Retrieves the Current Users Signed up Classes
GET /api/user/classes
Success-Response:
[
{
"classId": 1,
"clientId": 3,
"created_at": "2019-10-21T16:56:56.379Z",
"updated_at": "2019-10-21T16:56:56.379Z"
}
]
Unauthorized-Response:
{
"message": "Unauthroized"
}
Signs an user up for a class based on the provided class Id
POST /api/user/classes/:id
Success-Response:
{
"classId": 2,
"clientId": 3,
"created_at": "2019-10-21T19:00:55.322Z",
"updated_at": "2019-10-21T19:00:55.322Z"
}
Unauthorized-Response:
{
"message": "Unauthroized"
}
Removes the User from the provided Class Id
DELETE /api/user/classes/:id
Success-Response:
1
Unauthorized-Response:
{
"message": "Unauthroized"
}