This project exposes a Key/Value store through a REST API in the backend written with TypeScript and Express, and a UI written in React that consumes the API.
Store the given key/value combo
URL : /v1/keys/
Method : POST
Data constraints
{
"key": "[valid string]",
"value": "[any valid json]"
}
Data example
{
"key": "spencer-mcmaster",
"value": "{'age':23,'profession':'full stack developer'}"
}
Code : 204 No Content
Condition : If 'key' or 'value' is improperly formatted (i.e. user is not valid JSON)
Code : 400 BAD REQUEST
Content :
{
"errors": [
"Unable to complete request. key must be a valid string and value must be valid JSON."
]
}
Get the value for the given key
URL : /v1/keys/:key
URL Parameters : key is a URL encoded string that may or may not match a key in the store
Method : GET
Condition : Key was found.
Code : 200 OK
Content :
{
"key": "spencer-mcmaster",
"value": "{'age':23,'profession':'full stack developer'}"
}
Condition : Key was not found.
Code : 404 Not Found
Delete the key and associated value for the given key
URL : /v1/keys/:key
URL Parameters : Key is a url encoded string that may or may not match a key in the store
Method : DELETE
Data : {}
Condition : If the Key exists.
Code : 204 NO CONTENT
Condition : If there was no key available to delete.
Code : 404 NOT FOUND
- In a terminal navigate to frontend directory
- run
npm install && npm start
- In another terminal navigate to backend directory
- run
npm install && npm start
- Navigate to http:/localhost:3000 in a browser
- Add a key value pair via the form
- Retrieve the value by clicking "Retrieve value", make sure it appears below the form
- Delete the value by clicking "Delete key"
- Navigate back to "Retrieve value" and ensure that the key was deleted
- Run in other orders and with different values to see if anything breaks
- In a terminal navigate to backend directory
- Run
npm install
if needed and thennpm start
- Go to this postman collection
- Run the queries in the same order as steps 6-10 in the UI instructions
- Unit tests
- Better display of retrieved value, ran out of time to display it well
- Refactor the fetch API usage in the frontend, I hadn't used fetch in awhile and was pushed for time so it's a bit messy
- Add logging in the backend
- Validation frontend
- Validation backend (Express middleware)
- Add automated tests (i.e. Cypress for e2e in the front end, mocha + chai in the backend, automate Postman tests)