Skip to content

simple example of getting the new sails.js code running on heroku

Notifications You must be signed in to change notification settings

croffasia/heroku-sails

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

heroku-sails

This is a simple example of getting the new sails.js code running on heroku using mongodb as its database.

"Sails automatically builds a RESTful JSON API for your models. And here's the thing, it supports HTTP and WebSockets. By default, for every controller you create, you get the basic CRUD operations created automatically."

More examples at sails.js.

Setup

Could not be easier to setup your own API server using sails.js, node, mongodb, and heroku.

Short version:

  1. Install sails globally sudo npm install -g sails
  2. Create sails folder sails new heroku-sails
  3. Add to git: cd heroku-sails && git init && git add . && git commit
  4. Look at the git commit history for other changes made - there's only a few

If you have not yet, create heroku account and install heroku toolbelt

Then create a heroku app. I created heroku-sails in the following example:

$ heroku apps:create heroku-sails
Creating heroku-sails... done, region is us
https://heroku-sails.herokuapp.com/ | [email protected]:heroku-sails.git
Git remote heroku added

Add mongo db

$ heroku addons:add mongolab:starter
Adding mongolab:starter on heroku-sails... done, v3 (free)
Welcome to MongoLab.  Your new database is ready for use.  Please consult the MongoLab Add-on Admin UI for more information and useful management tools.
Use `heroku addons:docs mongolab:starter` to view documentation.

Optionally set the api key. If you don't, key check will be skipped and anyone can created/edit. Note that we what you set here is what is sent in URL. For more on this authentication, Read lib/authenKey.js

$ heroku config:set APPROVED_API_KEY=APIKEY
Setting config vars and restarting heroku-sails... done
APPROVED_API_KEY: APIKEY

Optionally add papertrail, lets you view logs from a browser:

$ heroku addons:add papertrail
Adding papertrail on heroku-sails... done, v4 (free)
Welcome to Papertrail. Questions and ideas are welcome. Happy logging!
Use `heroku addons:docs papertrail` to view documentation.

Deploy!

$ git push heroku master

Now view your new app in your browser.

Contact

For questions or custom work, please contact [email protected]

githalytics.com alpha

About

simple example of getting the new sails.js code running on heroku

Resources

Stars

Watchers

Forks

Packages

No packages published