This application builds an entire backend database containing construction project and employee data
* JavaScript
* Node
* Express
* Knex
* PostgreSQL
* JWT Tokens
* HTML
* CSS
* Chai/Mocha
This API requires a JSON Web Token (JWT) in order to modify any of the data in the database. Request a token through the following endpoint:
/api/v1/auth
The request body for the token must must include the properties appName and email
This token must be included when making requests with the following methods:
POST
DELETE
PUT
PATCH
The token can be included in any of the following locations:
-
Request Body: Add a key value pair for token in the body.
-
Authorization Header: Add an Authorization key with a token for the value.
-
Query Parameter: Use '?token=' as a query parameter to the request path with the token as value.
Users will be granted access to modify data if they have an email address that ends with '@turing.io'
NOTES
- All API requests will be returned JSON format.
All responses will be returned with one of the following HTTP status codes:
200
OK
The request was successful400
Bad Request
There was a problem with the request due to client error401
Unauthorized
User is unauthenticated and does not have the necessary credentials403
Forbidden
The user might not have the necessary permissions for a resource or may need an account of some sort404
Not found
The resource could not be found405
Method not allowed
The resource does not support the request method500
Internal Server Error
Unexpected error was encountered on server side
POST
/api/v1/auth
Example request:
{
"appName": "byob",
"email": "robbie@turing.io",
}
Example response:
"eyJhbGciOiJIUzI1NiIsInR5cCI6IpkXVCJ9.eyJhcHBOYW1lIjoiYnlvYiIsImVtYWlsIjoicm9iYmllQHR1cmluZy5pbyJ9.xhqE8SYBJP7V2zif9UgrIVVuyqyNDiRRsQ8asrt7ODA"
Example request:
- No body required/accepted
Example response:
[
{
"id": 65,
"name": "United Airlines Remodel",
"location": "Denver",
"union": true,
"public": true
},
{
"id": 66,
"name": "Coors Field West Mezzanine",
"location": "Denver",
"union": true,
"public": true
},
{
"id": 67,
"name": "Denver Brewing Company Tank 7",
"location": "Denver",
"union": false,
"public": false
}
]
- This endpoint accepts query parameters
/api/v1/projects/?name=United Airlines Remodel
response:Accepted query parameters are[ { "id": 65, "name": "United Airlines Remodel", "location": "Denver", "union": true, "public": true } ]
name
andlocation
Example request:
- No body required/accepted
Example response:
[
{
"id": 62,
"name": "Robbie Greiner",
"position": "Foreman",
"email": "robbie@gcbuilders.net",
"phone": "303-123-4567",
"project_id": 65,
"employee_id": 62
},
{
"id": 65,
"name": "Alex Berg",
"position": "Foreman",
"email": "alex@gcbuilders.net",
"phone": "303-123-4570",
"project_id": 65,
"employee_id": 65
},
{
"id": 76,
"name": "Ron Swanson",
"position": "Carpenter",
"email": "ron@gcbuilders.net",
"phone": "303-123-4581",
"project_id": 65,
"employee_id": 76
}
]
Example request:
- No body required/accepted
Example response:
{
"id": 76,
"name": "Turing School",
"location": "Denver",
"union": false,
"public": false
}
Example request:
{
"name": "Turing School",
"location": "Denver",
"union": false,
"public": false
}
Example response:
{
"id": 95
}
Example request:
- No request body
Example response:
- No response body. Status code 201
Example request:
- No request body
Example response:
- No response body. Status code 204
Example request:
{
"name": "Turing School",
"location": "Denver",
"union": false,
"public": false
}
- Request body only requires the key value pairs being changed
Example response:
- No response body. Status code 204
Example request:
- No body required/accepted
Example response:
[
{
"id": 62,
"name": "Robbie Greiner",
"position": "Foreman",
"email": "robbie@gcbuilders.net",
"phone": "303-123-4567"
},
{
"id": 63,
"name": "Bill Smith",
"position": "Foreman",
"email": "bill@gcbuilders.net",
"phone": "303-123-4568"
},
{
"id": 64,
"name": "Todd Gak",
"position": "Foreman",
"email": "todd@gcbuilders.net",
"phone": "303-123-4569"
}
]
- This endpoint accepts query parameters
<code>/api/v1/projects/?name=Todd Gak</code>
**response:**
```
{
"id": 64,
"name": "Todd Gak",
"position": "Foreman",
"email": "todd@gcbuilders.net",
"phone": "303-123-4569"
}
```
Accepted query parameters are <code>name</code>, <code>position</code>, <code>email</code>, and <code>phone</code>
Example request:
- No body required/accepted
Example response:
{
"id": 64,
"name": "Todd Gak",
"position": "Foreman",
"email": "todd@gcbuilders.net",
"phone": "303-123-4569"
}
Example request:
- No body required/accepted
Example response:
[
{
"id": 77,
"name": "CU Denver Student Activities",
"location": "Denver",
"union": true,
"public": true,
"project_id": 77,
"employee_id": 75
},
{
"id": 89,
"name": "State Farm Office",
"location": "Golden",
"union": false,
"public": false,
"project_id": 89,
"employee_id": 75
}
]
Example request:
{
"name": "Malcolm Reynolds",
"position": "Captain",
"email": "mal@gcbuilders.net",
"phone": "303-123-4569"
}
Example response:
{
"id": 77
}
Example request:
- No request body
Example response:
- No response body. Status code 204
Example request:
- No request body
Example response:
- No response body. Status code 204
Example request:
{
"name": "Malcolm Reynolds",
"position": "Captain",
"email": "mal@gcbuilders.net",
"phone": "303-123-4569"
}
- Request body only requires the key value pairs being changed
Example response:
- No response body. Status code 204