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:
- Product information
- Store locations
- Categories of Best Buy products
- Open Box buying options
- Recommendations product lists
- Smart Lists of curated products
The rest of this page explains how to get the code and run it. If you want to use the application, go here.
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/.
Clone the BBY Query Builder repository using git:
git clone https://github.com/BestBuyAPIs/bby-query-builder.git
cd bby-query-builder
We have two kinds of dependencies in this project: tools and Angular framework code. The tools help us manage and test the application.
- We get the tools we depend upon via
npm
, the node package manager. - We get the Angular code via
bower
, a client-side code package manager.
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 needapp/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.
You only need to do this once - as this will install grunt-cli globally.
npm install -g grunt-cli
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
.
There are two kinds of tests in the application: unit tests and a code coverage test.
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
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
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.
For more information please visit https://developer.bestbuy.com
And contact us directly @BestBuyAPI or email us developer@bestbuy.com.