Node.js Dublin Meetup April 2014

4,913 views

Published on

Published in: Software, Technology
0 Comments
4 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
4,913
On SlideShare
0
From Embeds
0
Number of Embeds
2,404
Actions
Shares
0
Downloads
13
Comments
0
Likes
4
Embeds 0
No embeds

No notes for slide

Node.js Dublin Meetup April 2014

  1. 1. Enterprise Node.js Development Damian Beresford Twitter: @dberesford @feedhenry 1 Node.js Dublin April 2014
  2. 2. FeedHenry Platform
  3. 3. Customers • Customers • Transport • Law Enforcement • Utilities • Aviation • Medical • „Hello world‟ Enterprise Proxy Pattern: 3
  4. 4. FeedHenry Open Source 4
  5. 5. Javascript 5
  6. 6. Node.js Anti Patterns • Java mind set • OOP • Monolithic Systems 6
  7. 7. Anti Anti Patterns • Data! Functions! Modules! • Callbacks, async, etc • Functional Programming • Underscore • Start with _each, _map, _filter, _reduce • Unix/KISS mindset • Microservices 7
  8. 8. Futurology • Promises • Generators • github.com/visionmedia/co • Reactive Programming • Reactive Manifesto • RxJS • Bacon.js 8
  9. 9. Testing Stack • Turbo – test runner • Istanbul – code coverage • Proxyquire – mock your require‟s • Grunt – ties it all together • See FeedHenry Node.js Cloud Testing Guide 9
  10. 10. 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
  11. 11. Testing - Istanbul • Code coverage with Istanbul 11 • Jenkins/CI integration • Express Middleware – dynamic code coverage
  12. 12. 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(); }); };
  13. 13. 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
  14. 14. 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
  15. 15. 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
  16. 16. 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
  17. 17. Misc • Private NPM Registry: npm delegate (may move to Kappa) • Docker – container awesomeness • API Blueprint – readme on steroids 17
  18. 18. API Blueprint 18
  19. 19. API Blueprint 19
  20. 20. Thank you.. • Tanx! • www.feedhenry.com/ for more… 20

×