Bootstraping – using ExpressJS 4, Mongoose, Passport.js and Jade – Hengki Sihombing



Bootstraping – using ExpressJS 4, Mongoose, Passport.js and Jade – Hengki Sihombing

0 1


jakartajs-may-2014-meetup

JakartaJS May 2014 meetup Slides.

On Github aredo / jakartajs-may-2014-meetup

Bootstraping

using ExpressJS 4, Mongoose, Passport.js and Jade

 

Hengki Sihombing

@hengkiardo          @aredo

Tech Lead

tukangslicing.com Gushcloud.com

Node.JS

Some reasons why I chose to use Node.js in this case

  • It is very lightweight and fast.
  • The counter is really easy to make to be real time.
  • Node.js was easy to configure.
  • There are lots of modules available for free. For example, I found a Node.js module for PayPal. In this case, Node.js was an awesome choice
  • It runs Javascript, so you can use the same language on server and client, and even share some code between them (e.g. for form validation, or to render views at either end.)

Express.JS

Express is a minimal and flexible node.js web application framework, providing a robust set of features for building single and multi-page, and hybrid web applications.

npm install express

OR

$ npm install -g express-generator

Why Mongoose

Because it provides easy-to-use methods for interacting with MongoDB. It is ORM, actually. It helps you forget about driver's query documentation, and focus on your models.
Mongoose provides a straight-forward, schema-based solution to modeling your application data and includes built-in type casting, validation, query building, business logic hooks and more, out of the box.

Mongoose provides various functionalities which makes your life easy such as

others option

Mongoskin, MongoJS

Mongoose connection to MongoDB

Features

  • 140+ authentication strategies
  • Easily handle success and failure
  • Supports persistent sessions
  • Dynamic scope and permissions
  • Pick and choose required strategies
  • Implement custom strategies
  • Lightweight code base
  • Easy to Use!!

$ npm install passport

WHY JADE?

WHY not EJS, HANDLERBAR, MUSCTACHE

I wouldn't say that one is better than the other. They are different, that's for sure, but "better" is quite relative term. The nice thing about Jade is that you have a shorter syntax which means you can type faster. The block in Jade is pretty powerful which can help me a lot when dealing with complex HTML code. Jade is rather clean and makes for some neat code in your views

Pick whatever you feel more comfortable.

Demo Code

express4-bootstrap-starter.tukangslicing.net
Source : github.com/aredo/express4-bootstrap-starter

Happy Coding

Questions?