[blibli brown bag] nodejs - the other side of javascript

35
NODEJS – THE OTHER SIDE OF JAVASCRIPT By Irfan Maulana Presented for Brown Bag at Blibli.com

Upload: irfan-maulana

Post on 08-Jan-2017

640 views

Category:

Technology


3 download

TRANSCRIPT

Page 1: [Blibli Brown Bag] Nodejs - The Other Side of Javascript

NODEJS – THE OTHER SIDE OF JAVASCRIPTBy Irfan Maulana

Presented for Brown Bag at Blibli.com

Page 2: [Blibli Brown Bag] Nodejs - The Other Side of Javascript

ABOUT ME

• Name : Irfan Maulana• Join at Blibli : October 2015• Role : SDE – Front End Developer• Project : SEOUL aka Blibli.com main website• Has been code Javascript for at least 2 years

Page 3: [Blibli Brown Bag] Nodejs - The Other Side of Javascript

WHAT IS NODEJS ?

• JavaScript runtime built on Chrome's V8 JavaScript engine.

Page 4: [Blibli Brown Bag] Nodejs - The Other Side of Javascript

MAN BEHIND

• Initiate by Ryan Dahl (github.com/ry)• from 2015 handled by Node.js Foundation

Page 5: [Blibli Brown Bag] Nodejs - The Other Side of Javascript

WHAT IS DIFFERENT ?

FRONT BACK

NODEJS IS JAVASCRIPT, BUT IN DIFFERENT SIDE

Page 6: [Blibli Brown Bag] Nodejs - The Other Side of Javascript

NODEJS OFFER

• Lightweight server• Near Real-Time Speed• Non-Blocking I/O with Event-Loop• NPM (like Ruby GEM)• Javascript Isomorphic• Thousand Third Party Library• Growth community and documentation

Page 7: [Blibli Brown Bag] Nodejs - The Other Side of Javascript

MOST POPULAR NPM MODULE

• Express : web development framework• Connect : extensible HTTP server framework, serves as

base express• Socket.io and sockjs : websockets component• Jade : templating engine• Mongo and Mongojs : Mongodb wrapper• Redis : Redis client library• Coffe-script : CoffeScript compiler• Underscore : utility library• Forever : utility for ensuring node script runs continously

Page 8: [Blibli Brown Bag] Nodejs - The Other Side of Javascript

YOU SHOULD USE NODEJS

• CHAT• API• QUEUED INPUT• MONITORING DASHBOARD• SERVER-SIDE WEB APPLICATION

Page 9: [Blibli Brown Bag] Nodejs - The Other Side of Javascript

DON’T USE NODEJS

• RELATIONAL DB BEHIND• HEAVY COMPUTATION/PROCESSING

Page 10: [Blibli Brown Bag] Nodejs - The Other Side of Javascript

NODEJS SHOWCASE

• Walmart• E-bay/Paypal• Microsoft - Azure CLI, Yammer• Linkedin• Trello• Uber• Medium• Wordpress

Page 11: [Blibli Brown Bag] Nodejs - The Other Side of Javascript

WEB DEVELOPMENT IN NODEJS

Page 12: [Blibli Brown Bag] Nodejs - The Other Side of Javascript

OUR NODEJS WEB DEV STACK

• EXPRESSJS : BASE FRAMEWORK – APP GENERATOR

• MONGOOSE : MONGODB CONNECTION• JADE : HTML TEMPLATE• ANGULAR JS : FRONTEND FRAMEWORK• MOCHA – SHOULD – SUPERTEST : UNIT TEST• GRUNT : TASK RUNNER

Page 13: [Blibli Brown Bag] Nodejs - The Other Side of Javascript

EXPRESSJS AND MONGOSE

Page 14: [Blibli Brown Bag] Nodejs - The Other Side of Javascript

USING EXPRESS GENERATOR

• Express generator : express <package>• Run : SET DEBUG=<package>:* & npm start• Default run in : http://localhost:3000/

Page 15: [Blibli Brown Bag] Nodejs - The Other Side of Javascript

HOW EXPRESS SEND DATA

• SERVER RENDER

• REST

Page 16: [Blibli Brown Bag] Nodejs - The Other Side of Javascript

OUR MONGODB CONNECTION

Page 17: [Blibli Brown Bag] Nodejs - The Other Side of Javascript

SCHEMA AND MODEL IN MONGOOSE

Page 18: [Blibli Brown Bag] Nodejs - The Other Side of Javascript

USING OUR MONGOOSE MODEL

Page 19: [Blibli Brown Bag] Nodejs - The Other Side of Javascript

EXPRESS ROUTER

Page 20: [Blibli Brown Bag] Nodejs - The Other Side of Javascript

POSTMAN

Page 21: [Blibli Brown Bag] Nodejs - The Other Side of Javascript

INTRODUCE JADE TEMPLATING

Page 22: [Blibli Brown Bag] Nodejs - The Other Side of Javascript

USING JADE FOR VIEW

• HTML : XML LIKE STRUCTURE• JADE : JSON LIKE STRUCTURE

Page 23: [Blibli Brown Bag] Nodejs - The Other Side of Javascript

JADE LAYOUT SAMPLE

Page 24: [Blibli Brown Bag] Nodejs - The Other Side of Javascript

USING JADE LAYOUT

Page 25: [Blibli Brown Bag] Nodejs - The Other Side of Javascript

JAVASCRIPT UNIT TEST

Page 26: [Blibli Brown Bag] Nodejs - The Other Side of Javascript

CREATE OUR RESTFUL UNIT TEST

Page 27: [Blibli Brown Bag] Nodejs - The Other Side of Javascript

GRUNT TASK

Page 28: [Blibli Brown Bag] Nodejs - The Other Side of Javascript

OUR GRUNT PLUGIN

• grunt-contrib-uglify• grunt-contrib-cssmin• grunt-contrib-concat• grunt-contrib-jade

Page 29: [Blibli Brown Bag] Nodejs - The Other Side of Javascript

UGLIFY ( MINIFY JAVASCRIPT)

Page 30: [Blibli Brown Bag] Nodejs - The Other Side of Javascript

CSS MINIFY

Page 31: [Blibli Brown Bag] Nodejs - The Other Side of Javascript

CONCAT FILE CSS AND JAVASCRIPT

Page 32: [Blibli Brown Bag] Nodejs - The Other Side of Javascript

COMPILE JADE

Page 35: [Blibli Brown Bag] Nodejs - The Other Side of Javascript

THANK YOUmazipanneh.wordpress.com

@Maz_Ipan

/mazipanneh

/in/irfanmaulanamazipan