There are just a couple of configurations managed as environment variables. In the development environment, these are injected by Docker Compose and managed in the docker-compose.yml
file.
DATABASE_URL
- This is the connection URL for the PostgreSQL database. It is not used in the development environment.DEBUG
- This toggles debug mode for the app to True/False.SECRET_KEY
- This is a secret string that you make up. It is used to encrypt and verify the authentication token on routes that require authentication. This is required. The app won't start without it.
Database migrations are handled by Flyway and files are stored in the /sql
directory. Migrations are automatically applied when running tests with Nose. You can run migrations manually in the development environment using docker-compose
too. The included script local_migrate.sh
uses an environment variable created by Docker Compose to find the IP address assigned to the database and execute the Flyway command to run migrations.
docker-compose run web ./local_migrate.sh
Tests, with code coverage reporting can be ran with the following command:
docker-compose run web nosetests -v --with-coverage --cover-erase --cover-package=app --cover-xml --cover-html
POST:
/v1/authenticate
Body:
{
"email": "something@email.com",
"password": "12345678"
}
Response:
{
"token": "reallylongjsonwebtokenstring"
}
Status Codes:
200
if successful400
if incorrect data provided401
if invalid credentials
POST:
/v1/user
Body:
{
"email": "something@email.com",
"password": "12345678"
}
Response:
{
"token": "reallylongjsonwebtokenstring"
}
Status Codes:
201
if successful400
if incorrect data provided409
if email is in use
POST:
/v1/inventory-item
Body:
{
"name": "Cool Item",
"url": "http://www.adafruit.com/products/2466",
"image_url": "http://www.adafruit.com/images/970x728/2466-05.gif.pagespeed.ce.7pXsy73MYp.gif",
"quantity": 1,
"vendor_name": "Adafruit",
"vendor_item_id": "2466"
}
Response:
{
"id": 1,
"user_id": 1,
"name": "Cool Item",
"url": "http://www.adafruit.com/products/2466",
"image_url": "http://www.adafruit.com/images/970x728/2466-05.gif.pagespeed.ce.7pXsy73MYp.gif",
"quantity": 1,
"vendor_name": "Adafruit",
"vendor_item_id": "2466"
}
Status Codes:
201
if successful400
if incorrect data provided401
if not authenticated
GET:
/v1/inventory-item
Query Parameters:
skip
: The number of records to skip for pagination (integer - required)take
: The number of records to take for pagination (integer - required)
Response:
{
count: 1,
items: [
{
"id": 1,
"user_id": 1,
"name": "Cool Item",
"url": "http://www.adafruit.com/products/2466",
"image_url": "http://www.adafruit.com/images/970x728/2466-05.gif.pagespeed.ce.7pXsy73MYp.gif",
"quantity": 1,
"vendor_name": "Adafruit",
"vendor_item_id": "2466"
}
]
}
Status Codes:
200
if successful400
ifskip
ortake
is missing401
if not authenticated
GET:
/v1/inventory-item/:id
Response:
{
"id": 1,
"user_id": 1,
"name": "Cool Item",
"url": "http://www.adafruit.com/products/2466",
"image_url": "http://www.adafruit.com/images/970x728/2466-05.gif.pagespeed.ce.7pXsy73MYp.gif",
"quantity": 1,
"vendor_name": "Adafruit",
"vendor_item_id": "2466"
}
Status Codes:
200
if successful401
if not authenticated404
if not found
PUT:
/v1/inventory-item/:id
Body:
{
"name": "Cool Item",
"url": "http://www.adafruit.com/products/2466",
"image_url": "http://www.adafruit.com/images/970x728/2466-05.gif.pagespeed.ce.7pXsy73MYp.gif",
"quantity": 1,
"vendor_name": "Adafruit",
"vendor_item_id": "2466"
}
Response:
{
"id": 1,
"user_id": 1,
"name": "Cool Item",
"url": "http://www.adafruit.com/products/2466",
"image_url": "http://www.adafruit.com/images/970x728/2466-05.gif.pagespeed.ce.7pXsy73MYp.gif",
"quantity": 1,
"vendor_name": "Adafruit",
"vendor_item_id": "2466"
}
Status Codes:
200
if successful400
if incorrect data provided401
if not authenticated404
if not found
DELETE:
/v1/inventory-item/:id
Body: None
Response: None
Status Codes:
204
if successful401
if not authenticated404
if not found
POST:
/v1/vendor-item
Body:
{
"vendor_name": "Adafruit",
"vendor_item_id": "2466",
"quantity": 1
}
Response:
{
"id": 1,
"user_id": 1,
"name": "Cool Item",
"url": "http://www.adafruit.com/products/2466",
"image_url": "http://www.adafruit.com/images/970x728/2466-05.gif.pagespeed.ce.7pXsy73MYp.gif",
"quantity": 1,
"vendor_name": "Adafruit",
"vendor_item_id": "2466"
}
Status Codes:
201
if successful401
if not authenticated409
if not vendor_name/vendor_id does not exist
Supported Vendors:
Adafruit
: https://www.adafruit.com/categoriesSparkfun
: https://www.sparkfun.com/categories