Skip to content

FuelRats/api.fuelrats.com

Repository files navigation

api.fuelrats.com

node Dependencies Open Github Issues Travis CI Build

Setting up

So, first of you need to fetch a few things and install. These should be available as packages from your favorite package manager.

  1. nvm
  2. yarn
  3. Postgres v9.4

Grab the repo:

git clone https://github.com/FuelRats/api.fuelrats.com.git

Install all of the required Node modules:

cd api.fuelrats.com
nvm install 8.8.1
yarn

Start postgres and create the databases required:

su postgres
psql -c 'CREATE DATABASE fuelrats;' -U postgres
psql -c 'CREATE EXTENSION citext;' -U postgres fuelrats
psql -c 'CREATE DATABASE fuelratsTest;' -U postgres
psql -c 'CREATE EXTENSION citext;' -U postgres fuelratstest
psql -c 'CREATE USER fuelrats;' -U postgres
psql -c "ALTER USER fuelrats PASSWORD 'SqueakBaby';" -U postgres
exit

If you want to use a different username or password, you can use them instead and set the new ones in your config.json

Now start the server!

node index.js

This will start the API service on either port 8082 or whatever port you've set in config.json.

Common Problems

"Missing indexes" or an empty object is returned

Your databases are empty. You will need to either import some archived data or create some random test data with the example generator script

Generating the docs

It's so easy a DerryBear could do it! Just run the generator scripts:

npm run jsdoc
npm run apidoc

The docs will be created under static/docs and therefore accessible via http://[server]:[port]/docs/ e.g. http://localhost:8081/docs/js or http://localhost:8081/docs/api

Running Tests

The test suite is comprised of a number of nodeunit tests. To run the entire suite, simply use:

npm test

If you wish to run individual tests, you can launch either an individual group:

npm test login

or even specify a single test within the group:

npm test login resetPassword

When running the entire test suite or a test group, any ouput to stderr or stdout is muted to keep the build process clean. If you run the tests individually, this output is restored to aid test development.

License

Copyright 2017 The Fuel Rats Mischief

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

  3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.