Giter Club home page Giter Club logo

censys-takehome's Introduction

Censys Take Home Assignment

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.

API Documentation

Store a Key/Value combination

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'}"
}

Success Response

Code : 204 No Content

Error Response

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 a value for a given key

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

Success Response

Condition : Key was found.

Code : 200 OK

Content :

{
    "key": "spencer-mcmaster",
    "value": "{'age':23,'profession':'full stack developer'}"
}

OR

Condition : Key was not found.

Code : 404 Not Found

Delete given key

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 : {}

Success Response

Condition : If the Key exists.

Code : 204 NO CONTENT

Error Responses

Condition : If there was no key available to delete.

Code : 404 NOT FOUND

Testing Instructions using UI

  1. In a terminal navigate to frontend directory
  2. run npm install && npm start
  3. In another terminal navigate to backend directory
  4. run npm install && npm start
  5. Navigate to http:/localhost:3000 in a browser
  6. Add a key value pair via the form
  7. Retrieve the value by clicking "Retrieve value", make sure it appears below the form
  8. Delete the value by clicking "Delete key"
  9. Navigate back to "Retrieve value" and ensure that the key was deleted
  10. Run in other orders and with different values to see if anything breaks

Testing Instructions for API

  1. In a terminal navigate to backend directory
  2. Run npm install if needed and then npm start
  3. Go to this postman collection
  4. Run the queries in the same order as steps 6-10 in the UI instructions

Things to do before this would be production ready

  • 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)

censys-takehome's People

Contributors

mcmasts avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.