Skip to content

brandonmoser/node_api

Repository files navigation

Node.JS API Case Study

A Simple Node.JS API for myRetail

Description of Spec

myRetail is a rapidly growing company with HQ in Richmond, VA and over 200 stores across the east coast. myRetail wants to make its internal data available to any number of client devices, from myRetail.com to native mobile apps.

The goal for this exercise is to create an end-to-end Proof-of-Concept for a products API, which will aggregate product data from multiple sources and return it as JSON to the caller.

Your goal is to create a RESTful service that can retrieve product and price details by ID. The URL structure is up to you to define, but try to follow some sort of logical convention. You should build the solution using JavaScript (Node.js), Java or Groovy, and a NoSQL data store such as Cassandra or MongoDB. You are free to use any frameworks and application servers that you choose.

Build an application that performs the following actions:

  • Responds to an HTTP request at /products/{id} and delivers product data as JSON (where {id} will be a number).

    • Example product IDs: 15117729, 16483589, 16696652, 16752456, 15643793)
    • Example response: {"id":13860428,"name":"The Big Lebowski (Blu-ray) (Widescreen)","current_price":{"value": 13.49,"currency_code":"USD"}}
  • Performs an HTTP request to retrieve the product name from an external API. (For this exercise the data will come from api.target.com, but let's just pretend this is an internal resource hosted by myRetail)

  • Reads pricing information from a NoSQL data store and combines it with the product id and name from the HTTP request into a single response.

  • Includes appropriate test cases implemented using a framework such as JUnit, Spock, or Mocha.

  • Contains a README.md file with instructions for testing, running and interacting with your application.

  • BONUS: Accepts an HTTP request to update the product's price in the data store. Hint: Ideally, it should respond to a different HTTP method at the same path /products/{id}.

  • BONUS: Contains a build script (pom.xml, build.gradle, package.json, etc) that can be used to build, run or package the application.

Building/Installing Project

  1. Clone the project locally
$ git clone https://github.com/brandonmoser/node_api.git && cd node_api
  1. Then install the npm packages
$ npm install

Running Tests

The tests are built with Mocha & Chai

$ npm test

Running the Server

Before running the server, make sure you have a MongoDB running locally on port 27017.

Running the server

$ npm start

About

A Simple Node.JS API for myRetail

Resources

License

Stars

Watchers

Forks

Packages

No packages published