node.js dublin meetup april 2014

Download Node.js Dublin Meetup April 2014

Post on 28-Aug-2014

1.024 views

Category:

Software

1 download

Embed Size (px)

DESCRIPTION

 

TRANSCRIPT

  • Enterprise Node.js Development Damian Beresford Twitter: @dberesford @feedhenry 1 Node.js Dublin April 2014
  • FeedHenry Platform
  • Customers Customers Transport Law Enforcement Utilities Aviation Medical Hello world Enterprise Proxy Pattern: 3
  • FeedHenry Open Source 4
  • Javascript 5
  • Node.js Anti Patterns Java mind set OOP Monolithic Systems 6
  • Anti Anti Patterns Data! Functions! Modules! Callbacks, async, etc Functional Programming Underscore Start with _each, _map, _filter, _reduce Unix/KISS mindset Microservices 7
  • Futurology Promises Generators github.com/visionmedia/co Reactive Programming Reactive Manifesto RxJS Bacon.js 8
  • Testing Stack Turbo test runner Istanbul code coverage Proxyquire mock your requires Grunt ties it all together See FeedHenry Node.js Cloud Testing Guide 9
  • 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
  • Testing - Istanbul Code coverage with Istanbul 11 Jenkins/CI integration Express Middleware dynamic code coverage
  • 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(); }); };
  • 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
  • Micro Services martinfowler.com/articles/microservices.html yobriefca.se/blog/2013/04/29/micro-service-architecture slideshare.net/michaelneale/microservices-and-functional-programming klangism.tumblr.com/post/80087171446/microservices richardrodger.com/monolithic-nodejs 14
  • 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
  • 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
  • Misc Private NPM Registry: npm delegate (may move to Kappa) Docker container awesomeness API Blueprint readme on steroids 17
  • API Blueprint 18
  • API Blueprint 19
  • Thank you.. Tanx! www.feedhenry.com/ for more 20