High Quality MySQL driver for Node right

Now that Felix Geisendörfer launched his node powered site http://transloadit.com, he’s tacked the much needed task of writing a high quality MySQL protocol implementation in pure JavaScript.

Using the high performance networking capabilities of node, and the awesome speed of V8, it’s now feasible to implement binary network protocols without resorting to writing C++ extensions and wrapping blocking APIs in thread pools.

Felix is a great programmer, but could use some help in the form of sponsorship and/or patches. We all win when high quality drivers are written and shared with the community.

Design Goals

  • TDD: All code is written using test driven development, code coverage should approach 100%
  • Simplicity: The MySQL protocol is easy, a good parser should reflect that
  • Efficiency: Use fast algorithms, buffers and as little memory as possible.
  • Portability: Should run anywhere node runs
  • Completeness: The goal is to support the full MySQL API.
  • Compatibility: MySql >= 4.1

Check out the code and more info on his git repo.

View Project Readme

nStore – easy database written for node.js in node.js right

Ever wanted to fire up a quick node.js app, but didn’t want to mess with finding a database driver that worked with the latest node and then installed and set up that database. Ever wanted the simplicity of an in-process db engine (like sqlite).

Wait no more, nStore is here. It’s written in pure js and is contained in a single js file to include in your node project. It supports full CRUD operations on key based documents.

The data is persisted to disk using a smart append-only format that’s easily recoverable by design. You can update/insert documents by key, read documents by key, remove documents by key… (get the picture, it’s key/value based).

Also you can build a node stream interface from a document collection or query the collection using a filter function and get the results as a single callback.

Removing stale data is easy and efficient too. Just supply a filter function to the automatic data compacter and it will remove the offending documents while compacting the data file. Thus the file is never needlessly bloated with delete lines.

Here is a short example that creates a database, inserts a document, and pulls it back out.

// Load the library
var nStore = require('nstore');
// Create a store
var users = nStore('data/users.db');

// Insert a new document with key "creationix"
users.save("creationix", {name: "Tim Caswell": age: 28}, function (err) {
    if (err) { throw err; }
    // The save is finished and written to disk safely
});

// Then later pull it back out
users.get("creationix", function (err, doc, meta) {
  // do something with the data
})

Try is out as a standalone database, or use it with Connect as a session store. http://github.com/creationix/nstore-session

[Source on GitHub]

View Project Readme

Connect – Middleware for NodeJS right

For the past few weeks Tim Caswell and TJ Holowaychuk have been busy developing a new middleware engine for Node.JS. This was unveiled recently at SWDC in Stockholm, Sweden and TXJS in Austin, Texas, and released by their employer, Ext JS, as a gift to the open source community.

Connect is a middleware system for node that makes it easy to mix and match utility modules into powerful production level applications. Have you ever wanted to add static file serving to your node app? No problem, it’s a one liner in Connect! Do you want gzip encoding, ram-caching, and 304 responses for super fast servers? Again, it’s just a line each to add these to Connect’s ruby-rack-like configuration call.

A stackup config for a Connect based blog might look something like this:

var controlled = ["/console/", "/files/", "/messages/"];

module.exports = require('./lib/connect').createServer([
    // We want to log all http traffic
    {filter: "log"},
    // Add cookie based sessions to the controlled routes
    {filter: "session", routes: controlled},
    // Make sure the user is authenticated
    {filter: "authentication", routes: controlled, param: {}},
    // Restrict access to controlled pages by user rules
    {filter: "authorization", routes: controlled, param: {}},
    // Listen for publish subscribe messages in real-time
    {provider: "pubsub", route: "/messages/", param: {}},
    // This is a logic endpoint, it's ext-direct rpc protocol
    {provider: "direct", route: "/console/", param: {}},
    // Use conditional GET to save on bandwidth
    {filter: "conditional-get"},
    // Cache all rest and static responses
    {filter: "cache"},
    // Gzip all resources when it makes sense
    {filter: "gzip"},
    // This is another logic endpoint, it's a rest-style interface to files
    {provider: "rest", route: "/files/", param: {}},
    // Finally serve everything else as static files
    {provider: "static", root: __dirname + "/public"},
    // Show pretty pages for exceptions
    {filter: "error-handler"}
]);

For more information see the recent article on howtonode.org about Connect.

[Source on GitHub] [Blog post]

View Project Readme

Nodules – module loader for Node with automated dependency resolution and module reloading right

While the world of nodejs has been busily been working on competing package managers to be the rubygems of the node world, Kris Zyp has quietly come up a novel approach. He overloads the require statement to do automatic downloading, caching and dependency resolution of modules based on urls, not a central repository. This decentralized approach means that anyone can use the package management features without registering the modules with a repository somewhere. Also it packs useful features like hot reloading of local modules and grouping of module aliases into packages.

[Source on GitHub]

View Project Readme

hxNode – Node.js wrapper for haxe right

What do you get when you combine the two very cool projects node.js and the haxe language? You get awesome! Blackdog is at it again extending the haxe project to be able to target more languages with Haxe. The language already compiles to browser javascript, flash bytecode, neko bytecode, PHP, and C++. Now he’s made a modified version of the JavaScript target that wraps the node.js apis.

If you love having a strongly typed system with AS3 like syntax and ocaml-like semantics, then Haxe is for you. Now you can write servers using the amazing event-based performance of node in it.

The wrapper is still under development, but it already wraps parts of the core node api directly and has a partial abstraction API to match the other existing haxe apis. Maybe node will be the key to helping haxe become widely used beyond flash.

View Project Readme

Wheat blog engine for node.js right

Ever wanted a blog that was made for coders? This one is built from the ground up with the needs of a modern programmer-who-happens-to-be-a-blogger-too in mind. Wheat is the new engine to howtonode.org released today.

If you’ve been itching to learn node, now is a great time. The API is stabilizing and now with a tool like wheat you can blog about your experiences.

Installing

If you don’t already have node.js, either compile by hand or use nvm (Node Version Manager)

git clone git://github.com/creationix/nvm.git ~/.nvm

Then add these three lines to your bash profile:

NVM_DIR=$HOME/.nvm
. $NVM_DIR/nvm.sh
nvm use v0.1.91

Every new shell will get the nvm environment and set a default node version. Now to install wheat:

git clone git://github.com/creationix/wheat.git
cd wheat
./install.sh

Usage

Create a git repository on your server. You can clone the howtonode.org repo for a starting place. This just needs a folder of articles, one for authors, and one for the skin of the site.

Here is an example structure:

 |-- README.markdown
 |-- articles/
 |   |-- hello-node/
 |   |   |-- hello-console.js
 |   |   |-- hello-http.js
 |   |   |-- hello-router.js
 |   |   |-- hello-tcp.js
 |   |   |-- hello-graph.dot
 |   |   `-- install.sh
 |   |-- hello-node.markdown
 |   |-- prototypal-inheritance/
 |   |   |-- classical.js
 |   |   |-- prototypal.js
 |   |   `-- spawn.js
 |   |-- prototypical-inheritance.markdown
 |   |-- welcome.markdown
 |-- authors/
 |   `-- Tim Caswell.markdown
 |-- description.markdown
 `-- skin/
     |-- article.haml
     |-- feed.xml.haml
     |-- index.haml
     |-- layout.haml
     |-- public/
     |   |-- favicon.ico
     |   |-- prettify.css
     |   |-- volcano.css
     |   |-- volcano.jpg
     |   `-- volcano.less
     |-- snippet.haml
     `-- temp.haml

Then you just cd into the repo and launch wheat:

> cd Code/howtonode.org
> wheat
Starting wheat server using git repo at /Users/tim/Code/howtonode.org
node-router server instance at http://127.0.0.1:8080/

Articles

Articles are written in markdown so there is no messing with clunky WYSIWYG editors. Also as you can see from the tree, code samples are stored in their own files. This means you can use your favorite code editor to write up your code snippets, and you can test them for syntax errors or even check the output.

If the snippet is written in node.js, you can tell the engine to execute it and show the output inline in the article like in the What is this article. Here is some sample markdown:

This is an example of global scope:

<what-is-this/global.js*>

This is an example of local scope:

<what-is-this/local.js*>

<what-is-this/this.js#person*>

Note that I was able to access `Person.name` and `Person.age` from
within `Person.greeting`.  

The * on the end means to execute the script. The hashtag means to show just that part of the file. This way you can explain a large file bit by bit, but keep it all in one functional place.

There is so much more the engine does, but this is just a sampling. There is live graphviz rendering, super scalable caching for production use on a bare git repo, RSS feed, etc…

View Project Readme

Step, control-flow the node.js way. right

A simple control-flow library for node.JS that makes parallel execution, serial execution, and error handling painless.

After making the highly popular “Do” library for making node.JS easier to wrangle, Tim Caswell (aka creationix), gave in and learned to do async code the proper node way.

“Do” was an effort to convert basic node callback style functions into “Continuable” style functions. This is great, but now with the Step library you can use callback based functions directly without the added conversion step to another paradigm.

How To Use

The step library exports a single function called Step. It accepts any number of functions as arguments and runs them in serial order using the passed in this context as the callback to the next step.

var Step = require('step');

Step(
  function readSelf() {
    fs.readFile(__filename, this);
  },
  function capitalize(err, text) {
    if (err) {
      throw err;
    }
    return text.toUpperCase();
  },
  function showIt(err, newText) {
    sys.puts(newText);
  }
);

If you’ve seen Will Conant’s flow-js library then the pattern should look familiar. It’s based on the same idea, but optimized for the node.js environment. The first argument to all steps is always the error of the previous state if there was one (including any exceptions thrown). Also, you can either return the new value of call on of the “this” or “this.parallel()” callbacks when the next step is ready.

source on github

View Project Readme

WPilot A remake of XPilot, this time in a web browser near you right

The game uses new fancy HTML5 features such as WebSocket and Canvas to make it possible.

Please visit project homepage for more details. http://jfd.github.com/wpilot/

Server requirements

You need Node.js in order to run the server. Download (or clone) Node.js at http://nodejs.org/

Quick start

You can start the game- and client server by typing:

./wpilots.js

For more more switches, start the server with the ‘-H’

View Project Readme

hook.io – the node.js web hook platform right

UPDATE: Hook.io has changed dramatically since last year and the new project is hosted here: http://github.com/hookio/

A soon to be released service/program by Marak Squires and Tim Smart.

From the README we get some explanation about what it does:

What is a web hook?

A web hook is a listener which triggers an action.

What is a web hook listener?

The listener is the event that gets triggered causing your web hook to be executed.

What is a web hook action?

The action of a web hook will be the events that are triggered when your web hook is executed. The actually events that occur are arbitrary (they can be anything)

What are hook.io’s web hook and action definitions?

Web hooks consist of an arbitrary listener and an arbitrary action. hook.io implements a hook dispatcher and an action dispatcher. these accepts custom hook and action definitions, validate configurations, and delegate events to where they belong.

Custom hook and action definitions might contain some of your business logic, but really they are meant only for routing purposes. If you need to define re-usable logic that can be spread across many definitions you will want to implement a hook.io protocol.

A hook.io “protocol” in it’s simplest form is a CommonJS module. you can create a hook.io protocol that does anything. check out our current protocols and node.js

What would you build a hook.io protocol for?

Really anything. If you wanted to integrate with Flickr, you would create the Flickr.js hook.io protocol. Now every single API method for Flickr can be called from a hook definition or an action definition.

[Source on GitHub] [Marak Squires] [Tim Smart]

View Project Readme