Transcript
Page 1: Node.js Dublin Meetup April 2014

© Copyright FeedHenry Ltd. 2013

Enterprise Node.js Development

Damian BeresfordTwitter: @dberesford

@feedhenry

1

Node.js Dublin April 2014

Page 2: Node.js Dublin Meetup April 2014

© Copyright FeedHenry Ltd. 2013

FeedHenry Platform

Page 3: Node.js Dublin Meetup April 2014

© Copyright FeedHenry Ltd. 2013

Customers

• Customers• Transport• Law Enforcement• Utilities• Aviation• Medical

• ‘Hello world’ Enterprise Proxy Pattern:

3

Page 4: Node.js Dublin Meetup April 2014

© Copyright FeedHenry Ltd. 2013

FeedHenry Open Source

4

Page 5: Node.js Dublin Meetup April 2014

© Copyright FeedHenry Ltd. 2013

Javascript

5

Page 6: Node.js Dublin Meetup April 2014

© Copyright FeedHenry Ltd. 2013

Node.js Anti Patterns

• Java mind set

• OOP

• Monolithic Systems

6

Page 7: Node.js Dublin Meetup April 2014

© Copyright FeedHenry Ltd. 2013

Anti Anti Patterns• Data! Functions! Modules!

• Callbacks, async, etc

• Functional Programming

• Underscore• Start with _each, _map, _filter, _reduce

• Unix/KISS mindset

• Microservices

7

Page 8: Node.js Dublin Meetup April 2014

© Copyright FeedHenry Ltd. 2013

Futurology

• Promises

• Generators• github.com/visionmedia/co

• Reactive Programming• Reactive Manifesto• RxJS• Bacon.js

8

Page 10: Node.js Dublin Meetup April 2014

© Copyright FeedHenry Ltd. 2013

Testing Stack - Turbo

• Turbo • Test runner burn out – tight coupling of test running and code coverage• No fluff, no nuff, just executes exported functions in your test files• Per-file and global setUp and tearDown• Parallel by default – encourages stateless tests

10

Page 11: Node.js Dublin Meetup April 2014

© Copyright FeedHenry Ltd. 2013

Testing - Istanbul

• Code coverage with Istanbul

11

• Jenkins/CI integration

• Express Middleware – dynamic code coverage

Page 12: Node.js Dublin Meetup April 2014

© Copyright FeedHenry Ltd. 2013

Testing - Proxyquire

• Proxyquire: “Proxies nodejs require in order to allow overriding of dependencies during testing”

12

var request = require('request');

exports.search = function(params, cb) {

request('https://www.google.ie/?q=foo#q=foo', function(err, res, body) {

if (err) return cb(err);

return cb(null, body);

});

};exports.it_should_test_search = function(finish) {

var mockRequest = function(url, cb) {

console.log("in mock call to request!");

return cb(null, {}, 'Sample data!!');

};

var main = proxyquire('lib/foo.js', {request: mockRequest});

main.search(null, function(err, data) {

assert.ok(!err, 'Unexpected error: ' + util.inspect(err));

console.log("got data from search: ", data);

finish();

});

};

Page 13: Node.js Dublin Meetup April 2014

© Copyright FeedHenry Ltd. 2013

Testing – unit vs acceptance

• Eyes on code!

• unit tests should require no external dependencies, external services should be mocked out (e.g. internet access, writing to file/database, etc)

• unit tests should be super quick to run

• unit tests should be reliable as no external dependencies

• unit tests should just test your own logic

• acceptance tests can require external dependencies, which do require setup (which should be well documented!)

• as such they can take longer to run

• acceptance tests are a more 'end to end' philosophy

13

Page 15: Node.js Dublin Meetup April 2014

© Copyright FeedHenry Ltd. 2013

Mirco Services

• Mix of Message Bus and API

• API - JSON in JSON out (robustness principal)

• Message Bus – Rabbit MQ

• Not just node.js, DropWizard for Java

• Continuous Integration - Small Production Deploys

• Operations – monitor all the things

• Dedicated Ops and Support teams

15

Page 16: Node.js Dublin Meetup April 2014

© Copyright FeedHenry Ltd. 2013

Mirco Services – complexity

• Not a silver bullet – but does help with complexity• Still deal with lots of business rules, moving parts, etc• Easy !== Simple• Work at simplicity

• Need Master Builders to keep all the balls in the air

• Boxology

16

Page 17: Node.js Dublin Meetup April 2014

© Copyright FeedHenry Ltd. 2013

Misc

• Private NPM Registry: npm delegate (may move to Kappa)

• Docker – container awesomeness

• API Blueprint – readme on steroids

17

Page 18: Node.js Dublin Meetup April 2014

© Copyright FeedHenry Ltd. 2013

API Blueprint

18

Page 19: Node.js Dublin Meetup April 2014

© Copyright FeedHenry Ltd. 2013

API Blueprint

19

Page 20: Node.js Dublin Meetup April 2014

© Copyright FeedHenry Ltd. 2013

Thank you..

• Tanx!

• www.feedhenry.com/ for more…

20


Top Related