how to build mobile api with node.js

89
HOW TO BE PREPARED FOR NODE-POCALYPSE @tomekcejner

Upload: tomek-cejner

Post on 06-Sep-2014

465 views

Category:

Documents


3 download

DESCRIPTION

Node-pocalypse is coming! Soon everything will be written in JavaScript.

TRANSCRIPT

Page 1: How to build mobile API with Node.js

HOW TO BE PREPARED FOR NODE-POCALYPSE

@tomekcejner

Page 2: How to build mobile API with Node.js

THE PRESENTER

TOMEK CEJNER @tomekcejner

Page 3: How to build mobile API with Node.js

APOCALYPSE?

Page 4: How to build mobile API with Node.js

JavaScript

Page 5: How to build mobile API with Node.js

Any application that can be written in JavaScript, will eventually be written in JavaScript.

http://blog.codinghorror.com/the-principle-of-least-power/

Jeff Atwood, 2007

Page 6: How to build mobile API with Node.js
Page 7: How to build mobile API with Node.js

CREATED IN 10 DAYS DIFFICULT CHILDHOOD

FUNCTIONAL DYNAMIC

Page 8: How to build mobile API with Node.js
Page 9: How to build mobile API with Node.js

IN 90’S EVERYBODY NEED A WEBSITE

Page 10: How to build mobile API with Node.js

http://www.amazon.com/

Page 11: How to build mobile API with Node.js

http://www.lego.com/

Page 12: How to build mobile API with Node.js

NOW ITS 2010’S EVERYBODY NEEDS MOBILE APP

Page 13: How to build mobile API with Node.js
Page 14: How to build mobile API with Node.js
Page 15: How to build mobile API with Node.js
Page 16: How to build mobile API with Node.js
Page 17: How to build mobile API with Node.js

THAT’S ALL THANK YOU!

Page 18: How to build mobile API with Node.js

BUT, IF…

Page 19: How to build mobile API with Node.js

API

Page 20: How to build mobile API with Node.js
Page 21: How to build mobile API with Node.js

NO API NO PUBLIC API

NO MOBILE PUBLIC API

ARE YOU PREPARED?

Page 22: How to build mobile API with Node.js

WHAT MAKES API MOBILE?

Page 23: How to build mobile API with Node.js

LOW BANDWIDTH HIGH LATENCY

NETWORK CONDITIONS VARY

Mobile device is

Page 24: How to build mobile API with Node.js

SEND ONLY WHAT IS NEEDED

Page 25: How to build mobile API with Node.js

SCREEN-ORIENTED NO CRUD-OVER-AIR

Page 26: How to build mobile API with Node.js

AVOID MULTIPLE ROUNDTRIPS CAUSED BY LAZY DESIGN EVERY REQUEST COUNTS

Page 27: How to build mobile API with Node.js

VERSIONING OR KEEP STABLE CONTRACT

Page 28: How to build mobile API with Node.js

SECURITY AUTHENTICATION

TRANSIT API ABUSE

Page 29: How to build mobile API with Node.js

ANALYTICS

Page 30: How to build mobile API with Node.js

Our approach

Page 31: How to build mobile API with Node.js

PLATFORM APIs

MOBILE API

Page 32: How to build mobile API with Node.js

INTRODUCING Mobster

Page 33: How to build mobile API with Node.js

OAUTH 2.0 AUTHORIZATION

API KEYS

Access control

Page 34: How to build mobile API with Node.js

DATA AGGREGATION DATA FILTERING

ANTI-CORRUPTION LAYER

Translation

Page 35: How to build mobile API with Node.js

PUSH NOTIFICATIONS GATEWAY

Mobile features

Page 36: How to build mobile API with Node.js

ENTER

Page 37: How to build mobile API with Node.js

EVENT-DRIVEN NETWORK PROGRAMS

JAVASCRIPT

Node.js is

Page 38: How to build mobile API with Node.js

V8

LIBUV HTTP-PARSER

JS STANDARD LIBRARY

Page 39: How to build mobile API with Node.js

WHY NODE.JS?

Page 40: How to build mobile API with Node.js

DB

SERVICE

REQUEST

REQUEST

REQUEST

REQUEST

TRADITIONAL WAY

Page 41: How to build mobile API with Node.js

WHAT WEB SERVERS DO MOST THE TIME? THEY WAIT

Page 42: How to build mobile API with Node.js

WHAT THREADS DO MOST THE TIME? THEY SUCK

Page 43: How to build mobile API with Node.js

EVENT LOOP

I/O

REGISTER CALLBACK

OPERATION COMPLETE

YOUR CODE

YOUR CODE

Page 44: How to build mobile API with Node.js

LESS THREADS LESS MEMORY OVERHEAD LESS COMPUTATION (!)

Page 45: How to build mobile API with Node.js

NODE.JS SURVIVAL KIT

Page 46: How to build mobile API with Node.js

Editors

Page 47: How to build mobile API with Node.js

UNIT TESTING

Page 48: How to build mobile API with Node.js

NodeUnit

Page 49: How to build mobile API with Node.js

NodeUnit + Expect.js

Page 50: How to build mobile API with Node.js

NodeUnit

Page 51: How to build mobile API with Node.js

NodeUnit

Page 52: How to build mobile API with Node.js

Mocha

Page 53: How to build mobile API with Node.js

Mocha

Page 54: How to build mobile API with Node.js

PACKAGE MANAGEMENT

Page 55: How to build mobile API with Node.js
Page 56: How to build mobile API with Node.js
Page 57: How to build mobile API with Node.js

pom.xml

Page 58: How to build mobile API with Node.js
Page 59: How to build mobile API with Node.js

CHECK NODE_MODULES TO SCM

Page 60: How to build mobile API with Node.js

WEB FRAMEWORKS

Page 61: How to build mobile API with Node.js
Page 62: How to build mobile API with Node.js
Page 63: How to build mobile API with Node.js
Page 64: How to build mobile API with Node.js

MIDDLEWARE

Page 65: How to build mobile API with Node.js
Page 66: How to build mobile API with Node.js

tomek@dev_laptop$ git push

appuser@server$ git pull appuser@server$ kill process_num appuser@server$ node myapp.js

DEPLOYMENT

Page 67: How to build mobile API with Node.js

MANAGEMENT WITH PM2

https://github.com/unitech/pm2

Page 68: How to build mobile API with Node.js

RUN

Page 69: How to build mobile API with Node.js

RESTART

Page 70: How to build mobile API with Node.js

PROCESS LIST

Page 71: How to build mobile API with Node.js

MONITORING

Page 72: How to build mobile API with Node.js

ZERO-DOWNTIME RELOAD HEALTH CHECK API ENDPOINT

LOG BROWSING LINUX STARTUP SCRIPTS

Fluff

Page 73: How to build mobile API with Node.js

Automate

ANSIBLE

Page 74: How to build mobile API with Node.js

SPEAKS YOUR LANGUAGE AGENTLESS

Ansible

Page 75: How to build mobile API with Node.js
Page 76: How to build mobile API with Node.js

CODE

Page 77: How to build mobile API with Node.js

GOOGLE: JAVASCRIPT GARDEN

http://bonsaiden.github.io/JavaScript-Garden/

Page 78: How to build mobile API with Node.js

JAVASCRIPT QUIRKS JSLINT & JSHINT TO RESCUE

Page 79: How to build mobile API with Node.js
Page 80: How to build mobile API with Node.js

ASYNCHRONOUS PROGRAMMING, M**********R

Page 81: How to build mobile API with Node.js
Page 82: How to build mobile API with Node.js
Page 83: How to build mobile API with Node.js
Page 84: How to build mobile API with Node.js

ASYNC TO RESCUE

https://github.com/caolan/async

Page 85: How to build mobile API with Node.js

https://github.com/caolan/async

Page 86: How to build mobile API with Node.js

TO NODE OR NOT TO NODE

Page 87: How to build mobile API with Node.js

DEVELOP FAST DEPLOY FAST

IT’S JAVASCRIPT

Page 88: How to build mobile API with Node.js

IT’S JAVASCRIPT NOT SO MATURE

NOT FOR CPU-INTENSIVE JOBS

Page 89: How to build mobile API with Node.js

THANK YOU