Your browser doesn't support this presentation. Try Chrome or Safari.


A better web framework for Node.

My name is
Daniel Erickson

I work at Yammer as a Senior Javascript Engineer
I work with Node almost every day
We built our upload service on Node
We built our real time document collaboration service on Node

So lets talk about Node

Node is good at helping you create highly scalable prototypes without a whole lot of effort
Node has a great module system
Once you get past the prototype stage, though, your code starts looking like spaghetti
Frameworks help you get rid of spaghetti

So lets talk about frameworks

When you work on a team, frameworks help your code base stay consistent
When you have a lot of dependencies, frameworks help you keep them all in order
When you want to implement a new feature, frameworks help you write it faster
Web frameworks have been around for a while now

So lets talk about what's out there now

Ruby has Rails:

Python has Django:

Then Merb came around:

but the Rails guys ate it

How about web frameworks for Node?

Connect came first(ish)*

*Geddy v1 was actually released before Connect.

Connect simplified the request and response cycle

Connect gave you middleware

Connect also gave you problems

Connect buffers some responses

Connect has no structure

Then Express came around

Express was built on top of Connect

Express gives you a real framework

Express gives you better routes

Express gives you almost no structure

Express doesn't give you models

Express buffers (some) requests*

* most are fine, but you have to wait for file uploads if you're using req.files

Express gives you all the problems Connect has

Flatiron has a different approach

Flatiron is a collection of modules that resemble a framework

Flatiron is pretty awesome but...

Flatiron has no* structure

*You get some boilerplate app code, but no solid conventions.

This lack of structure is why we built Geddy.js

Geddy.js is written by a few of us at Yammer:

But first some Yammer and Geddy history

Summer 2010: disappointed with the current options, Matt decides he wants to build his own web framework, Geddy v1

Winter 2010 - 2011: Yammer sets out to create an upload server that could handle the load of 3+ million users.

Early Spring 2011: The upload service launches with html5 document conversion, video transcoding, and image resizing.

Spring 2011: We continue to build out framework-like features onto the upload service

Fall 2011: A major refactor of Geddy is started- we merge the features that we developed for the upload service into geddy, and end up removing a lot of code in the process.

Winter 2011-2012: The upload service is ported to use the new framework that we came up with - we call it Geddy v2

Geddy v1 was a framework without an app

The upload service was an app without a framework

Geddy v2 is a framework built to make building apps easier

Geddy Features

Geddy has generators

$> geddy app your_app
$> geddy resource user

Geddy has routes

{controller: 'Main', action: 'index'});
{controller: 'Moving', action: 'pictures'});

Geddy has resources


Geddy has content negotiation


Geddy has models

Geddy has Bootstrap and jQuery

Geddy has EJS templates

<% if (localVar) { %> <%=localVar%> <% } %>

Geddy has logging'Some info for you');
geddy.log.warning('A warning!');
geddy.log.error('An error occurred');

Geddy has Metrics

$> npm install metrics

Geddy has buffered streams

Geddy has process clustering

What does a Geddy app look like?

First, lets generate a Geddy app:

$> geddy app test_app

Geddy app directory structure:


Geddy controller structure:


Geddy views structure:


Geddy models structure:


How do you start a Geddy app server?

$> cd test_app
$> geddy

Your Geddy app is now running at:


Lets generate a Geddy resource:

$> geddy resource user

What did that just do?

[ADDED] /app/models/user.js
[ADDED] /app/controllers/users.js
users resource route added to /config/router.js
Created resource view templates.

Now you've got these routes available

(GET)       /users
(GET)       /users/add
(GET)       /users/:id
(GET)       /users/:id/edit
(POST)      /users
(PUT)       /users/:id
(DELETE)    /users/:id

Lets Recap

Node is great for rapidly prototyping services and apps

Rapid prototyping without a framework results in spaghetti code

Current Node frameworks don't give you enough structure to allow for team work, feature building, and consistency

Geddy does.

So use it:

$> npm install -g jake geddy


Any Questions?