
This application is the merging of the following two articles: the Getting Started with Node on Heroku article and Building a Simple CRUD Application with Express and MongoDB article - check them out.
You can follow these articles as a step by step tutorial on the same app (if so it is recommended to follow first the 'Getting started...' and then 'Building a simple CRUD...' :)
If you are following these articles as a tutorial then read this:
- Follow the 'Getting started...' tutorial entirely but skip the last step ('Provision a database') because we will provide a MongoDB database via mLab.
- Note in the first tutorial that the
/views
folder contain the/pages
folder and the/partials
folder, they both are used by EJS as templates to compose pages that share same header, navbar, footers and render server side content. - When you start the second tutorial remember to keep the same file structure inherited from the first one. This means that instead of create an
index.html
(that we already have but it is calledindex.ejs
and is located in/views/pages/index.ejs
) you have to create a second page called/db
in/views/pages/db.ejs
folder.
For more information about using Node.js on Heroku or MongoDB or Express or EJS, see these articles and websites:
- Getting Started with Node.js on Heroku
- Heroku Node.js Support
- Node.js on Heroku
- Best Practices for Node.js Development
- MongoDB Node.js Driver Documentation
- Getting Started with MongoDB
- EJS is a client-side templating language
- Using WebSockets on Heroku with Node.js
Make sure you have Node.js and the Heroku Toolbelt installed.
$ git clone https://github.com/DavOnGit/node-mongo-heroku-getting-started.git # or clone your own fork
$ cd node-mongo-heroku-getting-started
$ npm install
$ npm start
Your app should now be running on localhost:5000.
or
Make sure you have the Heroku Toolbelt installed.
$ heroku create
$ git push heroku master
$ heroku open