Skip to content

drywallio/drywall-api

Repository files navigation

DryWall API

RESTful API using Node.js, Express, and MongoDB

Codeship Status for cofounders/drywall-api

Setup

  1. Install Node.js

  2. Set a DRYWALL_MONGO environment variable (details below) or install MongoDB

  3. Install the dependencies

	$ npm install
  1. Run the node server on localhost (default port 8000)
	$ npm start
  1. Check that its working:

    http://localhost:8000

Development

Run the app in development mode to automatically restart when you make a change to the source code.

  $ grunt dev

Tests

Sanity check the code and run integration tests.

  $ npm test

Configurations

The following environment variables are used in this app and can be configured by creating a .env file in the root of the project. It should be in the format: KEY=VALUE

  • PORT (default: 8000): TCP port where the app listens for HTTP requests
  • DRYWALL_AUTH0_CLIENT_SECRET: Auth0 client secret for drywall. It handles user social logins.
  • DRYWALL_AUTH0_ID: Auth0 client id for drywall. It handles user social logins.
  • DRYWALL_MONGOHQ_URI: MongoHQ/compose connection string (only one MongoDB connection).
  • DRYWALL_MONGOLAB_URI: MongoLab connection string (only one MongoDB connection).
  • GITHUB_CLIENT_ID: client id from a github application. This is to allow more requests.
  • GITHUB_SECRET: client secret from a github application.
  • DRYWALL_PAYPAL_LIVE_MODE (default: false): Either true or false to specify whether to use live mode credentials.
  • For the following, <paypalMode> = SANDBOX or LIVE.
  • DRYWALL_PAYPAL_<paypalMode>_CLIENT_ID: Paypal client id for this mode.
  • DRYWALL_PAYPAL_<paypalMode>_SECRET: Paypal secret for this mode.
  • DRYWALL_PAYPAL_<paypalMode>_USER: Paypal user for this mode.
  • DRYWALL_PAYPAL_<paypalMode>_PASSWORD: Paypal password for this mode.
  • DRYWALL_PAYPAL_<paypalMode>_SIGNATURE: Paypal signature for this mode.

By default the app connects to MongoDB as mongodb://localhost:27017/test.

Deployment

Auto deployment from a code branch to heroku is handled by codeship.

Environment Type branch URL
Staging develop http://drywall-api-staging.herokuapp.com
Production master http://drywall-api-production.herokuapp.com

MongoDB

To start MongoDB locally:

  $ mongod
  $ mongod --dbpath /data/db  # specify path to db data

http://docs.mongodb.org/manual/reference/mongo-shell/

In the mongo/bin folder, run mongo

> use <dbName>
> show collections
> db.<collection>.find() //return all
> db.<collection>.find({id: 1})
> db.<collection>.remove() //Does not remove indexes
> db.<collection>.drop()   //drops documents and indexes

To play with/research a little more: