Giter VIP home page Giter VIP logo

birbal's Introduction

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);

birbal's People

Contributors

mattneary avatar poincare avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

birbal's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.