SlideShare a Scribd company logo
1 of 19
Sunday, April 1, 12
                      020
                      node.js meetup
HOW WE’RE BUILDING WERCKER
     node.js essential modules and tools




      Micha Hernández van Leuffen        Wouter Mooij

                      @mies                     @wwwouter

                      mies@wercker.com          wouter@wercker.com

Sunday, April 1, 12
Continuous Deployment
                      made easy
         wercker

                         accelerator
Sunday, April 1, 12
wercker

            Wercker is a hosted continuous deployment platform,
            helping developer-teams working on web-applications,
            push smaller pieces of code, such that bugs are quickly
            detected and resolved.

            It is easy to use and with you from the start.



Sunday, April 1, 12
WHAT WE’RE USING


Sunday, April 1, 12
TECHNOLOGY STACK

                                   BACKBONE.JS



    wercker           WEBSOCKETS




                                               .net
                                     node.js
Sunday, April 1, 12
EXPRESS

                      ‣ Powers the Wercker API
                      ‣ Similar to Sinatra in Ruby or Flask in
                        Python

                      ‣ Just Use It
                      ‣ expressjs.com

Sunday, April 1, 12
EXPRESS
       // load dependencies
       var express = require(‘express’);
       var app = express.createServer();

       // define routes, send JSON
       app.get(‘/posts’, function(req, res) {
         res.send({title: ‘this is a post’});
       });

       // use templating
       app.get(‘/posts/:id’, function(req, res) {
         res.render(‘post’, {title: ‘this is a post’});
       });




Sunday, April 1, 12
EXPRESS                         Pro T
                                                   ip!
     // separate controller from routes in app.js
     var api = require(‘./controllers/api.js’);
     app.get(‘/posts’, api.getPosts);


    // have functionality reside in controllers/api.js
    exports getPosts = function(req, res) {
      res.send({title: ‘this is a post’});
    });




Sunday, April 1, 12
ASYNC                    Esca
                                          Callb     ping
                                                ack
                                                    Hell™
      // separate controller from routes in app.js
        fs.stat('/awesome/file', function (err, stats) {
          parseData(stats, function(err, data) {
            db.insert(data, function(err, result) {
              // do something with error or result
            });
        });




Sunday, April 1, 12
ASYNC
                      ‣ Control flow library (waterfall, series,
                        parallel)

                      ‣ Functional Programming methods
                        (filter, map, reduce, forEach)

                      ‣ Alternatives include (Step, Flow-js,
                        node-promise)

                      ‣ https://github.com/caolan/async
Sunday, April 1, 12
ASYNC
     async.waterfall([
         function(callback){
             fs.stat('/awesome/file', callback)
          },
         function(stats, callback){
               parseData(stats, callback);
          },
         function(data, callback){
             db.insert(json, callback);
          }
       ],
        // optional final callback to run once all functions have completed
       function (err, result) {
         // if there is an error it ends up here
         // otherwise this is the result of the db insert
         console.log(result);
     });
Sunday, April 1, 12
REQUEST

                      ‣ Sane HTTP requests
                      ‣ Streaming Support
                      ‣ Oauth signing
                      ‣ Convenience methods
                      ‣ https://github.com/mikeal/request
Sunday, April 1, 12
REQUEST

  // simple HTTP ‘GET’ request
  var request = require(‘request’);

  request.get('http://api.twitter.com/1/statuses/public_timeline.json',
  function(error, response, body) {
    console.log(body);
    });




Sunday, April 1, 12
MONGOOSE


                      ‣ MongoDB = Document Oriented
                        Database

                      ‣ Mongoose = MongoDB ODM
                      ‣ Easy to define and query models
                      ‣ http://mongoosejs.com/

Sunday, April 1, 12
MONGOOSE

     // define a model
     var mongoose = require('mongoose'),
         Schema = mongoose.Schema,
         ObjectId = Schema.ObjectId;

     var projectSchema = new Schema({
         name: String,
         git_url: String,
         user_id: {type: ObjectId, required: true, index: true},
         private: {type: Boolean, default: true},
         createdOn: {type: Date, default: Date.now},
     });



     module.exports = mongoose.model('Project', projectSchema);

Sunday, April 1, 12
MONGOOSE

      // use a model
      var Project = require(‘project.js’);

      // Find objects
      Project.find({ user_id: id}, [‘name’,‘createdOn’], {sort: {'createdOn': -1}},
        function(err, projects) {
           // do something with array of projects
           });

      // Retrieve a single object
      Project.findOne({ name: ‘mies’}, function(err, project) {
           // do something with the project
           });


      // Create new Project
           p = new Project({name: ‘mies’...}).save();


Sunday, April 1, 12
OTHERS

                      ‣   nodeenv - sandbox node environments
                          (https://github.com/ekalinin/nodeenv)

                      ‣   socket.io - cross-browser websockets
                          (http://socket.io)

                      ‣   aws2js - Amazon Web Services module
                          (https://github.com/SaltwaterC/aws2js)

                      ‣   underscore.js - Functional Programming utilities
                          (http://documentcloud.github.com/underscore/)

                      ‣   Custom NPM install urls:
                                 "dependencies": {
                                   "everyauth": "git://github.com/mies/everyauth.git"
                                 }

Sunday, April 1, 12
QUESTIONS?

Sunday, April 1, 12

More Related Content

What's hot

What's hot (20)

Loaders (and why we should use them)
Loaders (and why we should use them)Loaders (and why we should use them)
Loaders (and why we should use them)
 
[Srijan Wednesday Webinar] Rails 5: What's in It for Me?
[Srijan Wednesday Webinar] Rails 5: What's in It for Me?[Srijan Wednesday Webinar] Rails 5: What's in It for Me?
[Srijan Wednesday Webinar] Rails 5: What's in It for Me?
 
Workshop React.js
Workshop React.jsWorkshop React.js
Workshop React.js
 
Introduction to node.js
Introduction to node.jsIntroduction to node.js
Introduction to node.js
 
Deploying E.L.K stack w Puppet
Deploying E.L.K stack w PuppetDeploying E.L.K stack w Puppet
Deploying E.L.K stack w Puppet
 
Bucks County Tech Meetup: node.js introduction
Bucks County Tech Meetup: node.js introductionBucks County Tech Meetup: node.js introduction
Bucks County Tech Meetup: node.js introduction
 
What is nodejs
What is nodejsWhat is nodejs
What is nodejs
 
Puppet fundamentals
Puppet fundamentalsPuppet fundamentals
Puppet fundamentals
 
Avoiding callback hell with promises
Avoiding callback hell with promisesAvoiding callback hell with promises
Avoiding callback hell with promises
 
Service worker API
Service worker APIService worker API
Service worker API
 
AnsibleFest 2014 - Role Tips and Tricks
AnsibleFest 2014 - Role Tips and TricksAnsibleFest 2014 - Role Tips and Tricks
AnsibleFest 2014 - Role Tips and Tricks
 
Deploy MediaWiki usgin Fiware Lab Facilities
Deploy MediaWiki usgin Fiware Lab FacilitiesDeploy MediaWiki usgin Fiware Lab Facilities
Deploy MediaWiki usgin Fiware Lab Facilities
 
React on es6+
React on es6+React on es6+
React on es6+
 
The JavaFX Ecosystem
The JavaFX EcosystemThe JavaFX Ecosystem
The JavaFX Ecosystem
 
V2 and beyond
V2 and beyondV2 and beyond
V2 and beyond
 
New improvements for web developers - frontend.fi, Helsinki
New improvements for web developers - frontend.fi, HelsinkiNew improvements for web developers - frontend.fi, Helsinki
New improvements for web developers - frontend.fi, Helsinki
 
Messaging with the Docker
Messaging with the DockerMessaging with the Docker
Messaging with the Docker
 
Monitor your CentOS stack with Prometheus
Monitor your CentOS stack with PrometheusMonitor your CentOS stack with Prometheus
Monitor your CentOS stack with Prometheus
 
Spine.js
Spine.jsSpine.js
Spine.js
 
Node.js 0.8 features
Node.js 0.8 featuresNode.js 0.8 features
Node.js 0.8 features
 

Similar to How we're building Wercker

Intro to JavaScript Testing
Intro to JavaScript TestingIntro to JavaScript Testing
Intro to JavaScript Testing
Ran Mizrahi
 
How and why i roll my own node.js framework
How and why i roll my own node.js frameworkHow and why i roll my own node.js framework
How and why i roll my own node.js framework
Ben Lin
 
JavaScript Growing Up
JavaScript Growing UpJavaScript Growing Up
JavaScript Growing Up
David Padbury
 
Build web application by express
Build web application by expressBuild web application by express
Build web application by express
Shawn Meng
 
Silex: From nothing to an API
Silex: From nothing to an APISilex: From nothing to an API
Silex: From nothing to an API
chrisdkemper
 
JRuby + Rails = Awesome Java Web Framework at Jfokus 2011
JRuby + Rails = Awesome Java Web Framework at Jfokus 2011JRuby + Rails = Awesome Java Web Framework at Jfokus 2011
JRuby + Rails = Awesome Java Web Framework at Jfokus 2011
Nick Sieger
 
mDevCamp - The Best from Google IO
mDevCamp - The Best from Google IOmDevCamp - The Best from Google IO
mDevCamp - The Best from Google IO
ondraz
 

Similar to How we're building Wercker (20)

Introduction to node.js by Ran Mizrahi @ Reversim Summit
Introduction to node.js by Ran Mizrahi @ Reversim SummitIntroduction to node.js by Ran Mizrahi @ Reversim Summit
Introduction to node.js by Ran Mizrahi @ Reversim Summit
 
Intro to JavaScript Testing
Intro to JavaScript TestingIntro to JavaScript Testing
Intro to JavaScript Testing
 
How and why i roll my own node.js framework
How and why i roll my own node.js frameworkHow and why i roll my own node.js framework
How and why i roll my own node.js framework
 
Puppet and AWS: Getting the best of both worlds
Puppet and AWS: Getting the best of both worldsPuppet and AWS: Getting the best of both worlds
Puppet and AWS: Getting the best of both worlds
 
NodeJs
NodeJsNodeJs
NodeJs
 
Building Web Apps with Express
Building Web Apps with ExpressBuilding Web Apps with Express
Building Web Apps with Express
 
JavaScript Growing Up
JavaScript Growing UpJavaScript Growing Up
JavaScript Growing Up
 
Build web application by express
Build web application by expressBuild web application by express
Build web application by express
 
Silex: From nothing to an API
Silex: From nothing to an APISilex: From nothing to an API
Silex: From nothing to an API
 
Express Presentation
Express PresentationExpress Presentation
Express Presentation
 
Build Web Apps using Node.js
Build Web Apps using Node.jsBuild Web Apps using Node.js
Build Web Apps using Node.js
 
Developing web-apps like it's 2013
Developing web-apps like it's 2013Developing web-apps like it's 2013
Developing web-apps like it's 2013
 
Node.js - A practical introduction (v2)
Node.js  - A practical introduction (v2)Node.js  - A practical introduction (v2)
Node.js - A practical introduction (v2)
 
An introduction to Ember.js
An introduction to Ember.jsAn introduction to Ember.js
An introduction to Ember.js
 
Serverless Java on Kubernetes
Serverless Java on KubernetesServerless Java on Kubernetes
Serverless Java on Kubernetes
 
Play framework
Play frameworkPlay framework
Play framework
 
JRuby + Rails = Awesome Java Web Framework at Jfokus 2011
JRuby + Rails = Awesome Java Web Framework at Jfokus 2011JRuby + Rails = Awesome Java Web Framework at Jfokus 2011
JRuby + Rails = Awesome Java Web Framework at Jfokus 2011
 
mDevCamp - The Best from Google IO
mDevCamp - The Best from Google IOmDevCamp - The Best from Google IO
mDevCamp - The Best from Google IO
 
Event-driven IO server-side JavaScript environment based on V8 Engine
Event-driven IO server-side JavaScript environment based on V8 EngineEvent-driven IO server-side JavaScript environment based on V8 Engine
Event-driven IO server-side JavaScript environment based on V8 Engine
 
RESTful API In Node Js using Express
RESTful API In Node Js using Express RESTful API In Node Js using Express
RESTful API In Node Js using Express
 

Recently uploaded

+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...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
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
Victor Rentea
 
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
Safe Software
 

Recently uploaded (20)

Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
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...
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
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
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
+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...
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
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, ...
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
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
 
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
 
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
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
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
 
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
 

How we're building Wercker

  • 1. Sunday, April 1, 12 020 node.js meetup
  • 2. HOW WE’RE BUILDING WERCKER node.js essential modules and tools Micha Hernández van Leuffen Wouter Mooij @mies @wwwouter mies@wercker.com wouter@wercker.com Sunday, April 1, 12
  • 3. Continuous Deployment made easy wercker accelerator Sunday, April 1, 12
  • 4. wercker Wercker is a hosted continuous deployment platform, helping developer-teams working on web-applications, push smaller pieces of code, such that bugs are quickly detected and resolved. It is easy to use and with you from the start. Sunday, April 1, 12
  • 6. TECHNOLOGY STACK BACKBONE.JS wercker WEBSOCKETS .net node.js Sunday, April 1, 12
  • 7. EXPRESS ‣ Powers the Wercker API ‣ Similar to Sinatra in Ruby or Flask in Python ‣ Just Use It ‣ expressjs.com Sunday, April 1, 12
  • 8. EXPRESS // load dependencies var express = require(‘express’); var app = express.createServer(); // define routes, send JSON app.get(‘/posts’, function(req, res) { res.send({title: ‘this is a post’}); }); // use templating app.get(‘/posts/:id’, function(req, res) { res.render(‘post’, {title: ‘this is a post’}); }); Sunday, April 1, 12
  • 9. EXPRESS Pro T ip! // separate controller from routes in app.js var api = require(‘./controllers/api.js’); app.get(‘/posts’, api.getPosts); // have functionality reside in controllers/api.js exports getPosts = function(req, res) { res.send({title: ‘this is a post’}); }); Sunday, April 1, 12
  • 10. ASYNC Esca Callb ping ack Hell™ // separate controller from routes in app.js fs.stat('/awesome/file', function (err, stats) { parseData(stats, function(err, data) { db.insert(data, function(err, result) { // do something with error or result }); }); Sunday, April 1, 12
  • 11. ASYNC ‣ Control flow library (waterfall, series, parallel) ‣ Functional Programming methods (filter, map, reduce, forEach) ‣ Alternatives include (Step, Flow-js, node-promise) ‣ https://github.com/caolan/async Sunday, April 1, 12
  • 12. ASYNC async.waterfall([ function(callback){ fs.stat('/awesome/file', callback) }, function(stats, callback){ parseData(stats, callback); }, function(data, callback){ db.insert(json, callback); } ], // optional final callback to run once all functions have completed function (err, result) { // if there is an error it ends up here // otherwise this is the result of the db insert console.log(result); }); Sunday, April 1, 12
  • 13. REQUEST ‣ Sane HTTP requests ‣ Streaming Support ‣ Oauth signing ‣ Convenience methods ‣ https://github.com/mikeal/request Sunday, April 1, 12
  • 14. REQUEST // simple HTTP ‘GET’ request var request = require(‘request’); request.get('http://api.twitter.com/1/statuses/public_timeline.json', function(error, response, body) { console.log(body); }); Sunday, April 1, 12
  • 15. MONGOOSE ‣ MongoDB = Document Oriented Database ‣ Mongoose = MongoDB ODM ‣ Easy to define and query models ‣ http://mongoosejs.com/ Sunday, April 1, 12
  • 16. MONGOOSE // define a model var mongoose = require('mongoose'), Schema = mongoose.Schema, ObjectId = Schema.ObjectId; var projectSchema = new Schema({ name: String, git_url: String, user_id: {type: ObjectId, required: true, index: true}, private: {type: Boolean, default: true}, createdOn: {type: Date, default: Date.now}, }); module.exports = mongoose.model('Project', projectSchema); Sunday, April 1, 12
  • 17. MONGOOSE // use a model var Project = require(‘project.js’); // Find objects Project.find({ user_id: id}, [‘name’,‘createdOn’], {sort: {'createdOn': -1}}, function(err, projects) { // do something with array of projects }); // Retrieve a single object Project.findOne({ name: ‘mies’}, function(err, project) { // do something with the project }); // Create new Project p = new Project({name: ‘mies’...}).save(); Sunday, April 1, 12
  • 18. OTHERS ‣ nodeenv - sandbox node environments (https://github.com/ekalinin/nodeenv) ‣ socket.io - cross-browser websockets (http://socket.io) ‣ aws2js - Amazon Web Services module (https://github.com/SaltwaterC/aws2js) ‣ underscore.js - Functional Programming utilities (http://documentcloud.github.com/underscore/) ‣ Custom NPM install urls: "dependencies": { "everyauth": "git://github.com/mies/everyauth.git" } Sunday, April 1, 12