• Save
How we're building Wercker
Upcoming SlideShare
Loading in...5
×
 

Like this? Share it with your network

Share

How we're building Wercker

on

  • 2,661 views

Presentation for the first Amsterdam node.js meetup.

Presentation for the first Amsterdam node.js meetup.

Statistics

Views

Total Views
2,661
Views on SlideShare
2,649
Embed Views
12

Actions

Likes
2
Downloads
0
Comments
0

4 Embeds 12

http://us-w1.rockmelt.com 5
http://bottlenose.local 4
http://www.twylah.com 2
http://paper.li 1

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

How we're building Wercker Presentation Transcript

  • 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.comSunday, April 1, 12
  • 3. Continuous Deployment made easy wercker acceleratorSunday, 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
  • 5. WHAT WE’RE USINGSunday, April 1, 12
  • 6. TECHNOLOGY STACK BACKBONE.JS wercker WEBSOCKETS .net node.jsSunday, April 1, 12
  • 7. EXPRESS ‣ Powers the Wercker API ‣ Similar to Sinatra in Ruby or Flask in Python ‣ Just Use It ‣ expressjs.comSunday, 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/asyncSunday, 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/requestSunday, 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
  • 19. QUESTIONS?Sunday, April 1, 12