# beanpoll-http

> HTTP beans for beanpole

Latest version **0.0.10** (published 2012-11-02) · 0 weekly downloads

## Install

```sh
npm install beanpoll-http
pnpm add beanpoll-http
yarn add beanpoll-http
bun add beanpoll-http
```

## 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.10 |
| Published | 2012-11-02 |
| First published | 2012-02-24 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 9 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Craig Condon |
| Maintainers | architectd |

## Links

- npm: https://www.npmjs.com/package/beanpoll-http
- Repository: http://github.com/crcn/bean.http
- npm.io page: https://npm.io/package/beanpoll-http

## Dependencies (9)

- [tq](https://npm.io/package/tq.md) *
- [mime](https://npm.io/package/mime.md) *
- [vine](https://npm.io/package/vine.md) *
- [plugin](https://npm.io/package/plugin.md) *
- [connect](https://npm.io/package/connect.md) *
- [sprintf](https://npm.io/package/sprintf.md) *
- [structr](https://npm.io/package/structr.md) *
- [winston](https://npm.io/package/winston.md) <0.6.0
- [underscore](https://npm.io/package/underscore.md) *

## Recent versions

- 0.0.10 (latest) — 2012-11-02
- 0.0.9 — 2012-02-27
- 0.0.8 — 2012-02-24

## README

### Features

- expose your beanpole routes over HTTP
- easy to specify HTTP Middleware


### Plugins

- `http.gateway` exposes your beanpole routes over HTTP.
- `http.server` starts up the http server.
- `http.middleware` middleware for http specific routes



### Usage

Basic Configuration:

```javascript

//sets add a require path to the app

var loader = require('beanie');


loader.params({
	publicDir: __dirname + "/public"
	http: {
		port: 8080
	}
});

loader.
require('beanpoll-http').
load();
```


### Middleware


#### Basic Auth Middleware


```javascript


router.on({
	
	/**
	 */
	
	'pull basic/auth/user/pass -> secret/route': function() {
		return "authorized!";
	},
	
	
	/**
	 */
	
	'pull secret/route': function(request) {

		function login(user, pass, callback) {

			if(user == 'user' && pass == 'pass') return callback(false, { user: 'user' });
			
			callback('wrong user / pass');
		}
		
		request.forward('basic/auth', { login: login }, function(response) {

			request.end('authorized!');
		})
	}
});

```

#### Session Middleware

```javascript

router.on({
	
	/**
	 */
	
	'pull session -> account': function(request) {
		
		//should be "test" on next call
		console.log(request.session.data.username);
		
		request.session.data.username = 'test';
	},
	
})

```

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