{"_id":"now-middleware","_rev":"6-ea1890fbbcc0c5adcda82f6766f75464","name":"now-middleware","description":"Enables a middleware API for hooking into the NowJS execution path.","dist-tags":{"latest":"0.0.1"},"versions":{"0.0.1":{"author":{"name":"Ian Serlin"},"name":"now-middleware","description":"Enables a middleware API for hooking into the NowJS execution path.","version":"0.0.1","repository":{"type":"git","url":"git://github.com/ianserlin/now-middleware.git"},"main":"lib/middleware.js","engines":{"node":">= v0.4.0"},"dependencies":{"now":">= 0.7.6"},"devDependencies":{},"_npmUser":{"name":"ianserlin","email":"npm@ianserlin.com"},"_id":"now-middleware@0.0.1","_engineSupported":true,"_npmVersion":"1.1.0-alpha-6","_nodeVersion":"v0.6.5","_defaultsLoaded":true,"dist":{"shasum":"c562214fa90c3103f0cb19490fe604fc26d350cd","tarball":"https://registry.npmjs.org/now-middleware/-/now-middleware-0.0.1.tgz","integrity":"sha512-54oLYBAVXm+OEmNsKqfTNRPzChauc7gzMqkVp/1tQHoFNsqMpiExxj2jS/5uFKmRlVWU6BwOKUOtAYkuyF7hwA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIDLfMQSmFo2RxnUV6ECB7hpjWkv7ywKLKLhi9eUAicOsAiBm3V6GColY2N4POATd0fFdZxzcjjci+QyMo+ls3WzZSw=="}]},"maintainers":[{"name":"ianserlin","email":"npm@ianserlin.com"}]}},"readme":"NowJS Middleware Layer - Connect style\n--------------------------------------\n\nTo enable:\n\n<code>\nvar nowjs = require('now');\nrequire('now-middleware')(nowjs);\n</code>\n\n\nTo run when a new user connects:\n-------------------------------\n\n<code>\n.before( function );\n</code>\n\n<pre><code>\nnowjs.before(function(client,next){\n  var sid = decodeURIComponent( client.user.cookie[sessionKey] );\n  sessionStore.get( sid, function( err, session ){\n    client.now.session = session;\n    next();\n  });\n});\n</pre></code>\n\nParameters are:\n\n* the beforeware function you want called when each new nowjs session is established, you will receive the newly created nowjs user object (the \"this\" in remotely called functions) passed as client and the next() function which you must call to pass control to the next beforeware layer\n\nTo run when a user makes a remote method call on the server (e.g. to retrieve an HTTP session):\n-------------------------------\n\n<code>\n.use( route, function );\n</code>\n\n<pre><code>\nnowjs.use('users', function(args, next){\n  var self = this;\n  console.log( 'middleware is running' )\n  // add additional arguments\n  args.push( { lollipop: \"is tasty\" } );\n  next();\n});\n</pre></code>\n\nParameters are:\n\n* regex matched route (omit completely if you want to match all routes, what's a route? simply the name and namespace of the function you are calling)\n* the middleware function you want called, this function will receive all arguments the client sent, can manipulate/add to them, and then call next() to pass to the next layer in the middleware","maintainers":[{"email":"ian@useful.io","name":"ianserlin"}],"time":{"modified":"2022-06-22T06:36:04.857Z","created":"2011-12-13T20:39:04.429Z","0.0.1":"2011-12-13T20:39:06.359Z"},"author":{"name":"Ian Serlin"},"repository":{"type":"git","url":"git://github.com/ianserlin/now-middleware.git"},"readmeFilename":""}