Skip to content

BestBuyAPIs/bby-query-builder

Repository files navigation

BBY Query Builder

Build Status

BBY Query Builder is an application to help developers learn Best Buy's APIs. It is based on angular-seed.

Included in this app are queries for fetching:

  1. Product information
  2. Store locations
  3. Categories of Best Buy products
  4. Open Box buying options
  5. Recommendations product lists
  6. Smart Lists of curated products

Getting Started

The rest of this page explains how to get the code and run it. If you want to use the application, go here.

Working with the code

Prerequisites

You need git to clone the query-builder repository. You can get git from http://git-scm.com/.

We also use a number of node.js tools to initialize and test query-builder. You must have node.js and its package manager (npm) installed. You can get them from http://nodejs.org/.

Download bby-query-builder

Clone the BBY Query Builder repository using git:

git clone https://github.com/BestBuyAPIs/bby-query-builder.git
cd bby-query-builder

Install Dependencies

We have two kinds of dependencies in this project: tools and Angular framework code. The tools help us manage and test the application.

We have preconfigured npm to automatically run bower so we can simply do:

npm install

NOTE: You may need to run npm update. Try that if the subsequent steps fail.

Behind the scenes this will also call bower install. You should find that you have two new folders in your project.

  • node_modules - contains the npm packages for the tools we need
  • app/bower_components - contains the angular framework files

Note that the bower_components folder would normally be installed in the root folder but query-builder changes this location through the .bowerrc file. Putting it in the app folder makes it easier to serve the files by a webserver.

Install grunt-cli

You only need to do this once - as this will install grunt-cli globally.

npm install -g grunt-cli

Run the Application

We have preconfigured the project with a simple development web server. The simplest way to start this server is:

npm start

Now browse to the app at http://localhost:8000/app.

Testing

There are two kinds of tests in the application: unit tests and a code coverage test.

Running Unit Tests

The app comes preconfigured with unit tests. These are written in Jasmine, which we run with the Karma Test Runner. We provide a Karma configuration file to run them.

  • the configuration is found at karma.conf.js
  • the unit tests are found in the app/test/ directory and are named as ..._test.js.

The easiest way to run the unit tests is to use the supplied npm script:

npm test

This script will start the Karma test runner to execute the unit tests. Karma will do a single run of the tests and then exit.

You can also ask Karma to sit and watch the source and test files for changes and then re-run the tests whenever any of them change. The project contains a predefined script to do this:

npm run-script test-watch

Test Coverage

Our Karma test runner is configured to use a library called Istanbul to check for code coverage. It is automatically run with npm test. You can check your test coverage by opening the report file at coverage/PhantomJS/index.html

Deploying

Query Builder is deployed as a Github Pages site from the gh-pages branch. When you want to push changes you can use the prewritten script

npm run-script deploy

The first time you do this you might have to delete your local gh-pages branch before running the deploy script. Furthermore, Query Builder is a static app so it is easy to drop in and deploy from your own platform if you so choose.

Contact

For more information please visit https://developer.bestbuy.com

And contact us directly @BestBuyAPI or email us developer@bestbuy.com.

Releases

No releases published

Packages

No packages published