# Birbal

> Quick, simple routing

Latest version **0.0.3** (published 2011-12-17) · 0 weekly downloads

## Install

```sh
npm install Birbal
pnpm add Birbal
yarn add Birbal
bun add Birbal
```

## Health

**Score 10/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; low quality score; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.3 |
| Published | 2011-12-17 |
| First published | 2011-12-16 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Node | * |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 4 |
| Author | Dhaivat Pandya |
| Maintainers | dhaivatpandya |
| Keywords | routing, router, framework |

## Links

- npm: https://www.npmjs.com/package/Birbal
- Repository: https://github.com/poincare/Birbal
- Issues: http://github.com/poincare/Birbal/issues
- npm.io page: https://npm.io/package/Birbal

## Alternatives

- [express-promise-router](https://npm.io/package/express-promise-router.md) — 736.1K weekly downloads
- [next-usequerystate](https://npm.io/package/next-usequerystate.md) — 29.8K weekly downloads
- [@bitkyc08/opencodex](https://npm.io/package/@bitkyc08/opencodex.md) — 4.6K weekly downloads
- [lynkr](https://npm.io/package/lynkr.md) — 575 weekly downloads
- [baremetal.js](https://npm.io/package/baremetal.js.md) — 42 weekly downloads

## Recent versions

- 0.0.3 (latest) — 2011-12-17
- 0.0.2 — 2011-12-17
- 0.0.1 — 2011-12-16

## README

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.

```javascript
var app = require("Birbal");
```

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

```javascript
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.

```javascript
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.

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

Running a Server
----------------

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

---
_Source: https://npm.io/package/Birbal · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
