Skip to content

Poincare/Birbal

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Birbal

##A clever little framework for Node.js

  • Provides regex- and string-based routing of requested URLs.
  • Parses HTTP query-string parameters and body parameters, exposed in handler callbacks as this.vars.
  • Allows for middleware, such as database queries or cookie parsing.
  • Has a simple chainable syntax.

Setup

You will want to include the Birbal module. Most likely, you will set the imported value to a convenient name, like app which is used throughout our examples.

var app = require("Birbal");

Routing

Routing is performed by use of Birbal#get, Birbal#post, etc. Usage is of the following form.

app.get(*path*, *handler*[, *middleware*]).post(...)

handler is a function of request, response, and any passed values of the middleware. middleware is a function of handler, request, and response. The following is an example of this all working together.

app.get('/', function(req, res, time) {
	res.end("hi, it's "+time+".");
}, function(handler, req, res) {
	handler((new Date()).getTime());
});

Request Variables

Request variables are exposed to handlers and middleware as this.vars. The following is an example of this at use.

app.get(/^/, function(req, res) {
	res.end("hi, "+this.vars.name);
});

Running a Server

http.createServer(app).listen(8080);

About

A small routing/web framework for Node

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published