Coder Social home page Coder Social logo

union's Introduction

Synopsis

A hybrid streaming middleware kernel backwards compatible with connect.

Motivation

The advantage to streaming middlewares is that they do not require buffering the entire stream in order to execute their function.

Status

Build Status

Installation

There are a few ways to use union. Install the library using npm. You can add it to your package.json file as a dependancy

  $ [sudo] npm install union

Usage

Union's request handling is connect-compatible, meaning that all existing connect middlewares should work out-of-the-box with union.

(Union 0.3.x is compatible with connect >= 2.1.0)

In addition, the response object passed to middlewares listens for a "next" event, which is equivalent to calling next(). Flatiron middlewares are written in this manner, meaning they are not reverse-compatible with connect.

A simple case

var fs = require('fs'),
    union = require('../lib'),
    director = require('director');

var router = new director.http.Router();

var server = union.createServer({
  before: [
    function (req, res) {
      var found = router.dispatch(req, res);
      if (!found) {
        res.emit('next');
      }
    }
  ]
});

router.get(/foo/, function () {
  this.res.writeHead(200, { 'Content-Type': 'text/plain' })
  this.res.end('hello world\n');
});

router.post(/foo/, { stream: true }, function () {
  var req = this.req,
      res = this.res,
      writeStream;

  writeStream = fs.createWriteStream(Date.now() + '-foo.txt');
  req.pipe(writeStream);

  writeStream.on('close', function () {
    res.writeHead(200, { 'Content-Type': 'text/plain' });
    res.end('wrote to a stream!');
  });
});

server.listen(9090);
console.log('union with director running on 9090');

To demonstrate the code, we use director. A light-weight, Client AND Server side URL-Router for Node.js and Single Page Apps!

A case with connect

Code based on connect

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

var app = connect()
  .use(connect.favicon())
  .use(connect.logger('dev'))
  .use(connect.static('public'))
  .use(connect.directory('public'))
  .use(connect.cookieParser('my secret here'))
  .use(connect.session())
  .use(function (req, res) {
    res.end('Hello from Connect!\n');
  });

http.createServer(app).listen(3000);

Code based on union

var connect = require('connect')
  , union = require('union');

var server = union.createServer({
  buffer: false,
  before: [
    connect.favicon(),
    connect.logger('dev'),
    connect.static('public'),
    connect.directory('public'),
    connect.cookieParser('my secret here'),
    connect.session(),
    function (req, res) {
      res.end('Hello from Connect!\n');
    },
  ]
}).listen(3000);

SPDY enabled server example

API

union Static Members

createServer(options)

The options object is required. Options include:

Specification

  function createServer(options)

  @param options {Object}
  An object literal that represents the configuration for the server.

    @option before {Array}
    The `before` value is an array of middlewares, which are used to route and serve incoming
    requests. For instance, in the example, `favicon` is a middleware which handles requests
    for `/favicon.ico`.

    @option after {Array}
    The `after` value is an array of functions that return stream filters,
    which are applied after the request handlers in `options.before`.
    Stream filters inherit from `union.ResponseStream`, which implements the
    Node.js core streams api with a bunch of other goodies.

    @option limit {Object}
    (optional) A value, passed to internal instantiations of `union.BufferedStream`.

    @option https {Object}
    (optional) A value that specifies the certificate and key necessary to create an instance of
    `https.Server`.

    @option spdy {Object}
    (optional) A value that specifies the certificate and key necessary to create an instance of
    `spdy.Server`.

    @option headers {Object}
    (optional) An object representing a set of headers to set in every outgoing response

Example

var server = union.createServer({
  before: [
    favicon('./favicon.png'),
    function (req, res) {
      var found = router.dispatch(req, res);
      if (!found) {
        res.emit('next');
      }
    }
  ]
});

An example of the https or spdy option.

{
  cert: 'path/to/cert.pem',
  key: 'path/to/key.pem',
  ca: 'path/to/ca.pem'
}

An example of the headers option.

{
  'x-powered-by': 'your-sweet-application v10.9.8'
}

Error Handling

Error handler is similiar to middlware but takes an extra argument for error at the beginning.

var handle = function (err, req, res) {
  res.statusCode = err.status;
  res.end(req.headers);
};

var server = union.createServer({
  onError: handle,
  before: [
    favicon('./favicon.png'),
    function (req, res) {
      var found = router.dispatch(req, res);
      if (!found) {
        res.emit('next');
      }
    }
  ]
});

BufferedStream Constructor

This constructor inherits from Stream and can buffer data up to limit bytes. It also implements pause and resume methods.

Specification

  function BufferedStream(limit)

  @param limit {Number}
  the limit for which the stream can be buffered

Example

var bs = union.BufferedStream(n);

HttpStream Constructor

This constructor inherits from union.BufferedStream and returns a stream with these extra properties:

Specification

  function HttpStream()

Example

var hs = union.HttpStream();

HttpStream Instance Members

url

The url from the request.

Example

httpStream.url = '';

headers

The HTTP headers associated with the stream.

Example

httpStream.headers = '';

method

The HTTP method ("GET", "POST", etc).

Example

httpStream.method = 'POST';

query

The querystring associated with the stream (if applicable).

Example

httpStream.query = '';

ResponseStream Constructor

This constructor inherits from union.HttpStream, and is additionally writeable. Union supplies this constructor as a basic response stream middleware from which to inherit.

Specification

  function ResponseStream()

Example

var rs = union.ResponseStream();

Tests

All tests are written with vows and should be run with npm:

  $ npm test

Licence

(The MIT License)

Copyright (c) 2010-2012 Charlie Robbins & the Contributors 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 included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

union's People

Contributors

3rd-eden avatar bbtx0 avatar coderarity avatar dominictarr avatar dscape avatar eschmitt avatar fent avatar framp avatar indexzero avatar jcrugzz avatar jfhbrook avatar marak avatar mmalecki avatar pdehaan avatar pkrefta avatar pksunkara avatar tellnes avatar thornjad avatar xmader avatar yawnt avatar zckevin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

union's Issues

Connect compatibility issue (bodyParser)

Start a fresh project; install latest connect and union.

index.js

var fs = require('fs'),
    union = require('union'),
    connect = require('connect');

var server = union.createServer({
  before: [
    connect.bodyParser(),
    function (req, res) {
        res.writeHead(200, { 'Content-Type': 'text/html' })
        res.end('<form action="" method="post"><input name=t><input type=submit></form>');
    }
  ]
});

server.listen(9090);

Error when form is submitted:

_stream_readable.js:196
this._readableState.decoder = new StringDecoder(enc);
^
TypeError: Cannot set property 'decoder' of undefined
at Readable.setEncoding (_stream_readable.js:196:31)
at /test/node_modules/connect/lib/middleware/urlencoded.js:63:11
at noop (/test/node_modules/connect/lib/middleware/urlencoded.js:22:3)
at urlencoded (/test/node_modules/connect/lib/middleware/urlencoded.js:60:5)
at /test/node_modules/connect/lib/middleware/bodyParser.js:55:7
at json (/test/node_modules/connect/lib/middleware/json.js:56:55)
at Array.bodyParser [as 0] (/test/node_modules/connect/lib/middleware/bodyParser.js:53:5)
at dispatch (/test/node_modules/union/lib/routing-stream.js:110:21)
at RoutingStream.route (/test/node_modules/union/lib/routing-stream.js:121:5)
at g (events.js:175:14)

EDIT: tested with node v0.10.6, union v0.3.7, connect v2.7.11

Not compatible with all connect middleware

Deps:
[email protected]
[email protected]

Sessions are non-compatible, consider this basic application:

var flatiron = require('flatiron'),
    path = require('path'),
    app = flatiron.app,
    connect = require('connect');

app.use(flatiron.plugins.http, {
  before: [
        connect.cookieParser(),
    connect.session({secret: "test"}),
   ]
});

if (require.main === module) {
  app.init(function () {  
    app.start(8080);
  });
}

So navigating to http://localhost:8080 I would presume would not cause the app to error out. Here is the stack:

"stack": [
    "TypeError: Object [object Object] has no method '_implicitHeader'",
    "    at [object Object].<anonymous> (/node_modules/connect/lib/middleware/session.js:279:31)",
    "    at Object.error (/node_modules/union/lib/core.js:58:14)",
    "    at [object Object].dispatch (/node_modules/flatiron/node_modules/director/lib/director/http/index.js:87:16)",
    "    at Array.2 (/node_modules/flatiron/lib/flatiron/plugins/http.js:72:25)",
    "    at dispatch (/node_modules/union/lib/routing-stream.js:105:20)",
    "    at [object Object].<anonymous> (native)",
    "    at [object Object].g (events.js:156:14)",
    "    at [object Object].emit (events.js:64:17)",
    "    at /node_modules/union/lib/routing-stream.js:101:21",
    "    at /node_modules/connect/lib/middleware/session.js:323:9"
  ],
  "level": "error",
  "message": "uncaughtException"

Odd issues with response stream missing a bunch of stuff

So, I've been trying to get a static middleware for union (and express) running, and I got a bunch of nice features implemented by @substack but getting it to work with union is being painful.

Running the example with the gh-4 branch (which tries to implement getHeader & friends) and trying to get /hello.txt gets you this:

josh@onix:~/dev/ecstatic$ node example/union.js 
Listening on :8080

/home/josh/dev/union/lib/http-stream.js:40
    this.query = ~source.url.indexOf('?')
                             ^
TypeError: Cannot call method 'indexOf' of undefined
    at [object Object].pipeState (/home/josh/dev/union/lib/http-stream.js:40:30)
    at [object Object].emit (events.js:81:20)
    at [object Object].pipe (stream.js:159:8)
    at /home/josh/dev/ecstatic/ecstatic.js:52:11
[1]+  Done                    gedit ecstatic.js
josh@onix:~/dev/ecstatic$ 

So, source.url is missing. Okay, I can circumvent this. But, when I do, it seems the problem's deeper:

josh@onix:~/dev/ecstatic$ node example/union.js 
Listening on :8080
Cannot call method 'indexOf' of undefined

events.js:143
    listener.apply(this, arguments);
             ^
TypeError: Cannot call method 'apply' of undefined
    at [object Object].g (events.js:143:14)
    at [object Object].emit (events.js:81:20)
    at [object Object].pipe (stream.js:159:8)
    at /home/josh/dev/ecstatic/ecstatic.js:52:11
josh@onix:~/dev/ecstatic$ 

This is what ecstatic is doing with the response around that time:

        res.setHeader('content-type', mime.lookup(file));
        var s = fs.createReadStream(file);
        s.pipe(res);
        s.on('error', function (err) {
          res.statusCode = 500;
          if (res.writable) res.end(err && err.stack || err.toString());
        });

and the error seems to occur on s.pipe(res).

I'd fix this myself but I'm not really sure where to look.

Connect 2.0.3 bodyParser middleware issue

var flatiron = require('flatiron'),
    connect = require('connect'),
    app = flatiron.app;

app.use(flatiron.plugins.http, {
  before: [
    connect.bodyParser(),
    function(req, res){}
  ]
});

app.start(9090);

Pretty basic setup, now try posting some data:

curl -d "foo=bar" http://localhost:9090

The server crashes with this error message:

TypeError: Object [object Object] has no method 'setEncoding'

It seems that the standard node http request method setEncoding isn't present in the req object that is passed to middleware.

I give up for now... :)

Cheers,

SPDY support

Hi guys,

I've started working on SPDY implementation for flatiron flatiron/flatiron#32. Adding SPDY requires some changes in union too. Can I issue pull request for this ?

Not compatible with connect-static-file middleware

connect-static-file middleware does not work with union. With connect, it works as expected:

var connect = require('connect')
  , http = require('http')
  , staticFile = require('connect-static-file');

var app = connect()
  .use(staticFile('index.js'));

http.createServer(app).listen(3000);

With union, the browser never gets a response (loading and loading and loading)...:

var connect = require('connect')
  , union = require('union')
  , staticFile = require('connect-static-file');

var server = union.createServer({
  buffer: false,
  before: [
    staticFile('index.js')
  ]
}).listen(3000);

connect-static-file uses send under the hood. Tested with:

"connect": "^3.6.2",
"connect-static-file": "^1.2.0",
"union": "^0.4.6"
node v6.10.3

Using after filters

I have the following code which I think is needed for using after streams.

this.http.server = union.createServer({
    before: [
        function (req, res) {
            var found = self.http.router.dispatch(req, res);
            if (!found) {
                res.emit('next');
            }
        }
    ],
    after: [
        new union.ResponseStream()
    ]
});

But when I start this application, I get the following error:
warning: possible EventEmitter memory leak detected. 11 listeners added. Use emitter.setMaxListeners() to increase limit.

Can you please provide a better/any example for using after streams?

request/response objects do not implement the entire core req/res API

I tried to use connect's static provider, which should've Just Worked. However, it seems that the req and res objects between connect/express and flatiron are not 100% compatible.

Here's a reproducing test program:

var union = require("union"),
    express = require("express"),
    static = express.static(__dirname + '/static');

union.createServer({
  before: [
    static
  ]
}).listen(8080);

express.createServer(static).listen(8081);

console.log("union: localhost:8080");
console.log("express: localhost:8081");

This program works fine for the express server, but for the union server:

josh@onix:/tmp/express-test$ node test.js 
union: localhost:8080
express: localhost:8081

/tmp/express-test/node_modules/express/node_modules/connect/lib/middleware/static.js:162
    if (!res.getHeader('Date')) res.setHeader('Date', new Date().toUTCString()
             ^
TypeError: Object [object Object] has no method 'getHeader'
    at /tmp/express-test/node_modules/express/node_modules/connect/lib/middleware/static.js:162:14
josh@onix:/tmp/express-test$ 

Header test hangs

Running npm test or directly running node test/header-test.js hangs. This occurs when running on Linux, and (as reported by @BigBlueHat in #61 (comment)) on bash on Windows in mingw, but interestingly does not hang in cmd.

Here's the output I get on Linux, even after left running for 10 minutes:

$ npm test

> [email protected] test /home/jade/src/thornjad/union
> vows test/*-test.js --spec -i


  ♢ union/after

  When using union a union server with after middleware
    ✓ should preserve the request until the last call

  ♢ union/body-parser

  When using union with connect body parsing via urlencoded() or json() a request to /
    ✓ should respond with a body-decoded object

  ♢ union/double-write

  When using union an http server which attempts to write to the response twice a GET request to /foo
    ✓ it should respond with { 'hello': 'world' }
    ✓ it should not write to the response twice
  When the tests are over
    ✓ the server should close

  ♢ union/ecstatic

  When using union with ecstatic a request to /404.txt (which does not exist)
    ✓ should respond with 404 status code
  When using union with ecstatic a request to /some-file.txt
    ✓ should respond with hello world

  ♢ union/header


everyauth middleware problem

Hi,

Can anyone help me with this:
I am trying to integrate everyauth with union server. I call the middleware on
before:[
everyauth.middleware(),
........ router.dispatch(...)
]

When I do this, the server blocks and doent return or do anything! Am I doing it wrong ?

.

.

setEncoding is not defined

We need this for a variety of reasons. Currently, without it using connect middleware like bodyParser.js causes incorrect parsing of the POST body.

[email protected] cannot be installed without package-lock.json

$ npm init -y
$ npm install union
npm ERR! code 1
npm ERR! path /home/ANT.AMAZON.COM/calebev/tmp/node_modules/union
npm ERR! command failed
npm ERR! command sh -c npx npm-force-resolutions
npm ERR! npm WARN exec The following package was not found and will be installed: [email protected]
npm ERR! Error: ENOENT: no such file or directory, open './package-lock.json'

This is a bug in npm-force-resolutions, but the issues have been open for a while and the last commit was 3 years ago so I don't think it will be fixed.

union could use npm 8's overrides, or use force-resolutions, or npm-force-resolutions || true.

rogeriochaves/npm-force-resolutions#10
rogeriochaves/npm-force-resolutions#36
rogeriochaves/npm-force-resolutions#66

Most basic Union server takes 200ms to respond, compared to 2ms for Express?

I created the following simple Union server, and it takes 200ms to respond with the "not found" error message.

var union = require('union');

var server = module.exports = union.createServer({

    buffer: false

});

The comparable server with Express, and even more so the bare http server, only takes 1-3ms to respond with the same message. Express is just what I used as a comparison because I knew how to quickly write a similar test.

I'm running this server on a development machine on my LAN. The machine has an i7 processor, and SSD drive, so it's most definitely not something there. It's not a Raspberry Pi with an SD card or anything.

Any ideas why this might be so slow? I can't imagine the 200ms is justified somehow. I have other web apps that do template rendering and database queries in less than that amount of time. That's why I decided to go ahead and make this ticket. Thanks.

bizarre post parsing with latest flatiron

Relevant code:

  app.router.post(options.route, function sendgridPostHandler () {
    var json = require('util').inspect(this.req.body);

    app.log.info('this.req.body: ' + json);
    this.res.end('received');
  });

Relevant curl (problem isn't here):

% curl -X POST -d 'test' localhost:8080/mailjitsu.js
received%   

Relevant logs:

info: Server started on :8080
info: [POST] /mailjitsu.js
info: this.req.body: { test: '' }

{ test: "" } ? Where did that come from? My guess is here, but I'm not sure.

I'm going to bed for now. Insights would be great.

Simple case from Readme.md

I don't know if this is planned but simple case form Readme.md could be a little confusing for newbie users because it requires unknown module ./middleware/favicon. I'm aware that this require is from local filesystem and it should be implemented (and it is in exmples folder) but IMHO simple cases should be working out of the box with simple copy-paste.

What do you think guys ?

Piping response fails

Run the example, request locahost:8080. You'll get this:


union with sugarskull running on 8080

events.js:148
    throw new Error('.once only takes instances of Function');
          ^
Error: .once only takes instances of Function
    at [object Object].once (events.js:148:11)
    at new <anonymous> (/Users/maciej/Programowanie/JavaScript/union/lib/response-stream.js:23:8)
    at new <anonymous> (/Users/maciej/Programowanie/JavaScript/union/lib/routing-stream.js:25:17)
    at Server.<anonymous> (/Users/maciej/Programowanie/JavaScript/union/lib/core.js:26:25)
    at Server.emit (events.js:70:17)
    at HTTPParser.onIncoming (http.js:1479:12)
    at HTTPParser.onHeadersComplete (http.js:102:31)
    at Socket.ondata (http.js:1375:22)
    at TCP.onread (net.js:334:27)

Can't pipe

When used like that:

var fs = require('fs'),
    union = require('union');

union.createServer({
  before: [
    function (req, res, next) {
      var writeStream = fs.createWriteStream('req');
      req.pipe(writeStream);

      writeStream.on('close', function () {
        res.writeHead(200);
        res.end('Wrote to a stream\n');
      });
    }
  ]
}).listen(9000);

file req gets created but no data is found there (empty file) after I POST something to localhost:9000. Can someone confirm it should work so that I can write a test case?

It happens on current master - 3eeeef8.

DeprecationWarning: OutgoingMessage.prototype._headers is deprecated

% node --trace-deprecation /usr/local/bin/http-server
Starting up http-server, serving ./public
Available on:
  http://127.0.0.1:8080
  http://10.2.198.96:8080
Hit CTRL-C to stop the server
[2020-11-11T03:40:13.184Z]  "GET /" "Mozilla/5.0"
(node:13803) [DEP0066] DeprecationWarning: OutgoingMessage.prototype._headers is deprecated
    at new module.exports (/usr/local/lib/node_modules/http-server/node_modules/union/lib/response-stream.js:50:60)
    at new module.exports (/usr/local/lib/node_modules/http-server/node_modules/union/lib/routing-stream.js:30:17)
    at Server.requestHandler (/usr/local/lib/node_modules/http-server/node_modules/union/lib/core.js:27:25)
    at Server.emit (node:events:327:20)
    at parserOnIncoming (node:_http_server:919:12)
    at HTTPParser.parserOnHeadersComplete (node:_http_common:126:17)

this._headers = this.response._headers = this.response._headers || {};

See also #64 http-party/http-server#799

example and tests break on 0.4.12

Running the example gives:

substack : examples $ node simple.js 
union with director running on 8080

/home/substack/projects/union/node_modules/director/lib/director/router.js:402
      match   = path.match(new RegExp('^' + current));
                           ^
SyntaxError: Invalid regular expression: /^/\/: \ at end of pattern
    at new RegExp (unknown source)
    at [object Object].traverse (/home/substack/projects/union/node_modules/director/lib/director/router.js:402:28)
    at [object Object].dispatch (/home/substack/projects/union/node_modules/director/lib/director/http/index.js:62:18)
    at Array.1 (/home/substack/projects/union/examples/simple.js:12:26)
    at dispatch (/home/substack/projects/union/lib/routing-stream.js:100:20)
    at [object Object].<anonymous> (native)
    at [object Object].g (events.js:143:14)
    at [object Object].emit (events.js:61:17)
    at /home/substack/projects/union/lib/routing-stream.js:96:21
    at Array.favicon [as 0] (/home/substack/projects/union/examples/middleware/favicon.js:93:7)
substack : examples $ 

and since the test uses the example file, the test also fails.

connect session not working

there's still issue with connect session middleware and union:

-union: 0.1.7
-flatiron: 0.1.11
-connect: 2.0.0alpha1

As mentioned, connect patch ServerResponse prototype to support event "header". (connect/lib/patch.js)
On session middleware, connect expect the response parameter to be a http.ServerResponse and it listens to "header" event to write cookie header.
(line 221 on connect/lib/middleware/session.js)

    // set-cookie
    res.on('header', function(){
      if (!req.session) return;
      var cookie = req.session.cookie
        , proto = (req.headers['x-forwarded-proto'] || '').toLowerCase()
        , tls = req.connection.encrypted || (trustProxy && 'https' == proto)
        , secured = cookie.secure && tls;

      // browser-session cookies only set-cookie once
      if (null == cookie.expires && !sessionIsNew) return;

      // only send secure cookies via https
      if (cookie.secure && !secured) return debug('not secured');

      debug('set %s to %s', key, req.sessionID);
      res.setHeader('Set-Cookie', cookie.serialize(key, req.sessionID));
    });

As response object forwarded by union to connect is a ResponseStream object, "header" event is never emit.

row

    // set-cookie
    res.on('header', function(){

should be

    // set-cookie
    res.response.on('header', function(){

no idea of how to work around this issue

connect.session doesn't work for connect > 2.3.5

It dies with

/home/kenji/nodejs/union/node_modules/connect/lib/middleware/session.js:213
    if (0 != req.originalUrl.indexOf(cookie.path || '/')) return next();
                             ^
TypeError: Cannot call method 'indexOf' of undefined
    at Array.session [as 4] (/home/kenji/nodejs/union/node_modules/connect/lib/middleware/session.js:213:30)
    at dispatch (/home/kenji/nodejs/union/node_modules/union/lib/routing-stream.js:110:21)
    at g (events.js:185:14)
    at EventEmitter.emit (events.js:85:17)
    at RoutingStream.route (/home/kenji/nodejs/union/node_modules/union/lib/routing-stream.js:114:23)
    at Array.cookieParser [as 3] (/home/kenji/nodejs/union/node_modules/connect/lib/middleware/cookieParser.js:60:5)
    at dispatch (/home/kenji/nodejs/union/node_modules/union/lib/routing-stream.js:110:21)
    at g (events.js:185:14)
    at EventEmitter.emit (events.js:85:17)
    at RoutingStream.route (/home/kenji/nodejs/union/node_modules/union/lib/routing-stream.js:114:23)

Minimal example to reproduce:

var connect = require('connect')
  , union = require('union');

var server = union.createServer({
  buffer: false,
  before: [
    connect.cookieParser('my secret here'),
    connect.session()
  ]
}).listen(3000);

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.