A template for Node.js projects from your friends at Cloudant
- Built-in reverse proxy to your Cloudant account at /proxy, ending all CORS headaches.
- Custom API in
routes/api.js
using PouchDB, exposing your database in a more controlled fashion. - Uses Grunt to manage static assets and design documents.
- Manages design documents in the
ddocs
folder as JavaScript rather than raw JSON.
Express-Cloudant depends on Grunt.js being installed globally. To install it, run this:
sudo npm install -g grunt-cli
Then, let's get the project and install its dependencies:
git clone https://github.com/cloudant-labs/express-cloudant
cd express-cloudant
npm install
You're good to go!
Express-Cloudant uses a .env
file to store credentials and the like. A sample one comes in the repo as env.example
. Copy it and customize it by running this:
cp env.example .env
Now edit .env
with your Cloudant credentials. It's ignored by git, so you won't accidentally commit it.
Once you have Heroku's toolbelt installed, do this:
foreman run grunt && foreman start
This will...
- Concatenate and minify static assets.
- Push design docs stored in
/ddocs
to the appropriate databases. - Start the Node.js server.
Design documents live in the /ddocs
folder in JS files named after the databases where they'll be pushed to. So, a file named logs.js
will be pushed to a database named logs
. To see an example design doc in the format Express-Cloudant understands, open up /ddocs/_users.js
.
Heroku uses a .env
file to store environment variables like this:
USERNAME=derpherpburp
PASSWORD=friendshipismaniacal
To push those variables to your Heroku instance, do heroku config:push
. Then:
heroku create [app]
git push heroku master
Now your app should be live. Easy, eh?
Only together can we expand the universe of human potential! Fork the project on GitHub, open an issue, or submit a pull request. Everything helps :D