SlideShare a Scribd company logo
Tim Messerschmidt
@SeraAndroid
LondonJS Conf 2014
A story of!
technical debt
Application stacks at PayPal

C++

Java
Environments & Lean UX

Prototyping

Production
Application stacks at PayPal

C++
XSL

Java
JSP
Node
JS
Node & JS at PayPal
Moving away from Java architecture
•  CSS, HTML and even JS in Java
•  Originally replaced by JSP

Rapid development & deployment cycles
• 
• 
• 
• 

Open Source Stack
Bootstrap for frontend
JavaScript templating via Dust
V8 in PayPal’s C++ stack for legacy app UI
New stack at PayPal

Dust
C++

Java
 Node
Advantages of Node
Results of using Node at PayPal
•  Teams between 1/3 to 1/10 of Java teams
•  Doubled requests per second
•  35% decrease in average response time
•  Lines of code shrunk by factor 3 to 5
•  Development twice as fast
•  JS both on frontend and backend
Release the!
Kraken!
What is Kraken?
A JS suite on top of Node.js and Express
Preconfigured with different best practices
and tools:


• 
• 
• 
• 
• 

Dust for templates
LESS as CSS preprocessor
RequireJS as JS file and module loader
Grunt for running tasks
Runtime updates for UI code
But why?!
Project structure
Opinionated about separation of logic and
presentation


• 
• 
• 
• 
• 
• 

/config
/controllers
/models
/public/templates
/locales
/tests
Makara

Lusca

Adaro

Kappa
… and many more
Makara
Local content bundles
Internationalization support for Node apps

var i18n = require('makara');	
var provider = i18n.create(config);	
provider.getBundle('index', 'en_US', function (err, bundle) {	
var string = bundle.get('key');	
});
Property files for Makara
index.title=KrakenJS at LondonJS Conf	
index.speaker=Tim Messerschmidt	
index.greeting=Ahoi {attendeeName}!	
	
# A list	
index.speakers[0]=Lea Verou	
index.speakers[1]=Peter-Paul Koch	
Index.speakers[2]=Hannah Wolfe	
	
# A map	
index.sponsors[PP]=PayPal	
index.sponsors[GH]=GitHub	
	
# And subkeys	
index.conference.language=JS
Makara in use
Defining multiple values
/locales/US/en/index.properties	
•  index.greeting=Hello {name}!	

/locales/ES/es/index.properties	
•  index.greeting=Hola {name}!	
	

Accessing keys in templates
<h1>{@pre type="content" key="index.greeting"/}</h1>
Lusca
Security settings against various vulnerabilities


Cross-site request forgery support
Clickjacking / X-Frame-Options
Output escaping against XSS via Dust
Content Security Policy
Lusca configuration
Configuration in middleware.json	


"appsec": {	
	"csrf": true,	
	"csp": false,	
	"p3p": false,	
	"xframe": "SAMEORIGIN”	
}	
	

… or using Lusca’s methods
Lusca against CSRF
A token is added to the session automatically


var express = require('express'),	
	appsec = require('lusca'),
		
	server = express();	
	
server.use(appsec.csrf());	



The template needs to return the token:


<input type="hidden" name="_csrf" value="{_csrf}”>
Adaro
Brings Dust as default templating engine
Designed to work together with Makara


dustjs.onLoad = function (name, context, callback) {	
	// Custom file read/processing pipline	
	callback(err, str);	
}	
	
app.engine('dust', dustjs.dust({ cache: false }));	
app.set('view engine', 'dust');
Templating with Dust
Layout
	

<html>	
<body>	
{>"{_main}"/}	
</body>	
</html>	
	

Content page as partial


<div>Hello!</div>	
	
dust.render(’partial', { layout: ’template' }, ...);
Templating with Dust
Sections


{#modules}	
{name}, {description}{~n}	
{/modules}	
	

View context	


{ 	
	modules: [	
	
	{ name: “Makara”, description: “i18n” },	
	
	{ name: “Lusca”, description: “security settings” }	
	]	
}
Templating with Dust
Conditionals


{#modules}	
	{name}, {description}{~n}	
{:else}	
	No modules supported :(	
{/modules}	
	
{?modules}	
	modules exists!	
{/modules}	
	
{^modules}	
	No modules!	
{/modules}
Kappa
Serves as NPM Proxy
Enables support for private npm repos
Based on npm-delegate
hapi support
Global or local installation


npm install -g kappa	
kappa -c config.json
Configuring Kraken
Lives in /config/app.json	


Development vs. Production environments
•  2nd configuration allowed:
–  app-development.json	

•  Usage of NODE_ENV for environment
nconf for credentials and other variables
The Generator
Getting started
sudo npm install -g generator-kraken	
	
yo kraken	
	
,'""`.	
/ _ _ 	
|(@)(@)|
Release the Kraken!	
) __ (	
/,'))((`.	
(( (( )) ))	
` `)(' /'
Generation
yo kraken:controller myController	
	
Respond to XHR requests? (Y/n)	
	
create controllers/myController.js	
create test/myController.js
Result without XHR
var myModel = require('../models/model');	
	
module.exports = function (app) {	
	var model = new myModel();	
	
	app.get(’/ahoi', function (req, res) {
	 	res.render(’ahoi', model);	
	});	
};
Result with XHR
app.get('/ahoiXHR', function (req, res) {	
	res.format({	
	 	json: function () {	
	 	 	res.json(model);	
	 	},	
	 	html: function () {	
	 	 	res.render(’ahoiXHR', model);	
	 	}	
	});	
});
Models
yo kraken:model unicorn	
	
create models/unicorn.js	
	
module.exports = function UnicornModel() {	
	return {	
	 	name: ‘Charlie’	
	};	
};
Summary
Thanks!


Tim Messerschmidt
@SeraAndroid
tmesserschmidt@paypal.com
slideshare.com/paypal

More Related Content

PPTX
Kraken js at paypal
Lenny Markus
 
PDF
Kraken Front-Trends
PayPal
 
PDF
All aboard the NodeJS Express
David Boyer
 
PPT
Building your first Node app with Connect & Express
Christian Joudrey
 
PPTX
Intro to Node.js (v1)
Chris Cowan
 
PPT
Node js presentation
martincabrera
 
PDF
NodeJS for Beginner
Apaichon Punopas
 
KEY
Introduction to node.js
jacekbecela
 
Kraken js at paypal
Lenny Markus
 
Kraken Front-Trends
PayPal
 
All aboard the NodeJS Express
David Boyer
 
Building your first Node app with Connect & Express
Christian Joudrey
 
Intro to Node.js (v1)
Chris Cowan
 
Node js presentation
martincabrera
 
NodeJS for Beginner
Apaichon Punopas
 
Introduction to node.js
jacekbecela
 

What's hot (20)

PPTX
Nodejs intro
Ndjido Ardo BAR
 
PDF
Nodejs Explained with Examples
Gabriele Lana
 
PPTX
introduction to node.js
orkaplan
 
PDF
Comet with node.js and V8
amix3k
 
PDF
Nodejs in Production
William Bruno Moraes
 
PDF
Introduction to Node.js: What, why and how?
Christian Joudrey
 
KEY
Writing robust Node.js applications
Tom Croucher
 
PPT
RESTful API In Node Js using Express
Jeetendra singh
 
PDF
Node Architecture and Getting Started with Express
jguerrero999
 
PPTX
Introduction to Node.js
Vikash Singh
 
PDF
Node.js - A Quick Tour
Felix Geisendörfer
 
PPT
JavaScript Event Loop
Thomas Hunter II
 
PDF
Server Side Event Driven Programming
Kamal Hussain
 
KEY
A million connections and beyond - Node.js at scale
Tom Croucher
 
PPTX
Introduction to Node js
Akshay Mathur
 
PPTX
Java script at backend nodejs
Amit Thakkar
 
PDF
Node ppt
Tamil Selvan R S
 
PDF
[212] large scale backend service develpment
NAVER D2
 
PDF
Understanding the Single Thread Event Loop
TorontoNodeJS
 
PDF
Non-blocking I/O, Event loops and node.js
Marcus Frödin
 
Nodejs intro
Ndjido Ardo BAR
 
Nodejs Explained with Examples
Gabriele Lana
 
introduction to node.js
orkaplan
 
Comet with node.js and V8
amix3k
 
Nodejs in Production
William Bruno Moraes
 
Introduction to Node.js: What, why and how?
Christian Joudrey
 
Writing robust Node.js applications
Tom Croucher
 
RESTful API In Node Js using Express
Jeetendra singh
 
Node Architecture and Getting Started with Express
jguerrero999
 
Introduction to Node.js
Vikash Singh
 
Node.js - A Quick Tour
Felix Geisendörfer
 
JavaScript Event Loop
Thomas Hunter II
 
Server Side Event Driven Programming
Kamal Hussain
 
A million connections and beyond - Node.js at scale
Tom Croucher
 
Introduction to Node js
Akshay Mathur
 
Java script at backend nodejs
Amit Thakkar
 
[212] large scale backend service develpment
NAVER D2
 
Understanding the Single Thread Event Loop
TorontoNodeJS
 
Non-blocking I/O, Event loops and node.js
Marcus Frödin
 
Ad

Viewers also liked (19)

TXT
How to open paypal in pakistan
khanrafi
 
PDF
Bill Scott - GetJar
Mobile Monday Amsterdam
 
PPTX
Kraken
PayPal
 
PPTX
Introduction to node.js
Arun Kumar Arjunan
 
PDF
Paypal Tutorial: How to Open and Set- Up Your Account
Rea A.
 
PDF
Kicking Up the Dust with Node JS
Bill Scott
 
PPT
Social media strategies for PTC
mba8500
 
PPTX
سئو و بهینه سازی سایت به زبان ساده قسمت اول
kasra khoshkhooy
 
PDF
Grafico diario del dax perfomance index para el 12 03-2012
Experiencia Trading
 
PDF
LPL_Presentation_-_Q4_2014_-_12_8_14
Tony Palazzo
 
PPTX
Information Architecture class10 03 20
Marti Gukeisen
 
PDF
FIFA Teams & Their Hotel Demands
ixigo.com
 
PDF
Maneuver Warfare and Other Badass Habits of a Lean Product Developer

Marko Taipale
 
PDF
Chef & OpenStack: OSCON 2014
Matt Ray
 
PPTX
Super Powered SEO Tips for Auto Dealers
Greg Gifford
 
PDF
How to charge what you are worth for solo-based businesses
Jackie B Peterson
 
PPTX
20160426 AIIM16 CIP Preconference Briefing
Jesse Wilkins
 
PDF
Yoshis caanoo emulator_fact_sheets_v03
Rubén de Celis Hernández
 
PPTX
10 ways to improve seo ranking
Mindtree
 
How to open paypal in pakistan
khanrafi
 
Bill Scott - GetJar
Mobile Monday Amsterdam
 
Kraken
PayPal
 
Introduction to node.js
Arun Kumar Arjunan
 
Paypal Tutorial: How to Open and Set- Up Your Account
Rea A.
 
Kicking Up the Dust with Node JS
Bill Scott
 
Social media strategies for PTC
mba8500
 
سئو و بهینه سازی سایت به زبان ساده قسمت اول
kasra khoshkhooy
 
Grafico diario del dax perfomance index para el 12 03-2012
Experiencia Trading
 
LPL_Presentation_-_Q4_2014_-_12_8_14
Tony Palazzo
 
Information Architecture class10 03 20
Marti Gukeisen
 
FIFA Teams & Their Hotel Demands
ixigo.com
 
Maneuver Warfare and Other Badass Habits of a Lean Product Developer

Marko Taipale
 
Chef & OpenStack: OSCON 2014
Matt Ray
 
Super Powered SEO Tips for Auto Dealers
Greg Gifford
 
How to charge what you are worth for solo-based businesses
Jackie B Peterson
 
20160426 AIIM16 CIP Preconference Briefing
Jesse Wilkins
 
Yoshis caanoo emulator_fact_sheets_v03
Rubén de Celis Hernández
 
10 ways to improve seo ranking
Mindtree
 
Ad

Similar to KrakenJS (20)

PDF
Kraken at DevCon TLV
Tim Messerschmidt
 
PPTX
Sst hackathon express
Aeshan Wijetunge
 
PPTX
Node.js Web Apps @ ebay scale
Dmytro Semenov
 
PPTX
Kraken.js Lab Primer
Aeshan Wijetunge
 
PPTX
Ite express labs
Aeshan Wijetunge
 
PDF
Why we released the kraken
Cristiano Betta
 
PPTX
Node.js primer for ITE students
Quhan Arunasalam
 
PDF
Clash of the Titans: Releasing the Kraken | NodeJS @paypal
Bill Scott
 
PDF
Node.js Workshop
Quhan Arunasalam
 
PPT
IBM and Node.js - Old Doge, New Tricks
Dejan Glozic
 
PDF
What is Node.js? (ICON UK)
Tim Davis
 
KEY
20120306 dublin js
Richard Rodger
 
PPTX
Take the Fastest Path to Node.Js Application Development with Bitnami & AWS L...
Bitnami
 
PDF
Breaking the Server-Client Divide with Node.js and React
Dejan Glozic
 
PPTX
Quick workflow of a nodejs api
Paolo Carrasco Mori
 
PPTX
Node.js primer
Quhan Arunasalam
 
PPTX
Zero to Hipster with the M.I.K.E. Stack
Jen Looper
 
KEY
20120802 timisoara
Richard Rodger
 
PPTX
Connect js nodejs_api_shubhra
Shubhra Kar
 
PDF
Node.js Zurich Meetup #1
marcbachmann
 
Kraken at DevCon TLV
Tim Messerschmidt
 
Sst hackathon express
Aeshan Wijetunge
 
Node.js Web Apps @ ebay scale
Dmytro Semenov
 
Kraken.js Lab Primer
Aeshan Wijetunge
 
Ite express labs
Aeshan Wijetunge
 
Why we released the kraken
Cristiano Betta
 
Node.js primer for ITE students
Quhan Arunasalam
 
Clash of the Titans: Releasing the Kraken | NodeJS @paypal
Bill Scott
 
Node.js Workshop
Quhan Arunasalam
 
IBM and Node.js - Old Doge, New Tricks
Dejan Glozic
 
What is Node.js? (ICON UK)
Tim Davis
 
20120306 dublin js
Richard Rodger
 
Take the Fastest Path to Node.Js Application Development with Bitnami & AWS L...
Bitnami
 
Breaking the Server-Client Divide with Node.js and React
Dejan Glozic
 
Quick workflow of a nodejs api
Paolo Carrasco Mori
 
Node.js primer
Quhan Arunasalam
 
Zero to Hipster with the M.I.K.E. Stack
Jen Looper
 
20120802 timisoara
Richard Rodger
 
Connect js nodejs_api_shubhra
Shubhra Kar
 
Node.js Zurich Meetup #1
marcbachmann
 

More from PayPal (20)

PPTX
PayPal's Private Cloud @ Scale
PayPal
 
PDF
Death To Passwords Droid Edition
PayPal
 
PPTX
Future Of Payments
PayPal
 
PDF
The web can do that better - My adventure with HTML5 Vide, WebRTC and Shared ...
PayPal
 
PDF
Death To Passwords
PayPal
 
PPTX
Battle Hack London Intro
PayPal
 
PPTX
Authentication for Droids
PayPal
 
PDF
Concrete indentity really getting to know your users
PayPal
 
PDF
Online Identity: Getting to know your users
PayPal
 
PPTX
Mobile payments at Droidcon Eastern Europe
PayPal
 
PPTX
Reinvigorating Stagnant Innovation Through Your Developer Network
PayPal
 
PDF
Open Identity - getting to know your users
PayPal
 
PPTX
The Profitable Startup
PayPal
 
PDF
Startup Highway Workshop
PayPal
 
PDF
Droidcon Paris: The new Android SDK
PayPal
 
PPTX
Berlin Battle hack presentation
PayPal
 
PDF
From Good To Great
PayPal
 
PDF
Hack & Tell
PayPal
 
PDF
Payments for the REST of us
PayPal
 
PDF
Droidcon DE 2013
PayPal
 
PayPal's Private Cloud @ Scale
PayPal
 
Death To Passwords Droid Edition
PayPal
 
Future Of Payments
PayPal
 
The web can do that better - My adventure with HTML5 Vide, WebRTC and Shared ...
PayPal
 
Death To Passwords
PayPal
 
Battle Hack London Intro
PayPal
 
Authentication for Droids
PayPal
 
Concrete indentity really getting to know your users
PayPal
 
Online Identity: Getting to know your users
PayPal
 
Mobile payments at Droidcon Eastern Europe
PayPal
 
Reinvigorating Stagnant Innovation Through Your Developer Network
PayPal
 
Open Identity - getting to know your users
PayPal
 
The Profitable Startup
PayPal
 
Startup Highway Workshop
PayPal
 
Droidcon Paris: The new Android SDK
PayPal
 
Berlin Battle hack presentation
PayPal
 
From Good To Great
PayPal
 
Hack & Tell
PayPal
 
Payments for the REST of us
PayPal
 
Droidcon DE 2013
PayPal
 

Recently uploaded (20)

PDF
The Future of Mobile Is Context-Aware—Are You Ready?
iProgrammer Solutions Private Limited
 
PDF
Peak of Data & AI Encore - Real-Time Insights & Scalable Editing with ArcGIS
Safe Software
 
PDF
Unlocking the Future- AI Agents Meet Oracle Database 23ai - AIOUG Yatra 2025.pdf
Sandesh Rao
 
PPTX
Applied-Statistics-Mastering-Data-Driven-Decisions.pptx
parmaryashparmaryash
 
PDF
Responsible AI and AI Ethics - By Sylvester Ebhonu
Sylvester Ebhonu
 
PDF
CIFDAQ's Market Wrap : Bears Back in Control?
CIFDAQ
 
PPTX
cloud computing vai.pptx for the project
vaibhavdobariyal79
 
PDF
SparkLabs Primer on Artificial Intelligence 2025
SparkLabs Group
 
PPTX
IT Runs Better with ThousandEyes AI-driven Assurance
ThousandEyes
 
PPTX
AI and Robotics for Human Well-being.pptx
JAYMIN SUTHAR
 
PPTX
The Future of AI & Machine Learning.pptx
pritsen4700
 
PDF
NewMind AI Weekly Chronicles - July'25 - Week IV
NewMind AI
 
PDF
Doc9.....................................
SofiaCollazos
 
PDF
Google I/O Extended 2025 Baku - all ppts
HusseinMalikMammadli
 
PDF
Security features in Dell, HP, and Lenovo PC systems: A research-based compar...
Principled Technologies
 
PPTX
The-Ethical-Hackers-Imperative-Safeguarding-the-Digital-Frontier.pptx
sujalchauhan1305
 
PDF
Research-Fundamentals-and-Topic-Development.pdf
ayesha butalia
 
PDF
How Open Source Changed My Career by abdelrahman ismail
a0m0rajab1
 
PDF
AI Unleashed - Shaping the Future -Starting Today - AIOUG Yatra 2025 - For Co...
Sandesh Rao
 
PDF
Orbitly Pitch Deck|A Mission-Driven Platform for Side Project Collaboration (...
zz41354899
 
The Future of Mobile Is Context-Aware—Are You Ready?
iProgrammer Solutions Private Limited
 
Peak of Data & AI Encore - Real-Time Insights & Scalable Editing with ArcGIS
Safe Software
 
Unlocking the Future- AI Agents Meet Oracle Database 23ai - AIOUG Yatra 2025.pdf
Sandesh Rao
 
Applied-Statistics-Mastering-Data-Driven-Decisions.pptx
parmaryashparmaryash
 
Responsible AI and AI Ethics - By Sylvester Ebhonu
Sylvester Ebhonu
 
CIFDAQ's Market Wrap : Bears Back in Control?
CIFDAQ
 
cloud computing vai.pptx for the project
vaibhavdobariyal79
 
SparkLabs Primer on Artificial Intelligence 2025
SparkLabs Group
 
IT Runs Better with ThousandEyes AI-driven Assurance
ThousandEyes
 
AI and Robotics for Human Well-being.pptx
JAYMIN SUTHAR
 
The Future of AI & Machine Learning.pptx
pritsen4700
 
NewMind AI Weekly Chronicles - July'25 - Week IV
NewMind AI
 
Doc9.....................................
SofiaCollazos
 
Google I/O Extended 2025 Baku - all ppts
HusseinMalikMammadli
 
Security features in Dell, HP, and Lenovo PC systems: A research-based compar...
Principled Technologies
 
The-Ethical-Hackers-Imperative-Safeguarding-the-Digital-Frontier.pptx
sujalchauhan1305
 
Research-Fundamentals-and-Topic-Development.pdf
ayesha butalia
 
How Open Source Changed My Career by abdelrahman ismail
a0m0rajab1
 
AI Unleashed - Shaping the Future -Starting Today - AIOUG Yatra 2025 - For Co...
Sandesh Rao
 
Orbitly Pitch Deck|A Mission-Driven Platform for Side Project Collaboration (...
zz41354899
 

KrakenJS

  • 3. Application stacks at PayPal C++ Java
  • 4. Environments & Lean UX Prototyping Production
  • 5. Application stacks at PayPal C++ XSL Java JSP Node JS
  • 6. Node & JS at PayPal Moving away from Java architecture •  CSS, HTML and even JS in Java •  Originally replaced by JSP Rapid development & deployment cycles •  •  •  •  Open Source Stack Bootstrap for frontend JavaScript templating via Dust V8 in PayPal’s C++ stack for legacy app UI
  • 7. New stack at PayPal Dust C++ Java Node
  • 8. Advantages of Node Results of using Node at PayPal •  Teams between 1/3 to 1/10 of Java teams •  Doubled requests per second •  35% decrease in average response time •  Lines of code shrunk by factor 3 to 5 •  Development twice as fast •  JS both on frontend and backend
  • 10. What is Kraken? A JS suite on top of Node.js and Express Preconfigured with different best practices and tools: •  •  •  •  •  Dust for templates LESS as CSS preprocessor RequireJS as JS file and module loader Grunt for running tasks Runtime updates for UI code
  • 12. Project structure Opinionated about separation of logic and presentation •  •  •  •  •  •  /config /controllers /models /public/templates /locales /tests
  • 14. … and many more
  • 15. Makara Local content bundles Internationalization support for Node apps var i18n = require('makara'); var provider = i18n.create(config); provider.getBundle('index', 'en_US', function (err, bundle) { var string = bundle.get('key'); });
  • 16. Property files for Makara index.title=KrakenJS at LondonJS Conf index.speaker=Tim Messerschmidt index.greeting=Ahoi {attendeeName}! # A list index.speakers[0]=Lea Verou index.speakers[1]=Peter-Paul Koch Index.speakers[2]=Hannah Wolfe # A map index.sponsors[PP]=PayPal index.sponsors[GH]=GitHub # And subkeys index.conference.language=JS
  • 17. Makara in use Defining multiple values /locales/US/en/index.properties •  index.greeting=Hello {name}! /locales/ES/es/index.properties •  index.greeting=Hola {name}! Accessing keys in templates <h1>{@pre type="content" key="index.greeting"/}</h1>
  • 18. Lusca Security settings against various vulnerabilities Cross-site request forgery support Clickjacking / X-Frame-Options Output escaping against XSS via Dust Content Security Policy
  • 19. Lusca configuration Configuration in middleware.json "appsec": { "csrf": true, "csp": false, "p3p": false, "xframe": "SAMEORIGIN” } … or using Lusca’s methods
  • 20. Lusca against CSRF A token is added to the session automatically var express = require('express'), appsec = require('lusca'), server = express(); server.use(appsec.csrf()); The template needs to return the token: <input type="hidden" name="_csrf" value="{_csrf}”>
  • 21. Adaro Brings Dust as default templating engine Designed to work together with Makara dustjs.onLoad = function (name, context, callback) { // Custom file read/processing pipline callback(err, str); } app.engine('dust', dustjs.dust({ cache: false })); app.set('view engine', 'dust');
  • 22. Templating with Dust Layout <html> <body> {>"{_main}"/} </body> </html> Content page as partial <div>Hello!</div> dust.render(’partial', { layout: ’template' }, ...);
  • 23. Templating with Dust Sections {#modules} {name}, {description}{~n} {/modules} View context { modules: [ { name: “Makara”, description: “i18n” }, { name: “Lusca”, description: “security settings” } ] }
  • 24. Templating with Dust Conditionals {#modules} {name}, {description}{~n} {:else} No modules supported :( {/modules} {?modules} modules exists! {/modules} {^modules} No modules! {/modules}
  • 25. Kappa Serves as NPM Proxy Enables support for private npm repos Based on npm-delegate hapi support Global or local installation npm install -g kappa kappa -c config.json
  • 26. Configuring Kraken Lives in /config/app.json Development vs. Production environments •  2nd configuration allowed: –  app-development.json •  Usage of NODE_ENV for environment nconf for credentials and other variables
  • 28. Getting started sudo npm install -g generator-kraken yo kraken ,'""`. / _ _ |(@)(@)| Release the Kraken! ) __ ( /,'))((`. (( (( )) )) ` `)(' /'
  • 29. Generation yo kraken:controller myController Respond to XHR requests? (Y/n) create controllers/myController.js create test/myController.js
  • 30. Result without XHR var myModel = require('../models/model'); module.exports = function (app) { var model = new myModel(); app.get(’/ahoi', function (req, res) { res.render(’ahoi', model); }); };
  • 31. Result with XHR app.get('/ahoiXHR', function (req, res) { res.format({ json: function () { res.json(model); }, html: function () { res.render(’ahoiXHR', model); } }); });
  • 32. Models yo kraken:model unicorn create models/unicorn.js module.exports = function UnicornModel() { return { name: ‘Charlie’ }; };