Skip to content
Go to file

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time


A tl;dr checklist to guide your workflow for your new Node App

Set Up NodeJS and Express

  • Initialize a new NodeJS application using Node Package Manager

    $ npm init -y
    • (-y accepts all default settings)
  • Install Express

    $ npm install --save express
    • Note: --save auto adds module to package.json
  • Create index.js in root directory

    • Require Express module and set up app port:
    var express = require("express")
    var app = express()
    app.listen(4000, () => {
      console.log("app listening on port 4000")
  • Start server with nodemon which automates server reload on file change (server start traditionally done with node index.js)

    • to install nodemon enter npm install nodemon (install globally with npm install -g nodemon)

MongoDB & Mongoose ODM

  • Install Mongoose

    $ npm install --save mongoose
  • In db/connection.js, set up Schema and connection to the db:

    var mongoose = require("mongoose")
    mongoose.Promise = global.Promise
    var ExampleSchema = mongoose.Schema({
      name: String,
    mongoose.model("Example", ExampleSchema)
    module.exports = mongoose
  • Handy MongoDB CLI Commands:

    • Note: be sure $ mongod is running in a separate terminal window

    • $ mongo opens interface

    • > show dbs

    • > use <name_of_db>

    • > show collections

    • > db.<name_of_collection>.find({}) to show all

    • More commands...

Making the MEN app MEANer (Angular)

  • In index.js display root file: layout.html

    app.get("/", function(req, res) {
      res.sendFile(__dirname + "/layout.html")
  • Set up Express to accept AJAX requests (from Angular):

    app.use(parser.json({extended: true}))
  • CDN Angular from layout.html & add link to your Angular app

    <script type="text/javascript" src=""></script>
    <script type="text/javascript" src=""></script>
    <script src=""></script>
    <script src="/assets/js/app.js"></script>
  • Example Angular Factory and Controller + Express API Route:

    // app.js (Angular)
    function ExampleFactoryFunction($resource) {
      return $resource("/api/example/:name", {}, {
        update: { method: "put" }
    function indexController(ExampleFactory) {
                    .then(examples => this.examples = examples)
    function showController($stateParams, ExampleFactory) {
      this.example = Example.get({name: $})
      this.update = function() {
        this.example.$update({name: $})
    // index.js (Express)"/api/examples/:name", function(req, res) {
      Example.findOneAndUpdate({name:}, req.body, {new: true}).then(example => {
  • Example: WhenPresident

Other Helpful Modules

  • body-parser

  • hbs (handlebars)


A tl;dr checklist to guide your workflow for your new Node App



No releases published


No packages published