Team Lead: Benjamin Grabow | Oladimeji Ojo | Liam Sutton | Funmilayo Talabi | Jayne Carmichael Norrie | Dom Eccleston |
---|---|---|---|---|---|
- Node
- Express
- PostgresSQL
- Knex
- Knex Cleaner
- Bcryptjs
- JsonWebToken
- Cors
- Helmet
- Dotenv
- Nodemon (Development)
- Cross-Env (Development)
- Jest (Development)
- SuperTest (Development)
npm install
npm run migrate
npm run seed
npm run server
POST /user/register
Parameters
Name | Type | Description | Required |
---|---|---|---|
first_name | String | Users forename | Yes |
last_name | String | Users surname | Yes |
String | Users email | Yes | |
password | String | Users password | Yes |
POST This will create a new user and send back a token
Examples
Register Request
{
"first_name": "dom",
"last_name": "eccleston",
"email": "[email protected]",
"password": "123"
}
Register Success Response
{
"message": "Welcome dom",
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE1NzY2NzA1NDQsImV4cCI6MTU3Njc1Njk0NH0.jpyV3IoB3sYehy8CdQ_h1EPhSjIrglvmVEEgUyqo_Zs",
"user_id": 18
}
Register Error Response
{
"message": "Please make sure required fields are filled in."
}
POST /user/login
Parameters
Name | Type | Description | Required |
---|---|---|---|
String | Users email | Yes | |
password | String | Users password | Yes |
POST This will log the user in and send back a token
Examples
Login Request
{
"email": "[email protected]",
"password": "123"
}
Login Success Response
{
"message": "Welcome Back Lizzo!",
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE1NzY4MzM1NDQsImV4cCI6MTU3NjkxOTk0NH0.SJgkKCi8rezDfWseszQ4HkSNyDbQNdeEmX0Kp48Dvic",
"user": {
"id": 2,
"first_name": "Lizzo",
"last_name": "Smith",
"email": "[email protected]",
"password": "$2a$10$32yN0PhBtC.F9DESU4JCnO0oHKo6Z2Bz1QjK83hxn/fflvhGKjY4W",
"location": null,
"role_id": 1,
"user_id": 5,
"avatar_url": null,
"experience_level": 2,
"confidence_level": 2
}
}
Login Error Response
{
"message": "Please make sure required fields are filled in."
}
DELETE /user/:id
DELETE This will delete a user at the provided id
Examples
Delete User Success Response
{
"message": "User deleted"
}
Delete User Error Response
{
"message": "Unable to find user"
}
GET /profile/coaches
GET This will get all coaches
Examples
GET Coaches Success Response
{
"coaches": [
{
"id": 1,
"first_name": "Jayne",
"last_name": "Carmichael Norrie",
"email": "[email protected]",
"password": "$2a$10$3LmQzlDtk/1NYys6kn5Ea.FH680/SzfqPWNTC3X9qZQ9.a.I1Z3vi",
"location": null,
"role_id": 2,
"user_id": 1,
"avatar_url": "google.com",
"experience_level": 1,
"skill_level": 1,
"description": "Jayne worked as a singing teacher for 9 years and is now studying with Lambda School",
"rating": null,
"hourly_rate": null,
"contact_url": null
}
]
}
GET Coaches Error Response
{
"message": "Auth Failed"
}
GET /appointment/:id
Parameters
Name | Type | Description | Required |
---|---|---|---|
role | String | role_id of the user | Yes |
GET This will get all user appointments at the provided id
(id is the coach.id or student id) and we need to send a body with an object = {"role": role_id} (role_id from the user)
Examples
GET Appointments Success Response
{
"appointments": [
{
"first_name": "Bob",
"last_name": "Smith",
"email": "[email protected]",
"experience_level": 1,
"confidence_level": 1,
"avatar_url": "www.stripe.com",
"id": 1,
"created_at": "2019-12-20T07:50:04.203Z",
"appointment_datetime": null,
"canceled": false,
"appointment_topic": "Frontend"
}
]
}
GET Appointments Error Response
{
"message": "Auth Failed"
}