<commit_before>**co-express** is an express wrapper that enables generators to be used as middlewares.

[![NPM version](https://badge.fury.io/js/co-express.png)](http://badge.fury.io/js/co-express) [![Build Status](https://travis-ci.org/mciparelli/co-express.png?branch=master)](https://travis-ci.org/mciparelli/co-express) [![Dependency Status](https://david-dm.org/mciparelli/co-express.png)](https://david-dm.org/mciparelli/co-express) [![devDependency Status](https://david-dm.org/mciparelli/co-express/dev-status.png)](https://david-dm.org/mciparelli/co-express#info=devDependencies)

## Usage

**co-express** lets you write your express routes by using generator functions as middlewares.
Like this:

```js
var fs = require('mz/fs');
var express = require('express');
var wrap = require('co-express');

var app = express();

app.get('/', wrap(function* (req, res) {
  var packageContents = yield fs.readFile('./package.json', 'utf8');
  res.send(packageContents);
}));

app.listen(8000);
```

You can also define multiple generator functions just the [express](https://github.com/visionmedia/express) way, as long as you wrap them and call `next()`:

```js
app.get('/users', wrap(function* (req, res, next) {
  req.users = yield db.getUsers();
  next();
}), wrap(function* (req, res) {
  res.send(req.users);
}));
```

## Installation

```bash
$ npm install co-express
```

## License

(The MIT License)

Copyright (c) 2013 <NAME> &lt;<EMAIL>&gt;

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
'Software'), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be<commit_msg>Add note on second argument<commit_after>**co-express** is an express wrapper that enables generators to be used as middlewares.

[![NPM version](https://badge.fury.io/js/co-express.png)](http://badge.fury.io/js/co-express) [![Build Status](https://travis-ci.org/mciparelli/co-express.png?branch=master)](https://travis-ci.org/mciparelli/co-express) [![Dependency Status](https://david-dm.org/mciparelli/co-express.png)](https://david-dm.org/mciparelli/co-express) [![devDependency Status](https://david-dm.org/mciparelli/co-express/dev-status.png)](https://david-dm.org/mciparelli/co-express#info=devDependencies)

## Usage

**co-express** lets you write your express routes by using generator functions as middlewares.
Like this:

```js
var fs = require('mz/fs');
var express = require('express');
var wrap = require('co-express');

var app = express();

app.get('/', wrap(function* (req, res) {
  var packageContents = yield fs.readFile('./package.json', 'utf8');
  res.send(packageContents);
}));

app.listen(8000);
```

You can also define multiple generator functions just the [express](https://github.com/visionmedia/express) way, as long as you wrap them and call `next()`:

```js
app.get('/users', wrap(function* (req, res, next) {
  req.users = yield db.getUsers();
  next();
}), wrap(function* (req, res) {
  res.send(req.users);
}));
```

### Usage with other libraries

Starting from v2, you can pass your own wrapper function as a second argument.

This argument will be used instead of `co.wrap`.

The support of this wrapper library when used with this extra argument is untested
and may vary from library to library.


## Installation

```bash
$ npm install co-express
```


## License

(The MIT License)

Copyright (c) 2013 <NAME> &lt;<EMAIL>&gt;

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
'Software'), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
{'fraction_non_alphanumeric': 0.14441287878787878, 'fraction_numerical': 0.004498106060606061, 'mean_word_length': 5.044349070100143, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 16, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6452108', 'n_tokens_mistral': 1333, 'n_tokens_neox': 1276, 'n_words': 420}