# http-connect

> a module that make http instance compatible with connect middleware

Latest version **0.1.4** (published 2015-10-21) · MIT license · 0 weekly downloads

## Install

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

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.4 |
| Published | 2015-10-21 |
| First published | 2015-10-15 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >= 0.10.0 |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Akira Wu |
| Maintainers | akira_cn |
| Keywords | web, middleware, connect, thinkjs |

## Links

- npm: https://www.npmjs.com/package/http-connect
- Repository: https://github.com/akira-cn/http-connect
- Homepage: https://github.com/akira-cn/http-connect#readme
- Issues: https://github.com/akira-cn/http-connect/issues
- npm.io page: https://npm.io/package/http-connect

## Dependencies (2)

- [qs](https://npm.io/package/qs.md) *
- [es6-promise](https://npm.io/package/es6-promise.md) *

## Alternatives

- [@opentelemetry/exporter-zipkin](https://npm.io/package/@opentelemetry/exporter-zipkin.md) — 14.8M weekly downloads
- [pusher-js](https://npm.io/package/pusher-js.md) — 2.0M weekly downloads
- [browserify](https://npm.io/package/browserify.md) — 1.7M weekly downloads
- [sqs-consumer](https://npm.io/package/sqs-consumer.md) — 1.7M weekly downloads
- [@sanity/eventsource](https://npm.io/package/@sanity/eventsource.md) — 930.8K weekly downloads

## Recent versions

- 0.1.4 (latest) — 2015-10-21
- 0.1.3 — 2015-10-21
- 0.1.2 — 2015-10-15
- 0.1.0 — 2015-10-15

## README

# HTTP-Connect

HTTP-Connect is a module that make http instance compatible with connect middleware. [http://senchalabs.github.com/connect]

```js
var PORT = 3000;
var http = require('http');

var url = require('url');

var connect = require('http-connect');

var server = http.createServer(function (request, response) {
  var app = connect({
    req: request,
    res: response,
    pathname: url.parse(request.url).pathname
  });

  var cookieParser = require('cookie-parser');

  app.use(cookieParser());

  app.use(function(req, res, next){
    res.write(JSON.stringify(req.cookies));
    res.end();
  });
});

server.listen(PORT);

console.log("Server runing at port: " + PORT + ".");
```

## Install HTTP-Connect

```bash
$ npm install http-connect
```

## Use with think.js

HTTP-Connect can be used in [think.js](https://github.com/75team/thinkjs) controllers.

```js
var connect = require('http-connect');

module.exports = Controller("Home/BaseController", function(){
  "use strict";
  return {
    init: function(http){
      this.super("init", http);
      //其他的通用逻辑
    },
    indexAction: function(){
      var self = this;
      var app = connect(this.http);

      app.use(function(req, res, next){
        //do sth.
      });
    }
  };
});
```

## License

[MIT](LICENSE)

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