SlideShare una empresa de Scribd logo
1 de 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

Más contenido relacionado

La actualidad más candente

OSCON 2011 - Node.js Tutorial
OSCON 2011 - Node.js TutorialOSCON 2011 - Node.js Tutorial
OSCON 2011 - Node.js Tutorial
Tom Croucher
 
Building a production ready meteor app
Building a production ready meteor appBuilding a production ready meteor app
Building a production ready meteor app
Ritik Malhotra
 
Nodejs - Building a RESTful API
Nodejs - Building a RESTful APINodejs - Building a RESTful API
Nodejs - Building a RESTful API
Sang Cù
 
Java script at backend nodejs
Java script at backend   nodejsJava script at backend   nodejs
Java script at backend nodejs
Amit Thakkar
 

La actualidad más candente (20)

Securing Microservices using Play and Akka HTTP
Securing Microservices using Play and Akka HTTPSecuring Microservices using Play and Akka HTTP
Securing Microservices using Play and Akka HTTP
 
A language for the Internet: Why JavaScript and Node.js is right for Internet...
A language for the Internet: Why JavaScript and Node.js is right for Internet...A language for the Internet: Why JavaScript and Node.js is right for Internet...
A language for the Internet: Why JavaScript and Node.js is right for Internet...
 
NodeJS : Communication and Round Robin Way
NodeJS : Communication and Round Robin WayNodeJS : Communication and Round Robin Way
NodeJS : Communication and Round Robin Way
 
OSCON 2011 - Node.js Tutorial
OSCON 2011 - Node.js TutorialOSCON 2011 - Node.js Tutorial
OSCON 2011 - Node.js Tutorial
 
Construindo APIs Usando Rails
Construindo APIs Usando RailsConstruindo APIs Usando Rails
Construindo APIs Usando Rails
 
Nuxt.js - Introduction
Nuxt.js - IntroductionNuxt.js - Introduction
Nuxt.js - Introduction
 
.NET Conf 2018: Build Great Libraries using .NET Standard
.NET Conf 2018: Build Great Libraries using .NET Standard.NET Conf 2018: Build Great Libraries using .NET Standard
.NET Conf 2018: Build Great Libraries using .NET Standard
 
Building a production ready meteor app
Building a production ready meteor appBuilding a production ready meteor app
Building a production ready meteor app
 
Node js training (1)
Node js training (1)Node js training (1)
Node js training (1)
 
Nuxt Talk
Nuxt TalkNuxt Talk
Nuxt Talk
 
GWT Web Socket and data serialization
GWT Web Socket and data serializationGWT Web Socket and data serialization
GWT Web Socket and data serialization
 
Building Real-Time Applications with Android and WebSockets
Building Real-Time Applications with Android and WebSocketsBuilding Real-Time Applications with Android and WebSockets
Building Real-Time Applications with Android and WebSockets
 
Nodejs - Building a RESTful API
Nodejs - Building a RESTful APINodejs - Building a RESTful API
Nodejs - Building a RESTful API
 
Node, express & sails
Node, express & sailsNode, express & sails
Node, express & sails
 
vert.x 3.1 - be reactive on the JVM but not only in Java
vert.x 3.1 - be reactive on the JVM but not only in Javavert.x 3.1 - be reactive on the JVM but not only in Java
vert.x 3.1 - be reactive on the JVM but not only in Java
 
Sails.js Intro
Sails.js IntroSails.js Intro
Sails.js Intro
 
Symfony finally swiped right on envvars
Symfony finally swiped right on envvarsSymfony finally swiped right on envvars
Symfony finally swiped right on envvars
 
Getting Started with Ansible
Getting Started with AnsibleGetting Started with Ansible
Getting Started with Ansible
 
Java script at backend nodejs
Java script at backend   nodejsJava script at backend   nodejs
Java script at backend nodejs
 
EC2 AMI Factory with Chef, Berkshelf, and Packer
EC2 AMI Factory with Chef, Berkshelf, and PackerEC2 AMI Factory with Chef, Berkshelf, and Packer
EC2 AMI Factory with Chef, Berkshelf, and Packer
 

Destacado

Asynchronous I/O in NodeJS - new standard or challenges?
Asynchronous I/O in NodeJS - new standard or challenges?Asynchronous I/O in NodeJS - new standard or challenges?
Asynchronous I/O in NodeJS - new standard or challenges?
Dinh Pham
 

Destacado (20)

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
 
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
 
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
 
Meet song nhi your virtual financial assistance
Meet song nhi   your virtual financial assistanceMeet song nhi   your virtual financial assistance
Meet song nhi your virtual financial assistance
 
Microservices and Seneca at RomaJS group
Microservices and Seneca at RomaJS groupMicroservices and Seneca at RomaJS group
Microservices and Seneca at RomaJS group
 
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
 
Node Interactive : 7 years, 7 design patterns, will node continue to outshine
Node Interactive : 7 years, 7 design patterns, will node continue to outshineNode Interactive : 7 years, 7 design patterns, will node continue to outshine
Node Interactive : 7 years, 7 design patterns, will node continue to outshine
 
NodeJS Microservices, Built it Now, Scale it Later!
NodeJS Microservices, Built it Now, Scale it Later!NodeJS Microservices, Built it Now, Scale it Later!
NodeJS Microservices, Built it Now, Scale it Later!
 
Writing Test Cases with PHPUnit
Writing Test Cases with PHPUnitWriting Test Cases with PHPUnit
Writing Test Cases with PHPUnit
 
Nodejs in Production
Nodejs in ProductionNodejs in Production
Nodejs in Production
 
Building Web Apps & APIs With Node JS
Building Web Apps & APIs With Node JSBuilding Web Apps & APIs With Node JS
Building Web Apps & APIs With Node JS
 
NodeJS security - still unsafe at most speeds - v1.0
NodeJS security - still unsafe at most speeds - v1.0NodeJS security - still unsafe at most speeds - v1.0
NodeJS security - still unsafe at most speeds - v1.0
 
Asynchronous I/O in NodeJS - new standard or challenges?
Asynchronous I/O in NodeJS - new standard or challenges?Asynchronous I/O in NodeJS - new standard or challenges?
Asynchronous I/O in NodeJS - new standard or challenges?
 
Patterns and practices for real-world event-driven microservices
Patterns and practices for real-world event-driven microservicesPatterns and practices for real-world event-driven microservices
Patterns and practices for real-world event-driven microservices
 
Testing NodeJS Security
Testing NodeJS SecurityTesting NodeJS Security
Testing NodeJS Security
 
Why Reactive Architecture Will Take Over The World (and why we should be wary...
Why Reactive Architecture Will Take Over The World (and why we should be wary...Why Reactive Architecture Will Take Over The World (and why we should be wary...
Why Reactive Architecture Will Take Over The World (and why we should be wary...
 
Microservices Past, Present, Future
Microservices Past, Present, FutureMicroservices Past, Present, Future
Microservices Past, Present, Future
 
Bizweb Microservices Architecture
Bizweb Microservices ArchitectureBizweb Microservices Architecture
Bizweb Microservices Architecture
 
ITLC HN 14 - Bizweb Microservices Architecture
ITLC HN 14  - Bizweb Microservices ArchitectureITLC HN 14  - Bizweb Microservices Architecture
ITLC HN 14 - Bizweb Microservices Architecture
 
Distributed Transaction in Microservice
Distributed Transaction in MicroserviceDistributed Transaction in Microservice
Distributed Transaction in Microservice
 

Similar a Introducing the Seneca MVP framework for Node.js

Intro to node and mongodb 1
Intro to node and mongodb   1Intro to node and mongodb   1
Intro to node and mongodb 1
Mohammad Qureshi
 
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
 
Writing robust Node.js applications
Writing robust Node.js applicationsWriting robust Node.js applications
Writing robust Node.js applications
Tom Croucher
 
Module, AMD, RequireJS
Module, AMD, RequireJSModule, AMD, RequireJS
Module, AMD, RequireJS
偉格 高
 

Similar a Introducing the Seneca MVP framework for Node.js (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?
 

Más 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.pdf
Richard Rodger
 
Richard_TheDev2023_pattern.pptx.pdf
Richard_TheDev2023_pattern.pptx.pdfRichard_TheDev2023_pattern.pptx.pdf
Richard_TheDev2023_pattern.pptx.pdf
Richard Rodger
 
richard-rodger-awssofia-microservices-2019.pdf
richard-rodger-awssofia-microservices-2019.pdfrichard-rodger-awssofia-microservices-2019.pdf
richard-rodger-awssofia-microservices-2019.pdf
Richard Rodger
 
richardrodger-microservice-algebra-cluj-apr.pdf
richardrodger-microservice-algebra-cluj-apr.pdfrichardrodger-microservice-algebra-cluj-apr.pdf
richardrodger-microservice-algebra-cluj-apr.pdf
Richard Rodger
 
richardrodger-designing-microservices-london-may.pdf
richardrodger-designing-microservices-london-may.pdfrichardrodger-designing-microservices-london-may.pdf
richardrodger-designing-microservices-london-may.pdf
Richard Rodger
 
richardrodger-designing-microservices-london-may.pdf
richardrodger-designing-microservices-london-may.pdfrichardrodger-designing-microservices-london-may.pdf
richardrodger-designing-microservices-london-may.pdf
Richard Rodger
 
richardrodger-microservice-risk-dublin-mar.pdf
richardrodger-microservice-risk-dublin-mar.pdfrichardrodger-microservice-risk-dublin-mar.pdf
richardrodger-microservice-risk-dublin-mar.pdf
Richard Rodger
 
richardrodger-service-discovery-waterford-feb.pdf
richardrodger-service-discovery-waterford-feb.pdfrichardrodger-service-discovery-waterford-feb.pdf
richardrodger-service-discovery-waterford-feb.pdf
Richard Rodger
 
Building businesspost.ie using Node.js
Building businesspost.ie using Node.jsBuilding businesspost.ie using Node.js
Building businesspost.ie using Node.js
Richard Rodger
 
How to Write Big Apps (Richard Rodger NodeDublin 2012)
How to Write Big Apps (Richard Rodger NodeDublin 2012)How to Write Big Apps (Richard Rodger NodeDublin 2012)
How to Write Big Apps (Richard Rodger NodeDublin 2012)
Richard Rodger
 
Richard rodger-appgen-2012-lxjs-lisbon
Richard rodger-appgen-2012-lxjs-lisbonRichard rodger-appgen-2012-lxjs-lisbon
Richard rodger-appgen-2012-lxjs-lisbon
Richard Rodger
 

Más 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
 
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
 
Building businesspost.ie using Node.js
Building businesspost.ie using Node.jsBuilding businesspost.ie using Node.js
Building businesspost.ie using Node.js
 
How to Write Big Apps (Richard Rodger NodeDublin 2012)
How to Write Big Apps (Richard Rodger NodeDublin 2012)How to Write Big Apps (Richard Rodger NodeDublin 2012)
How to Write Big Apps (Richard Rodger NodeDublin 2012)
 
Richard rodger-appgen-2012-lxjs-lisbon
Richard rodger-appgen-2012-lxjs-lisbonRichard rodger-appgen-2012-lxjs-lisbon
Richard rodger-appgen-2012-lxjs-lisbon
 
20120802 timisoara
20120802 timisoara20120802 timisoara
20120802 timisoara
 
20120816 nodejsdublin
20120816 nodejsdublin20120816 nodejsdublin
20120816 nodejsdublin
 

Último

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Earley Information Science
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 

Último (20)

Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
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
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
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...
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
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
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
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
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 

Introducing the Seneca MVP framework for Node.js

  • 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

Notas del editor

  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