kickstarter your node.js application

36
Node Meetup Tuesday, December 2, 2014

Upload: hengki-sihombing

Post on 12-Jul-2015

952 views

Category:

Technology


1 download

TRANSCRIPT

Page 1: Kickstarter Your Node.JS Application

Node MeetupTuesday, December 2, 2014

Page 2: Kickstarter Your Node.JS Application

$ whoiam

Page 3: Kickstarter Your Node.JS Application

{ name : “Hengki Sihombing” email : “[email protected]”, twitter : “hengkiardo”, github : “aredo” }

module.export =

Page 4: Kickstarter Your Node.JS Application

Kickstarter Your Node.JS Application

http://blog.efvincent.com/wp-content/uploads/2011/06/Capture.png

Page 5: Kickstarter Your Node.JS Application

require(‘express’) require(‘mongoose’) require(‘passport’) require(‘async’) require(‘grunt’) require(‘demo’) require(‘QA’)

Page 6: Kickstarter Your Node.JS Application

Why Node.JS

Page 7: Kickstarter Your Node.JS Application

Answer by your selfWhy you come to this meetup :)

Page 8: Kickstarter Your Node.JS Application

Express.JSFast, unopinionated, minimalist web framework for Node.js

expressjs.com

$ npm install express

Page 9: Kickstarter Your Node.JS Application

MVC Framework base on Express.JS

http://www.quora.com/Why-should-I-use-Express-when-developing-a-web-app-with-Node-js http://evanhahn.com/understanding-express/

• KrakenJs http://locomotivejs.org/ • Locomotive.JS http://locomotivejs.org/

• Sails http://locomotivejs.org/ • Sleek.JS http://sleekjs.com/ • ……

Page 10: Kickstarter Your Node.JS Application

Why Express.JS ???

http://www.quora.com/Why-should-I-use-Express-when-developing-a-web-app-with-Node-js http://evanhahn.com/understanding-express/

• Express is a lightweight framework, meaning it does not make too many assumptions but gives you enough to avoid re-inventing the wheel.

• Express is preferred because it adds dead simple routing and support for Connect middleware, allowing many extensions and useful features

• Like any abstraction, Express hides difficult bits and says "don't worry, you don't need to understand this part". It does things for you so that you don't have to bother. In other words, it's magic

• https://www.google.com/#q=why+express.js

Page 11: Kickstarter Your Node.JS Application

Simple Express App

Page 12: Kickstarter Your Node.JS Application

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

Page 13: Kickstarter Your Node.JS Application

MongoDB Connection with Mongoose

Page 14: Kickstarter Your Node.JS Application

• 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!!

https://github.com/jaredhanson/passport

Page 15: Kickstarter Your Node.JS Application

Sample Twitter Auth with Passport

Page 16: Kickstarter Your Node.JS Application

Sample FB Auth with Passport

Page 17: Kickstarter Your Node.JS Application

Sample Linkedin Auth with Passport

Page 18: Kickstarter Your Node.JS Application

ASYNCHRONOUSBecause Javascript

Page 19: Kickstarter Your Node.JS Application

PromisesPromises… Promises… Never break your promises.

Personally, never make promises.

https://blog.domenic.me/youre-missing-the-point-of-promises

Page 20: Kickstarter Your Node.JS Application

😟

Page 21: Kickstarter Your Node.JS Application

Not part of the Node“until latest stable version”

Makes in tegrat ion more d i f f icu l t . Makes swapping code in / out more painfu l .

So good i t ’s got i t ’s own websi te cal lbackhel l .com

Callbacks

Page 22: Kickstarter Your Node.JS Application

async

$ npm install async — save

Async is a utility module which provides straight-forward, powerful functions for working with

asynchronous JavaScript. Although originally designed for use with Node.js, it can also be

used directly in the browser.

https://github.com/caolan/async

Page 23: Kickstarter Your Node.JS Application
Page 24: Kickstarter Your Node.JS Application
Page 25: Kickstarter Your Node.JS Application
Page 26: Kickstarter Your Node.JS Application

Why use a task runner or

build system?

another build tools: Gulp, Make, NPM, Ant, Maven

Page 27: Kickstarter Your Node.JS Application

Automation

Page 28: Kickstarter Your Node.JS Application

Automation isn’t about being lazy.

It’s about being efficient

Page 29: Kickstarter Your Node.JS Application
Page 30: Kickstarter Your Node.JS Application
Page 31: Kickstarter Your Node.JS Application
Page 32: Kickstarter Your Node.JS Application

$ npm install -g grunt-cli

Before you get started

$ npm install —save-dev grunt

Page 33: Kickstarter Your Node.JS Application

package.json to manage dependencies

Page 34: Kickstarter Your Node.JS Application

Grunt Overview

Page 35: Kickstarter Your Node.JS Application

Demo

https://express4-bootstrap-starter.herokuapp.com/

https://github.com/aredo/express4-bootstrap-starter

$ git clone [email protected]:aredo/express4-bootstrap-starter.git

Page 36: Kickstarter Your Node.JS Application

QA!

{ name : “Hengki Sihombing” email : “[email protected]”, twitter : “hengkiardo”, github : “aredo” }

module.export =