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

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
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 

Recently uploaded (20)

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
 
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
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
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
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
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
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
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
 
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
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
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
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
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...
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 

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