Skip to content
This repository has been archived by the owner on May 26, 2022. It is now read-only.
/ chuck-node Public archive

The sourcecode of the app is meant to serve as an MVC seed project / or boilerplate for any Express / MongoDB based NodeJS app. This can be a starting point for engineers who are looking to get familiar with these technologies, Chuck Node is a great learning tool to get you started.

Notifications You must be signed in to change notification settings

Traackr/chuck-node

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

40 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Chuck Node: A Node.js Boilerplate

Chuck Node is an open source project. The app itself is a crowdsourcing tool for Chuck Norris Facts. Because Chuck Norris is unstoppable!

See: http://en.wikipedia.org/wiki/Chuck_Norris

The sourcecode of the app is meant to serve as an MVC seed project / or boilerplate for any Express / MongoDB based NodeJS app. This can be a starting point for engineers who are looking to get familiar with these technologies, Chuck Node is a great learning tool to get you started.

If you would like to be a contributor to the project, please contact Paul Kist at paul AT traackr DOT com

Demo

http://chucknode.herokuapp.com

What's here?

There are examples in this boiler plate to get started with:

Requirements and Installation

Tested on Node 0.10.30, NPM 1.4.21

Requirements

  • NodeJS & NPM
  • MongoDB
  • Grunt (npm install -g grunt-cli; npm install -g grunt)

Installation

After cloning the project for the first time you'll want to update your project dependencies by running npm install in your home directory by doing:

$ npm install

If this is successful, continue on by running the unit tests and building the app. Currently there are no files to build at the moment and no build tasks have been set up. But testing is part of the build process so simply run:

$ grunt

And the default task will run the unit tests, both the spec and nyan versions of the test (these are different reporters). Actualy because the spec version of the suite ran all the tests, there's no use to run the rest under nyan. But this is an example that you can single out certain tests to run under different reporters, see the grunt configuration Gruntfile

Running the App

In our package.json which is native to NPM, we have a few tasks defined:

  "scripts": {
    "start": "NODE_PATH=./app/controllers NODE_ENV=development ./node_modules/.bin/nodemon server.js",
  "test": "NODE_PATH=./app/controllers NODE_ENV=test mocha"
  }

So to run the app simply use npm start (or npm run-script startWin in Windows) and it will run on port 3000 by default

Getting Started On Your App

The app is structured as follows. Under the app folder are the following directories and their purpose:

  • model - Schema definitions are here. Look at Facts.js as an example
  • controllers - Controller classes are here. Look at FactController.js as an example
  • views - Handlebar templates go here. Look at views/fact for examples
  • lib - Custom business logic an go here in an organized fashion and included in your main controller via require
  • lib/HandlebarHelpers.js - here is where you wanna create your own handlebar functions to be used in your templates

The files you'll wanna update:

  • Edit the main view templates:
    • layouts/default.html
    • partials/*.html
  • Add routes to config/routes.js
  • Create your Model and Controllers
  • Create your views

Deploying on Heroku

The overall steps to deploy Chuck Node on Heroku are:

  1. Create and configure the application on Heroku
  2. Push the application to Heroku
  3. Configure the application

This assumes you have installed the Heroku cli on your machine (https://toolbelt.heroku.com/)

Create the application on heroku.com

Create a new application for Chick Node on Heroku and make sure to install an add-on for MongoDB, e.g. MongoHQ Sandbox (free). The URL for you application should be http://.kerokuapp.com. Heroku also creates a git repo for your application: [email protected]:.git

Push the application to Heroku

With Heroku you can push and deploy an application as if you where pushing your code to a remote git repository.

  • Add Heroku as a remote repository: git remote add heroku [email protected]:<ap-name>.git
  • Push + deploy code: git push heroku master

Configure the application

Heroku (and the application) uses environment variables to configure the application (see config/config.js). You will need to define the following environment variables with Heroku:

  • heroku config:set NODE_ENV=production
  • heroku config:set PORT=80
  • heroku config:set MONGOHQ_URL=mongodb://<username>:<password>@paulo.mongohq.com:10053/<mongohq-app-id> (_this would be the syntax if you used MongoHQ as an add-on for your hosted MongoDB database _)

You might need to restart the application for these to take effect: heroku restart

About

The sourcecode of the app is meant to serve as an MVC seed project / or boilerplate for any Express / MongoDB based NodeJS app. This can be a starting point for engineers who are looking to get familiar with these technologies, Chuck Node is a great learning tool to get you started.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published