SlideShare une entreprise Scribd logo
1  sur  33
seneca
 nodejsdublin
16 August 2012

Richard Rodger
   @rjrodger
hello
nodejsdublin
 • let's start a community project
 • how Node.js modules work
 • introducing the seneca module
getting
    started
• how do you learn Node.js?
• how do you contribute to Node.js?
• how do you get a job doing Node.js?
your
community
• nodejsdublin is for you
• here to help you learn
• here to build a great community
let's start
 a project
• less talking, more coding!
• community project with many coders
• something with lots of small pieces
seneca
• A Minimal Viable Product toolkit
• let's you build a startup in a weekend :)
• for more about MVPs: http://bit.ly/N25FlZ
• Lucius Annaeus Seneca, 4 BC – AD 65
• You have to be stoic to do a startup
• "increases are of sluggish growth, but the way to
  ruin is rapid"
                             * http://cassandralegacy.blogspot.ie/2011/08/seneca-effect-origins-of-collapse.html
sign up
• Tweet @nodejsdublin with #seneca
• Mail me: richard.rodger@nearform.com
• Code: github.com/nodejsdublin/seneca
node.js
   modules
• basic building blocks of Node.js apps
• no special syntax; plain old JavaScript
• no version conflicts!
using modules

var _ = require("underscore");

var threes = _.map([1, 2, 3], function(n){ return n*3 });
console.log( threes );
// prints [3, 6, 9]



var mongo = require('mongodb');

var host = 'localhost';
var port = 27017;

var db   = new mongo.Db( 'mydatabase',
  new mongo.Server(host, port, {}), {});

db.open(function(err, db) { ... }
cool
        modules
• express - JSP/ASP style dynamic server-side pages
• socket.io - HTML5 real-time web sockets that "just work"
• request - easy outbound calls to web services
using npm
• npmjs.org - module repository of record
• usage: npm install modulename
• modules live in local node_modules folder
how to pick
 a module
•   serious modules are on https://github.com/joyent/node/wiki/modules
•   popularity! check watchers/issues on github
•   documentation, including third party blogs
•   ask the community: http://nodejs.org/community/
why npm
  rocks
• modules are installed separately for each project
• dependencies are also installed separately
• no global conflicts, no cross-dependency
  conflicts
package.json
 • defines a module; lists dependencies
 • always create one for each project
 • npm install will set up dependencies for you!
package.json
{
  "name"         : "optimist",
  "version"      : "0.3.4",
  "description" : "Light-weight option parsing.",
  "main"         : "./index.js",
 
  "dependencies" : {
     "wordwrap" : ">=0.0.2"
  },

  "repository"   : {
    "type" : "git",
    "url" : "http://github.com/substack/node-optimist.git"
  },

  "keywords"    : [ "argument", "args", "option", "parser" ]
  "author"      : { "name" : "James Halliday" },
  "engine"      : { "node" : ">=0.4 }
}
write a
    module
• create a project on github
• npm init - creates package.json for you
• start with lib/modulename.js
modulename.js
"use strict";

function ModuleName() {
  var self = {};

    var private = "hidden";

    self.member = "data";

    self.method = function() { ... };

    return self;
}

exports.ModuleName = ModuleName


                     callingcode.js
    var modulename = require('modulename')

    var instance = new modulename.ModuleName()
parambulator
•   written just for this meetup! - sanity checks JSON data structures
•   https://github.com/rjrodger/parambulator
•   you also need a README.md and LICENSE.txt
•   you really should have unit tests; try the vows module
file structure
parambulator /

      package.json

      README.md

      LICENSE.txt

      lib /

         parambulator.js
publishing a
  module
• the package.json files property is your friend
• register for an account on npmjs.org
• npm publish
• sit back and bask in the glory...
seneca
• nearForm builds web/mobile services
• shared set of features every startup needs
• ... must resist ... let's build a framework!
shared
     features
•   user accounts: login/logout, profile pages, social media, ...
•   email: transactional, promotional, ...
•   e-commerce: gateways, app stores, ...
•   admin: data editors, analytics, audit logs, ..
seneca is in
  production

businesspost.ie   chartaca.com   stanzr.com
command
 pattern
•   actions are represented by a set of properties
•   seneca "executes" them by invoking plugins
•   everything that happens is traceable
•   business logic is insulated from service providers
seneca commands
// register a new user
seneca.act({
   on:       'user',
   cmd:      'register',
   email:    'alice@example.com',
   name:     'Alice',
   password: '1234',
   active:   true
},
function(err, result) { ... })


// send an email
seneca.act({
   on:       'email',
   cmd:      'send',
   to:       'alice@example.com',
   code:     'thanks-for-registering',
   fields:   {name:'Alice'}
},
function(err, result) { ... })
plugins
• everything is a plugin
• plugins provide actions
• plugins are just modules!
seneca plugin
function EchoPlugin() {
  var self = {};
  self.name = 'echo';

    self.init = function(seneca,opts,cb) {

        seneca.add({on:'echo'}, function(args,seneca,cb){
           var out = args
           cb(null,out)
        })

        cb()
    }

    self.service = function() {
      return function(req,res,next){
        if( '/echo' == req.url ) {
          res.writeHead(200);
          res.end(req.url);
        }
        else next();
      }
    }
}

exports.plugin = function() {
  return new EchoPlugin()
}
shared
data model
• Built-in ODM - Object Document Mapper
• You need this to stay sane
• ActiveRecord-ish API with MongoDB-ish queries
seneca data model
var product = seneca.make('product');

product.name = 'Apple';
product.price = 1.99;

product.save$(function(err,savedproduct){
   console.log('generated id: '+savedproduct.id);
})

product.load$('1234',function(err,foundproduct){
   console.log('found product '+foundproduct);
})

product.list$( {price:1.99}, function(err,list){
   for( var i = 0; i < list.length; i++ ) {
     console.log( list[i] );
   }
})
what we
•
 have now
  messy code that kinda sorta works
• a few hackety hack plugins
• no documentation!
what we
     need
• plugins! plugins! plugins!
• documentation ( ... just kidding! I'll do that)
• some nodeknockout.com entries -
   November 10-12th! Fame & Glory Await!
let's code!
• Tweet @nodejsdublin with #seneca
• Mail me: richard.rodger@nearform.com
• Code: github.com/nodejsdublin/seneca

Contenu connexe

Tendances

Java script nirvana in netbeans [con5679]
Java script nirvana in netbeans [con5679]Java script nirvana in netbeans [con5679]
Java script nirvana in netbeans [con5679]Ryan Cuprak
 
Node.js, toy or power tool?
Node.js, toy or power tool?Node.js, toy or power tool?
Node.js, toy or power tool?Ovidiu Dimulescu
 
Mobile gotcha
Mobile gotchaMobile gotcha
Mobile gotchaphegaro
 
Developing in the Cloud
Developing in the CloudDeveloping in the Cloud
Developing in the CloudRyan Cuprak
 
9 anti-patterns for node.js teams
9 anti-patterns for node.js teams9 anti-patterns for node.js teams
9 anti-patterns for node.js teamsJeff Harrell
 
PHP Indonesia - Nodejs Web Development
PHP Indonesia - Nodejs Web DevelopmentPHP Indonesia - Nodejs Web Development
PHP Indonesia - Nodejs Web DevelopmentIrfan Maulana
 
Scalability using Node.js
Scalability using Node.jsScalability using Node.js
Scalability using Node.jsratankadam
 
Why You Should Use MERN Stack for Startup Apps?
Why You Should Use MERN Stack for Startup Apps?Why You Should Use MERN Stack for Startup Apps?
Why You Should Use MERN Stack for Startup Apps?Pixel Crayons
 
Javascript fatigue, 자바스크립트 피로
Javascript fatigue, 자바스크립트 피로Javascript fatigue, 자바스크립트 피로
Javascript fatigue, 자바스크립트 피로Rhio Kim
 
Joshfire factory: Using NodeJS in production
Joshfire factory: Using NodeJS in productionJoshfire factory: Using NodeJS in production
Joshfire factory: Using NodeJS in productionSteren Giannini
 
Hybrid Mobile Development with Apache Cordova and
Hybrid Mobile Development with Apache Cordova and Hybrid Mobile Development with Apache Cordova and
Hybrid Mobile Development with Apache Cordova and Ryan Cuprak
 
JavaScript: Past, Present, Future
JavaScript: Past, Present, FutureJavaScript: Past, Present, Future
JavaScript: Past, Present, FutureJungryul Choi
 
MEAN Stack WeNode Barcelona Workshop
MEAN Stack WeNode Barcelona WorkshopMEAN Stack WeNode Barcelona Workshop
MEAN Stack WeNode Barcelona WorkshopValeri Karpov
 
Engage 2015 - 10 Mistakes You and Every XPages Developer Make. Yes, I said YOU!
Engage 2015 - 10 Mistakes You and Every XPages Developer Make. Yes, I said YOU!Engage 2015 - 10 Mistakes You and Every XPages Developer Make. Yes, I said YOU!
Engage 2015 - 10 Mistakes You and Every XPages Developer Make. Yes, I said YOU!Serdar Basegmez
 
TDD a REST API With Node.js and MongoDB
TDD a REST API With Node.js and MongoDBTDD a REST API With Node.js and MongoDB
TDD a REST API With Node.js and MongoDBValeri Karpov
 
The Dark Side of Single Page Applications
The Dark Side of Single Page ApplicationsThe Dark Side of Single Page Applications
The Dark Side of Single Page ApplicationsDor Kalev
 

Tendances (20)

Java script nirvana in netbeans [con5679]
Java script nirvana in netbeans [con5679]Java script nirvana in netbeans [con5679]
Java script nirvana in netbeans [con5679]
 
Node.js, toy or power tool?
Node.js, toy or power tool?Node.js, toy or power tool?
Node.js, toy or power tool?
 
Mobile gotcha
Mobile gotchaMobile gotcha
Mobile gotcha
 
8 Most Effective Node.js Tools for Developers
8 Most Effective Node.js Tools for Developers8 Most Effective Node.js Tools for Developers
8 Most Effective Node.js Tools for Developers
 
Developing in the Cloud
Developing in the CloudDeveloping in the Cloud
Developing in the Cloud
 
Node js projects
Node js projectsNode js projects
Node js projects
 
9 anti-patterns for node.js teams
9 anti-patterns for node.js teams9 anti-patterns for node.js teams
9 anti-patterns for node.js teams
 
PHP Indonesia - Nodejs Web Development
PHP Indonesia - Nodejs Web DevelopmentPHP Indonesia - Nodejs Web Development
PHP Indonesia - Nodejs Web Development
 
Scalability using Node.js
Scalability using Node.jsScalability using Node.js
Scalability using Node.js
 
Why You Should Use MERN Stack for Startup Apps?
Why You Should Use MERN Stack for Startup Apps?Why You Should Use MERN Stack for Startup Apps?
Why You Should Use MERN Stack for Startup Apps?
 
Javascript fatigue, 자바스크립트 피로
Javascript fatigue, 자바스크립트 피로Javascript fatigue, 자바스크립트 피로
Javascript fatigue, 자바스크립트 피로
 
Joshfire factory: Using NodeJS in production
Joshfire factory: Using NodeJS in productionJoshfire factory: Using NodeJS in production
Joshfire factory: Using NodeJS in production
 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.js
 
Hybrid Mobile Development with Apache Cordova and
Hybrid Mobile Development with Apache Cordova and Hybrid Mobile Development with Apache Cordova and
Hybrid Mobile Development with Apache Cordova and
 
Meanstack overview
Meanstack overviewMeanstack overview
Meanstack overview
 
JavaScript: Past, Present, Future
JavaScript: Past, Present, FutureJavaScript: Past, Present, Future
JavaScript: Past, Present, Future
 
MEAN Stack WeNode Barcelona Workshop
MEAN Stack WeNode Barcelona WorkshopMEAN Stack WeNode Barcelona Workshop
MEAN Stack WeNode Barcelona Workshop
 
Engage 2015 - 10 Mistakes You and Every XPages Developer Make. Yes, I said YOU!
Engage 2015 - 10 Mistakes You and Every XPages Developer Make. Yes, I said YOU!Engage 2015 - 10 Mistakes You and Every XPages Developer Make. Yes, I said YOU!
Engage 2015 - 10 Mistakes You and Every XPages Developer Make. Yes, I said YOU!
 
TDD a REST API With Node.js and MongoDB
TDD a REST API With Node.js and MongoDBTDD a REST API With Node.js and MongoDB
TDD a REST API With Node.js and MongoDB
 
The Dark Side of Single Page Applications
The Dark Side of Single Page ApplicationsThe Dark Side of Single Page Applications
The Dark Side of Single Page Applications
 

Similaire à 20120816 nodejsdublin

Intro to node and mongodb 1
Intro to node and mongodb   1Intro to node and mongodb   1
Intro to node and mongodb 1Mohammad Qureshi
 
Practical Use of MongoDB for Node.js
Practical Use of MongoDB for Node.jsPractical Use of MongoDB for Node.js
Practical Use of MongoDB for Node.jsasync_io
 
Intro To Node.js
Intro To Node.jsIntro To Node.js
Intro To Node.jsChris Cowan
 
WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...Fabio Franzini
 
Introduction to REST API with Node.js
Introduction to REST API with Node.jsIntroduction to REST API with Node.js
Introduction to REST API with Node.jsYoann Gotthilf
 
Node.js Patterns for Discerning Developers
Node.js Patterns for Discerning DevelopersNode.js Patterns for Discerning Developers
Node.js Patterns for Discerning Developerscacois
 
soft-shake.ch - Hands on Node.js
soft-shake.ch - Hands on Node.jssoft-shake.ch - Hands on Node.js
soft-shake.ch - Hands on Node.jssoft-shake.ch
 
SwampDragon presentation: The Copenhagen Django Meetup Group
SwampDragon presentation: The Copenhagen Django Meetup GroupSwampDragon presentation: The Copenhagen Django Meetup Group
SwampDragon presentation: The Copenhagen Django Meetup GroupErnest Jumbe
 
JavaScript Modules Done Right
JavaScript Modules Done RightJavaScript Modules Done Right
JavaScript Modules Done RightMariusz Nowak
 
Automating Complex Setups with Puppet
Automating Complex Setups with PuppetAutomating Complex Setups with Puppet
Automating Complex Setups with PuppetKris Buytaert
 
1.6 米嘉 gobuildweb
1.6 米嘉 gobuildweb1.6 米嘉 gobuildweb
1.6 米嘉 gobuildwebLeo Zhou
 
Writing robust Node.js applications
Writing robust Node.js applicationsWriting robust Node.js applications
Writing robust Node.js applicationsTom Croucher
 
node.js: Javascript's in your backend
node.js: Javascript's in your backendnode.js: Javascript's in your backend
node.js: Javascript's in your backendDavid Padbury
 
Module, AMD, RequireJS
Module, AMD, RequireJSModule, AMD, RequireJS
Module, AMD, RequireJS偉格 高
 
Introduction to Node.js: What, why and how?
Introduction to Node.js: What, why and how?Introduction to Node.js: What, why and how?
Introduction to Node.js: What, why and how?Christian Joudrey
 

Similaire à 20120816 nodejsdublin (20)

Intro to node and mongodb 1
Intro to node and mongodb   1Intro to node and mongodb   1
Intro to node and mongodb 1
 
Practical Use of MongoDB for Node.js
Practical Use of MongoDB for Node.jsPractical Use of MongoDB for Node.js
Practical Use of MongoDB for Node.js
 
Node azure
Node azureNode azure
Node azure
 
Intro To Node.js
Intro To Node.jsIntro To Node.js
Intro To Node.js
 
WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...
 
Introduction to REST API with Node.js
Introduction to REST API with Node.jsIntroduction to REST API with Node.js
Introduction to REST API with Node.js
 
Node.js Patterns for Discerning Developers
Node.js Patterns for Discerning DevelopersNode.js Patterns for Discerning Developers
Node.js Patterns for Discerning Developers
 
soft-shake.ch - Hands on Node.js
soft-shake.ch - Hands on Node.jssoft-shake.ch - Hands on Node.js
soft-shake.ch - Hands on Node.js
 
Wider than rails
Wider than railsWider than rails
Wider than rails
 
Django at Scale
Django at ScaleDjango at Scale
Django at Scale
 
SwampDragon presentation: The Copenhagen Django Meetup Group
SwampDragon presentation: The Copenhagen Django Meetup GroupSwampDragon presentation: The Copenhagen Django Meetup Group
SwampDragon presentation: The Copenhagen Django Meetup Group
 
JavaScript Modules Done Right
JavaScript Modules Done RightJavaScript Modules Done Right
JavaScript Modules Done Right
 
Automating Complex Setups with Puppet
Automating Complex Setups with PuppetAutomating Complex Setups with Puppet
Automating Complex Setups with Puppet
 
Node.js
Node.jsNode.js
Node.js
 
1.6 米嘉 gobuildweb
1.6 米嘉 gobuildweb1.6 米嘉 gobuildweb
1.6 米嘉 gobuildweb
 
Logstash
LogstashLogstash
Logstash
 
Writing robust Node.js applications
Writing robust Node.js applicationsWriting robust Node.js applications
Writing robust Node.js applications
 
node.js: Javascript's in your backend
node.js: Javascript's in your backendnode.js: Javascript's in your backend
node.js: Javascript's in your backend
 
Module, AMD, RequireJS
Module, AMD, RequireJSModule, AMD, RequireJS
Module, AMD, RequireJS
 
Introduction to Node.js: What, why and how?
Introduction to Node.js: What, why and how?Introduction to Node.js: What, why and how?
Introduction to Node.js: What, why and how?
 

Plus de Richard Rodger

Using RAG to create your own Podcast conversations.pdf
Using RAG to create your own Podcast conversations.pdfUsing RAG to create your own Podcast conversations.pdf
Using RAG to create your own Podcast conversations.pdfRichard Rodger
 
Richard_TheDev2023_pattern.pptx.pdf
Richard_TheDev2023_pattern.pptx.pdfRichard_TheDev2023_pattern.pptx.pdf
Richard_TheDev2023_pattern.pptx.pdfRichard Rodger
 
richard-rodger-awssofia-microservices-2019.pdf
richard-rodger-awssofia-microservices-2019.pdfrichard-rodger-awssofia-microservices-2019.pdf
richard-rodger-awssofia-microservices-2019.pdfRichard Rodger
 
richardrodger-microservice-algebra-cluj-apr.pdf
richardrodger-microservice-algebra-cluj-apr.pdfrichardrodger-microservice-algebra-cluj-apr.pdf
richardrodger-microservice-algebra-cluj-apr.pdfRichard Rodger
 
richardrodger-designing-microservices-london-may.pdf
richardrodger-designing-microservices-london-may.pdfrichardrodger-designing-microservices-london-may.pdf
richardrodger-designing-microservices-london-may.pdfRichard Rodger
 
richardrodger-designing-microservices-london-may.pdf
richardrodger-designing-microservices-london-may.pdfrichardrodger-designing-microservices-london-may.pdf
richardrodger-designing-microservices-london-may.pdfRichard Rodger
 
richardrodger-microservice-risk-dublin-mar.pdf
richardrodger-microservice-risk-dublin-mar.pdfrichardrodger-microservice-risk-dublin-mar.pdf
richardrodger-microservice-risk-dublin-mar.pdfRichard Rodger
 
richardrodger-service-discovery-waterford-feb.pdf
richardrodger-service-discovery-waterford-feb.pdfrichardrodger-service-discovery-waterford-feb.pdf
richardrodger-service-discovery-waterford-feb.pdfRichard Rodger
 
richardrodger-vespa-waterford-oct.pdf
richardrodger-vespa-waterford-oct.pdfrichardrodger-vespa-waterford-oct.pdf
richardrodger-vespa-waterford-oct.pdfRichard Rodger
 
Richardrodger designing-microservices-uxdx-dublin-oct
Richardrodger designing-microservices-uxdx-dublin-octRichardrodger designing-microservices-uxdx-dublin-oct
Richardrodger designing-microservices-uxdx-dublin-octRichard Rodger
 
How microservices fail, and what to do about it
How microservices fail, and what to do about itHow microservices fail, and what to do about it
How microservices fail, and what to do about itRichard Rodger
 
Rapid Digital Innovation: How Node.js Delivers
Rapid Digital Innovation: How Node.js DeliversRapid Digital Innovation: How Node.js Delivers
Rapid Digital Innovation: How Node.js DeliversRichard Rodger
 
Richardrodger nodeconfeu-2014-final
Richardrodger nodeconfeu-2014-finalRichardrodger nodeconfeu-2014-final
Richardrodger nodeconfeu-2014-finalRichard Rodger
 
Richardrodger nodeday-2014-final
Richardrodger nodeday-2014-finalRichardrodger nodeday-2014-final
Richardrodger nodeday-2014-finalRichard Rodger
 
Richardrodger nodeday-2014-final
Richardrodger nodeday-2014-finalRichardrodger nodeday-2014-final
Richardrodger nodeday-2014-finalRichard Rodger
 
Richardrodger microxchgio-feb-2015-final
Richardrodger microxchgio-feb-2015-finalRichardrodger microxchgio-feb-2015-final
Richardrodger microxchgio-feb-2015-finalRichard Rodger
 
Micro-services Battle Scars
Micro-services Battle ScarsMicro-services Battle Scars
Micro-services Battle ScarsRichard Rodger
 
Richard rodger technical debt - web summit 2013
Richard rodger   technical debt - web summit 2013Richard rodger   technical debt - web summit 2013
Richard rodger technical debt - web summit 2013Richard Rodger
 
The Seneca Pattern at EngineYard Distill 2013 Conference
The Seneca Pattern at EngineYard Distill 2013 ConferenceThe Seneca Pattern at EngineYard Distill 2013 Conference
The Seneca Pattern at EngineYard Distill 2013 ConferenceRichard Rodger
 
Building businesspost.ie using Node.js
Building businesspost.ie using Node.jsBuilding businesspost.ie using Node.js
Building businesspost.ie using Node.jsRichard Rodger
 

Plus de Richard Rodger (20)

Using RAG to create your own Podcast conversations.pdf
Using RAG to create your own Podcast conversations.pdfUsing RAG to create your own Podcast conversations.pdf
Using RAG to create your own Podcast conversations.pdf
 
Richard_TheDev2023_pattern.pptx.pdf
Richard_TheDev2023_pattern.pptx.pdfRichard_TheDev2023_pattern.pptx.pdf
Richard_TheDev2023_pattern.pptx.pdf
 
richard-rodger-awssofia-microservices-2019.pdf
richard-rodger-awssofia-microservices-2019.pdfrichard-rodger-awssofia-microservices-2019.pdf
richard-rodger-awssofia-microservices-2019.pdf
 
richardrodger-microservice-algebra-cluj-apr.pdf
richardrodger-microservice-algebra-cluj-apr.pdfrichardrodger-microservice-algebra-cluj-apr.pdf
richardrodger-microservice-algebra-cluj-apr.pdf
 
richardrodger-designing-microservices-london-may.pdf
richardrodger-designing-microservices-london-may.pdfrichardrodger-designing-microservices-london-may.pdf
richardrodger-designing-microservices-london-may.pdf
 
richardrodger-designing-microservices-london-may.pdf
richardrodger-designing-microservices-london-may.pdfrichardrodger-designing-microservices-london-may.pdf
richardrodger-designing-microservices-london-may.pdf
 
richardrodger-microservice-risk-dublin-mar.pdf
richardrodger-microservice-risk-dublin-mar.pdfrichardrodger-microservice-risk-dublin-mar.pdf
richardrodger-microservice-risk-dublin-mar.pdf
 
richardrodger-service-discovery-waterford-feb.pdf
richardrodger-service-discovery-waterford-feb.pdfrichardrodger-service-discovery-waterford-feb.pdf
richardrodger-service-discovery-waterford-feb.pdf
 
richardrodger-vespa-waterford-oct.pdf
richardrodger-vespa-waterford-oct.pdfrichardrodger-vespa-waterford-oct.pdf
richardrodger-vespa-waterford-oct.pdf
 
Richardrodger designing-microservices-uxdx-dublin-oct
Richardrodger designing-microservices-uxdx-dublin-octRichardrodger designing-microservices-uxdx-dublin-oct
Richardrodger designing-microservices-uxdx-dublin-oct
 
How microservices fail, and what to do about it
How microservices fail, and what to do about itHow microservices fail, and what to do about it
How microservices fail, and what to do about it
 
Rapid Digital Innovation: How Node.js Delivers
Rapid Digital Innovation: How Node.js DeliversRapid Digital Innovation: How Node.js Delivers
Rapid Digital Innovation: How Node.js Delivers
 
Richardrodger nodeconfeu-2014-final
Richardrodger nodeconfeu-2014-finalRichardrodger nodeconfeu-2014-final
Richardrodger nodeconfeu-2014-final
 
Richardrodger nodeday-2014-final
Richardrodger nodeday-2014-finalRichardrodger nodeday-2014-final
Richardrodger nodeday-2014-final
 
Richardrodger nodeday-2014-final
Richardrodger nodeday-2014-finalRichardrodger nodeday-2014-final
Richardrodger nodeday-2014-final
 
Richardrodger microxchgio-feb-2015-final
Richardrodger microxchgio-feb-2015-finalRichardrodger microxchgio-feb-2015-final
Richardrodger microxchgio-feb-2015-final
 
Micro-services Battle Scars
Micro-services Battle ScarsMicro-services Battle Scars
Micro-services Battle Scars
 
Richard rodger technical debt - web summit 2013
Richard rodger   technical debt - web summit 2013Richard rodger   technical debt - web summit 2013
Richard rodger technical debt - web summit 2013
 
The Seneca Pattern at EngineYard Distill 2013 Conference
The Seneca Pattern at EngineYard Distill 2013 ConferenceThe Seneca Pattern at EngineYard Distill 2013 Conference
The Seneca Pattern at EngineYard Distill 2013 Conference
 
Building businesspost.ie using Node.js
Building businesspost.ie using Node.jsBuilding businesspost.ie using Node.js
Building businesspost.ie using Node.js
 

Dernier

Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxRustici Software
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfOrbitshub
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024The Digital Insurer
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKJago de Vreede
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Victor Rentea
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfOverkill Security
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamUiPathCommunity
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...apidays
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...apidays
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 

Dernier (20)

Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 

20120816 nodejsdublin

  • 1. seneca nodejsdublin 16 August 2012 Richard Rodger @rjrodger
  • 2. hello nodejsdublin • let's start a community project • how Node.js modules work • introducing the seneca module
  • 3. getting started • how do you learn Node.js? • how do you contribute to Node.js? • how do you get a job doing Node.js?
  • 4. your community • nodejsdublin is for you • here to help you learn • here to build a great community
  • 5. let's start a project • less talking, more coding! • community project with many coders • something with lots of small pieces
  • 6. seneca • A Minimal Viable Product toolkit • let's you build a startup in a weekend :) • for more about MVPs: http://bit.ly/N25FlZ
  • 7. • Lucius Annaeus Seneca, 4 BC – AD 65 • You have to be stoic to do a startup • "increases are of sluggish growth, but the way to ruin is rapid" * http://cassandralegacy.blogspot.ie/2011/08/seneca-effect-origins-of-collapse.html
  • 8. sign up • Tweet @nodejsdublin with #seneca • Mail me: richard.rodger@nearform.com • Code: github.com/nodejsdublin/seneca
  • 9. node.js modules • basic building blocks of Node.js apps • no special syntax; plain old JavaScript • no version conflicts!
  • 10. using modules var _ = require("underscore"); var threes = _.map([1, 2, 3], function(n){ return n*3 }); console.log( threes ); // prints [3, 6, 9] var mongo = require('mongodb'); var host = 'localhost'; var port = 27017; var db = new mongo.Db( 'mydatabase', new mongo.Server(host, port, {}), {}); db.open(function(err, db) { ... }
  • 11. cool modules • express - JSP/ASP style dynamic server-side pages • socket.io - HTML5 real-time web sockets that "just work" • request - easy outbound calls to web services
  • 12. using npm • npmjs.org - module repository of record • usage: npm install modulename • modules live in local node_modules folder
  • 13. how to pick a module • serious modules are on https://github.com/joyent/node/wiki/modules • popularity! check watchers/issues on github • documentation, including third party blogs • ask the community: http://nodejs.org/community/
  • 14. why npm rocks • modules are installed separately for each project • dependencies are also installed separately • no global conflicts, no cross-dependency conflicts
  • 15. package.json • defines a module; lists dependencies • always create one for each project • npm install will set up dependencies for you!
  • 16. package.json {   "name" : "optimist",   "version" : "0.3.4",   "description" : "Light-weight option parsing.", "main" : "./index.js",     "dependencies" : {      "wordwrap" : ">=0.0.2"   },   "repository" : {     "type" : "git",     "url" : "http://github.com/substack/node-optimist.git"   },   "keywords" : [ "argument", "args", "option", "parser" ]   "author" : { "name" : "James Halliday" }, "engine" : { "node" : ">=0.4 } }
  • 17. write a module • create a project on github • npm init - creates package.json for you • start with lib/modulename.js
  • 18. modulename.js "use strict"; function ModuleName() { var self = {}; var private = "hidden"; self.member = "data"; self.method = function() { ... }; return self; } exports.ModuleName = ModuleName callingcode.js var modulename = require('modulename') var instance = new modulename.ModuleName()
  • 19. parambulator • written just for this meetup! - sanity checks JSON data structures • https://github.com/rjrodger/parambulator • you also need a README.md and LICENSE.txt • you really should have unit tests; try the vows module
  • 20. file structure parambulator / package.json README.md LICENSE.txt lib / parambulator.js
  • 21. publishing a module • the package.json files property is your friend • register for an account on npmjs.org • npm publish • sit back and bask in the glory...
  • 22. seneca • nearForm builds web/mobile services • shared set of features every startup needs • ... must resist ... let's build a framework!
  • 23. shared features • user accounts: login/logout, profile pages, social media, ... • email: transactional, promotional, ... • e-commerce: gateways, app stores, ... • admin: data editors, analytics, audit logs, ..
  • 24. seneca is in production businesspost.ie chartaca.com stanzr.com
  • 25. command pattern • actions are represented by a set of properties • seneca "executes" them by invoking plugins • everything that happens is traceable • business logic is insulated from service providers
  • 26. seneca commands // register a new user seneca.act({ on: 'user', cmd: 'register', email: 'alice@example.com', name: 'Alice', password: '1234', active: true }, function(err, result) { ... }) // send an email seneca.act({ on: 'email', cmd: 'send', to: 'alice@example.com', code: 'thanks-for-registering', fields: {name:'Alice'} }, function(err, result) { ... })
  • 27. plugins • everything is a plugin • plugins provide actions • plugins are just modules!
  • 28. seneca plugin function EchoPlugin() { var self = {}; self.name = 'echo'; self.init = function(seneca,opts,cb) { seneca.add({on:'echo'}, function(args,seneca,cb){ var out = args cb(null,out) }) cb() } self.service = function() { return function(req,res,next){ if( '/echo' == req.url ) { res.writeHead(200); res.end(req.url); } else next(); } } } exports.plugin = function() { return new EchoPlugin() }
  • 29. shared data model • Built-in ODM - Object Document Mapper • You need this to stay sane • ActiveRecord-ish API with MongoDB-ish queries
  • 30. seneca data model var product = seneca.make('product'); product.name = 'Apple'; product.price = 1.99; product.save$(function(err,savedproduct){ console.log('generated id: '+savedproduct.id); }) product.load$('1234',function(err,foundproduct){ console.log('found product '+foundproduct); }) product.list$( {price:1.99}, function(err,list){ for( var i = 0; i < list.length; i++ ) { console.log( list[i] ); } })
  • 31. what we • have now messy code that kinda sorta works • a few hackety hack plugins • no documentation!
  • 32. what we need • plugins! plugins! plugins! • documentation ( ... just kidding! I'll do that) • some nodeknockout.com entries - November 10-12th! Fame & Glory Await!
  • 33. let's code! • Tweet @nodejsdublin with #seneca • Mail me: richard.rodger@nearform.com • Code: github.com/nodejsdublin/seneca

Notes de l'éditeur

  1. \n
  2. \n
  3. \n
  4. \n
  5. ...and here&apos;s one we made earlier\n
  6. \n
  7. nero\nseneca squeezes the curve\n\n
  8. \n
  9. \n
  10. \n
  11. \n
  12. intro npm, installed with node\n
  13. \n
  14. \n
  15. \n
  16. explain optimist\n
  17. \n
  18. explain var self = {}\n
  19. blueprint\n
  20. \n
  21. \n
  22. \n
  23. \n
  24. about a year old\n
  25. \n
  26. \n
  27. \n
  28. \n
  29. \n
  30. \n
  31. \n
  32. \n
  33. \n