Short Description
Dynamodb container for application
Full Description
NodeJs Server for Storage+
Run the application
- Install nodejs
- run
npm install
in the root directory of the project - run
node bin/www
to launch the application
Configure
- To setup the database tables,
export SETUP_TABLES=true
- To use a remote (AWS) database,
export REMOTE_DATABASE=true
- You will need to export your
AWS_ACCESS_KEY_ID
andAWS_SECRET_ACCESS_KEY
as well for this to work properly
- You will need to export your
You may want to install nodemon to automatically relaunch when you make changes to the server
DyanamoDB
To run DynamoDB locally:
- Download DynamoDB
- Extract and run in the extracted folder:
java -Djava.library.path=./DynamoDBLocal_lib -jar DynamoDBLocal.jar -sharedDb
- Ensure it is running by navigating to http://localhost:8000/shell you should see an interactive shell appear
Technologies
- NodeJs - underlying server
- DynamoDb - database
- ExpressJs - for rest endpoints
- PassportJs - authentication (WIP)
Endpoints (WIP)
rest-api/user
implemented
POST
(New User){ "email":"blah", "password":"blah" }
rest-api/user/me
implemented
GET
(Info about self)
PUT{ "email":"blah", "id":"123456" }
(Updates){ "email":"balh@blah.com", "password":"blah" }
rest-api/categories
implemented
GET
(list of all categories for the authenticated user)[ { "id": "30424743-d9ba-485d-a993-259f01c163d4", "name": "Bananas", "qty": 7 }, { "id": "9e823101-c4f7-4469-91c2-a4633e0e7fb8", "name": "Green Beans", "qty": 5 } ]
rest-api/category
implemented
POST
(New category){ "name":"Beans", "qty":5 }
rest-api/category/{id}
implemented
GET
(Info on Category)
PUT{ "name":"Green Beans", "qty":5, }
(Update Category)
DELETE (remove category and associated barcodes){ "name":"Super Green Beans", "qty":6, }
rest-api/category/{category_id}/barcodes
implemented
GET (get list of barcodes associated with a category){ "codes": [ {"code":"123454", "id":"453h4kj3", "name":"Western Family Beans"}, {"code":"678902", "id":"43j2l5n2", "name":"Smith's Eggs"} ] }
rest-api/barcode
implemented
POST
(create){ "categoryId":"40gkj2n5", "name":"Western Family beans" }
rest-api/barcode/{id}
PUT
(update barcode)
DELETE (remove barcode){ "categoryId":"12345", "name":"Western Family beans", "code":"123456789" }
rest-api/barcode/searchMyFoodStorage
POST
(lookup){ "code":"123456" }
Response:
{ "id":"h4k2l5m", "categoryId":"40gkj2n5", "name":"Western Family beans", "code":"123456" }
rest-api/barcode/searchUpcDatabase
POST
(lookup){ "code":"123456" }
Response:
[ { "name":"Western Family beans", "image":"http://blah.com/.png" }, { "name":"Western Family beans", "image":"http://blah.com/.png" }, ]
Database Design
users
username | password | created | categories | barcodes | |
---|---|---|---|---|---|
bbarke | bbarke@blah.com | supasecret | YYYYmmdd:hh:ss | {"category": {"eggs"}} |
For demo purposes, it may be easir to store the password in plain text, but this will change at a later date to make it more secure