diff --git a/node_modules/coalesce/coalesce.js b/node_modules/coalesce/coalesce.js index db5df7cd..bdf9421e 100644 --- a/node_modules/coalesce/coalesce.js +++ b/node_modules/coalesce/coalesce.js @@ -212,7 +212,7 @@ module.exports=require('theory')((function(){ ,match: '*' ,flow: 0 ,on: state.err - }) + }); state.req = (function(req,res){ req.url = state.url(req); req.file = state.file(req); @@ -578,7 +578,7 @@ module.exports=require('theory')((function(){ if(a(run.on,way+'.meta.state')){ return fn(true) } // change API return fn(false); } - console.log("RUN :-->"+" testing "+opt.file) + console.log("RUN :-->"+" testing "+opt.file); var ts = a.time.is() , p = fork(opt.file,[],{env:process.env}) , gear = run.on[way] || (run.on[way]={meta:{},cogs:{}}) @@ -596,7 +596,7 @@ module.exports=require('theory')((function(){ } web.state.ways.push(a(m,'mod.state')); web.state.ways.sort(web.state.sort); - opt.invincible = gear.meta.invincible + opt.invincible = gear.meta.invincible; run.track(opt,opt.reply); fn(p.pid||true); fn = function(){}; return; diff --git a/node_modules/coalesce/node_modules/formidable/package.json b/node_modules/coalesce/node_modules/formidable/package.json index 177f84f0..0d15f403 100644 --- a/node_modules/coalesce/node_modules/formidable/package.json +++ b/node_modules/coalesce/node_modules/formidable/package.json @@ -24,5 +24,9 @@ "readmeFilename": "Readme.md", "description": "[![Build Status](https://secure.travis-ci.org/felixge/node-formidable.png?branch=master)](http://travis-ci.org/felixge/node-formidable)", "_id": "formidable@1.0.11", - "_from": "formidable@1.0.11" + "dist": { + "shasum": "2c56edbf30989db453ab311ac38b373ca8949b60" + }, + "_from": "formidable@1.0.11", + "_resolved": "https://registry.npmjs.org/formidable/-/formidable-1.0.11.tgz" } diff --git a/node_modules/coalesce/node_modules/node-static/node_modules/colors/package.json b/node_modules/coalesce/node_modules/node-static/node_modules/colors/package.json index 1ccd4c41..5d5f4d5d 100644 --- a/node_modules/coalesce/node_modules/node-static/node_modules/colors/package.json +++ b/node_modules/coalesce/node_modules/node-static/node_modules/colors/package.json @@ -25,5 +25,9 @@ "readme": "# colors.js - get color and style in your node.js console ( and browser ) like what\n\n\n\n\n## Installation\n\n npm install colors\n\n## colors and styles!\n\n- bold\n- italic\n- underline\n- inverse\n- yellow\n- cyan\n- white\n- magenta\n- green\n- red\n- grey\n- blue\n- rainbow\n- zebra\n- random\n\n## Usage\n\n``` js\nvar colors = require('./colors');\n\nconsole.log('hello'.green); // outputs green text\nconsole.log('i like cake and pies'.underline.red) // outputs red underlined text\nconsole.log('inverse the color'.inverse); // inverses the color\nconsole.log('OMG Rainbows!'.rainbow); // rainbow (ignores spaces)\n```\n\n# Creating Custom themes\n\n```js\n\nvar colors = require('colors');\n\ncolors.setTheme({\n silly: 'rainbow',\n input: 'grey',\n verbose: 'cyan',\n prompt: 'grey',\n info: 'green',\n data: 'grey',\n help: 'cyan',\n warn: 'yellow',\n debug: 'blue',\n error: 'red'\n});\n\n// outputs red text\nconsole.log(\"this is an error\".error);\n\n// outputs yellow text\nconsole.log(\"this is a warning\".warn);\n```\n\n\n### Contributors \n\nMarak (Marak Squires)\nAlexis Sellier (cloudhead)\nmmalecki (Maciej MaƂecki)\nnicoreed (Nico Reed)\nmorganrallen (Morgan Allen)\nJustinCampbell (Justin Campbell)\nded (Dustin Diaz)\n\n\n#### , Marak Squires , Justin Campbell, Dustin Diaz (@ded)\n", "readmeFilename": "ReadMe.md", "_id": "colors@0.6.2", - "_from": "colors@>=0.6.0" + "dist": { + "shasum": "feb92acb58bc6d82083ec15e6c8718877e2dd746" + }, + "_from": "colors@>=0.6.0", + "_resolved": "https://registry.npmjs.org/colors/-/colors-0.6.2.tgz" } diff --git a/node_modules/coalesce/node_modules/node-static/node_modules/optimist/node_modules/minimist/package.json b/node_modules/coalesce/node_modules/node-static/node_modules/optimist/node_modules/minimist/package.json index de49bb51..a7876d8f 100644 --- a/node_modules/coalesce/node_modules/node-static/node_modules/optimist/node_modules/minimist/package.json +++ b/node_modules/coalesce/node_modules/node-static/node_modules/optimist/node_modules/minimist/package.json @@ -46,5 +46,9 @@ "url": "https://github.com/substack/minimist/issues" }, "_id": "minimist@0.0.8", - "_from": "minimist@~0.0.1" + "dist": { + "shasum": "857fcabfc3397d2625b8228262e86aa7a011b05d" + }, + "_from": "minimist@~0.0.1", + "_resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz" } diff --git a/node_modules/coalesce/node_modules/node-static/node_modules/optimist/node_modules/wordwrap/package.json b/node_modules/coalesce/node_modules/node-static/node_modules/optimist/node_modules/wordwrap/package.json index df8dc051..9ba95a3a 100644 --- a/node_modules/coalesce/node_modules/node-static/node_modules/optimist/node_modules/wordwrap/package.json +++ b/node_modules/coalesce/node_modules/node-static/node_modules/optimist/node_modules/wordwrap/package.json @@ -41,5 +41,9 @@ }, "homepage": "https://github.com/substack/node-wordwrap", "_id": "wordwrap@0.0.2", - "_from": "wordwrap@~0.0.2" + "dist": { + "shasum": "624b9d3e54ad494743ebeb222c78828a452556bf" + }, + "_from": "wordwrap@~0.0.2", + "_resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-0.0.2.tgz" } diff --git a/node_modules/coalesce/node_modules/node-static/node_modules/optimist/package.json b/node_modules/coalesce/node_modules/node-static/node_modules/optimist/package.json index 84d984d3..82dd72ba 100644 --- a/node_modules/coalesce/node_modules/node-static/node_modules/optimist/package.json +++ b/node_modules/coalesce/node_modules/node-static/node_modules/optimist/package.json @@ -43,5 +43,9 @@ }, "homepage": "https://github.com/substack/node-optimist", "_id": "optimist@0.6.1", - "_from": "optimist@>=0.3.4" + "dist": { + "shasum": "da3ea74686fa21a19a111c326e90eb15a0196686" + }, + "_from": "optimist@>=0.3.4", + "_resolved": "https://registry.npmjs.org/optimist/-/optimist-0.6.1.tgz" } diff --git a/node_modules/coalesce/node_modules/node-static/package.json b/node_modules/coalesce/node_modules/node-static/package.json index 8249ce2a..830a89d9 100644 --- a/node_modules/coalesce/node_modules/node-static/package.json +++ b/node_modules/coalesce/node_modules/node-static/package.json @@ -50,5 +50,9 @@ }, "homepage": "https://github.com/cloudhead/node-static", "_id": "node-static@0.7.1", - "_from": "node-static@0.7.1" + "dist": { + "shasum": "abda969541fc828572002a308831d0e7c64489c6" + }, + "_from": "node-static@0.7.1", + "_resolved": "https://registry.npmjs.org/node-static/-/node-static-0.7.1.tgz" } diff --git a/node_modules/coalesce/node_modules/sockjs-client/node_modules/node-uuid/package.json b/node_modules/coalesce/node_modules/sockjs-client/node_modules/node-uuid/package.json index c6d3d81f..23949263 100644 --- a/node_modules/coalesce/node_modules/sockjs-client/node_modules/node-uuid/package.json +++ b/node_modules/coalesce/node_modules/sockjs-client/node_modules/node-uuid/package.json @@ -31,5 +31,9 @@ }, "homepage": "https://github.com/broofa/node-uuid", "_id": "node-uuid@1.3.3", - "_from": "node-uuid@1.3.3" + "dist": { + "shasum": "d7a9a5131a4851c74f0836c74a37c1e1341a9fa7" + }, + "_from": "node-uuid@1.3.3", + "_resolved": "https://registry.npmjs.org/node-uuid/-/node-uuid-1.3.3.tgz" } diff --git a/node_modules/coalesce/node_modules/sockjs-client/package.json b/node_modules/coalesce/node_modules/sockjs-client/package.json index bf193142..bc70fac2 100644 --- a/node_modules/coalesce/node_modules/sockjs-client/package.json +++ b/node_modules/coalesce/node_modules/sockjs-client/package.json @@ -24,5 +24,9 @@ }, "homepage": "https://github.com/sockjs/sockjs-client-node", "_id": "sockjs-client@0.1.3", - "_from": "sockjs-client@~>0.1.3" + "dist": { + "shasum": "aaaf2f27bf4bf6f101e69f71008c8dbe6e810a81" + }, + "_from": "sockjs-client@~>0.1.3", + "_resolved": "https://registry.npmjs.org/sockjs-client/-/sockjs-client-0.1.3.tgz" } diff --git a/node_modules/coalesce/node_modules/sockjs/node_modules/faye-websocket/node_modules/websocket-driver/package.json b/node_modules/coalesce/node_modules/sockjs/node_modules/faye-websocket/node_modules/websocket-driver/package.json index 37f7c8ed..6bfbb150 100644 --- a/node_modules/coalesce/node_modules/sockjs/node_modules/faye-websocket/node_modules/websocket-driver/package.json +++ b/node_modules/coalesce/node_modules/sockjs/node_modules/faye-websocket/node_modules/websocket-driver/package.json @@ -32,5 +32,9 @@ "readme": "# websocket-driver [![Build Status](https://travis-ci.org/faye/websocket-driver-node.png)](https://travis-ci.org/faye/websocket-driver-node)\n\nThis module provides a complete implementation of the WebSocket protocols that\ncan be hooked up to any I/O stream. It aims to simplify things by decoupling\nthe protocol details from the I/O layer, such that users only need to implement\ncode to stream data in and out of it without needing to know anything about how\nthe protocol actually works. Think of it as a complete WebSocket system with\npluggable I/O.\n\nDue to this design, you get a lot of things for free. In particular, if you\nhook this module up to some I/O object, it will do all of this for you:\n\n* Select the correct server-side driver to talk to the client\n* Generate and send both server- and client-side handshakes\n* Recognize when the handshake phase completes and the WS protocol begins\n* Negotiate subprotocol selection based on `Sec-WebSocket-Protocol`\n* Buffer sent messages until the handshake process is finished\n* Deal with proxies that defer delivery of the draft-76 handshake body\n* Notify you when the socket is open and closed and when messages arrive\n* Recombine fragmented messages\n* Dispatch text, binary, ping and close frames\n* Manage the socket-closing handshake process\n* Automatically reply to ping frames with a matching pong\n* Apply masking to messages sent by the client\n\nThis library was originally extracted from the [Faye](http://faye.jcoglan.com)\nproject but now aims to provide simple WebSocket support for any Node-based\nproject.\n\n\n## Installation\n\n```\n$ npm install websocket-driver\n```\n\n\n## Usage\n\nThis module provides protocol drivers that have the same interface on the\nserver and on the client. A WebSocket driver is an object with two duplex\nstreams attached; one for incoming/outgoing messages and one for managing the\nwire protocol over an I/O stream. The full API is described below.\n\n\n### Server-side with HTTP\n\nA Node webserver emits a special event for 'upgrade' requests, and this is\nwhere you should handle WebSockets. You first check whether the request is a\nWebSocket, and if so you can create a driver and attach the request's I/O\nstream to it.\n\n```js\nvar http = require('http'),\n websocket = require('websocket-driver');\n\nvar server = http.createServer();\n\nserver.on('upgrade', function(request, socket, body) {\n if (!websocket.isWebSocket(request)) return;\n\n var driver = websocket.http(request);\n\n driver.io.write(body);\n socket.pipe(driver.io).pipe(socket);\n\n driver.messages.on('data', function(message) {\n console.log('Got a message', message);\n });\n\n driver.start();\n});\n```\n\nNote the line `driver.io.write(body)` - you must pass the `body` buffer to the\nsocket driver in order to make certain versions of the protocol work.\n\n\n### Server-side with TCP\n\nYou can also handle WebSocket connections in a bare TCP server, if you're not\nusing an HTTP server and don't want to implement HTTP parsing yourself.\n\nThe driver will emit a `connect` event when a request is received, and at this\npoint you can detect whether it's a WebSocket and handle it as such. Here's an\nexample using the Node `net` module:\n\n```js\nvar net = require('net'),\n websocket = require('websocket-driver');\n\nvar server = net.createServer(function(connection) {\n var driver = websocket.server();\n\n driver.on('connect', function() {\n if (websocket.isWebSocket(driver)) {\n driver.start();\n } else {\n // handle other HTTP requests\n }\n });\n\n driver.on('close', function() { connection.end() });\n connection.on('error', function() {});\n\n connection.pipe(driver.io).pipe(connection);\n\n driver.messages.pipe(driver.messages);\n});\n\nserver.listen(4180);\n```\n\nIn the `connect` event, the driver gains several properties to describe the\nrequest, similar to a Node request object, such as `method`, `url` and\n`headers`. However you should remember it's not a real request object; you\ncannot write data to it, it only tells you what request data we parsed from the\ninput.\n\nIf the request has a body, it will be in the `driver.body` buffer, but only as\nmuch of the body as has been piped into the driver when the `connect` event\nfires.\n\n\n### Client-side\n\nSimilarly, to implement a WebSocket client you just need to make a driver by\npassing in a URL. After this you use the driver API as described below to\nprocess incoming data and send outgoing data.\n\n\n```js\nvar net = require('net'),\n websocket = require('websocket-driver');\n\nvar driver = websocket.client('ws://www.example.com/socket'),\n tcp = net.createConnection(80, 'www.example.com');\n\ntcp.pipe(driver.io).pipe(tcp);\n\ndriver.messages.on('data', function(message) {\n console.log('Got a message', message);\n});\n\ntcp.on('connect', function() {\n driver.start();\n});\n```\n\nClient drivers have two additional properties for reading the HTTP data that\nwas sent back by the server:\n\n* `driver.statusCode` - the integer value of the HTTP status code\n* `driver.headers` - an object containing the response headers\n\n\n### Driver API\n\nDrivers are created using one of the following methods:\n\n```js\ndriver = websocket.http(request, options)\ndriver = websocket.server(options)\ndriver = websocket.client(url, options)\n```\n\nThe `http` method returns a driver chosen using the headers from a Node HTTP\nrequest object. The `server` method returns a driver that will parse an HTTP\nrequest and then decide which driver to use for it using the `http` method. The\n`client` method always returns a driver for the RFC version of the protocol\nwith masking enabled on outgoing frames.\n\nThe `options` argument is optional, and is an object. It may contain the\nfollowing fields:\n\n* `maxLength` - the maximum allowed size of incoming message frames, in bytes.\n The default value is `2^26 - 1`, or 1 byte short of 64 MiB.\n* `protocols` - an array of strings representing acceptable subprotocols for\n use over the socket. The driver will negotiate one of these to use via the\n `Sec-WebSocket-Protocol` header if supported by the other peer.\n\nA driver has two duplex streams attached to it:\n\n* `driver.io` - this stream should be attached to an I/O socket like a\n TCP stream. Pipe incoming TCP chunks to this stream for them to be parsed,\n and pipe this stream back into TCP to send outgoing frames.\n* `driver.messages` - this stream emits messages received over the\n WebSocket. Writing to it sends messages to the other peer by emitting frames\n via the `driver.io` stream.\n\nAll drivers respond to the following API methods, but some of them are no-ops\ndepending on whether the client supports the behaviour.\n\nNote that most of these methods are commands: if they produce data that should\nbe sent over the socket, they will give this to you by emitting `data` events\non the `driver.io` stream.\n\n#### `driver.on('open', function(event) {})`\n\nSets the callback to execute when the socket becomes open.\n\n#### `driver.on('message', function(event) {})`\n\nSets the callback to execute when a message is received. `event` will have a\n`data` attribute containing either a string in the case of a text message or a\n`Buffer` in the case of a binary message.\n\nYou can also listen for messages using the `driver.messages.on('data')` event,\nwhich emits strings for text messages and buffers for binary messages.\n\n#### `driver.on('error', function(event) {})`\n\nSets the callback to execute when a protocol error occurs due to the other peer\nsending an invalid byte sequence. `event` will have a `message` attribute\ndescribing the error.\n\n#### `driver.on('close', function(event) {})`\n\nSets the callback to execute when the socket becomes closed. The `event` object\nhas `code` and `reason` attributes.\n\n#### `driver.setHeader(name, value)`\n\nSets a custom header to be sent as part of the handshake response, either from\nthe server or from the client. Must be called before `start()`, since this is\nwhen the headers are serialized and sent.\n\n#### `driver.start()`\n\nInitiates the protocol by sending the handshake - either the response for a\nserver-side driver or the request for a client-side one. This should be the\nfirst method you invoke. Returns `true` iff a handshake was sent.\n\n#### `driver.parse(string)`\n\nTakes a string and parses it, potentially resulting in message events being\nemitted (see `on('message')` above) or in data being sent to `driver.io`. You\nshould send all data you receive via I/O to this method by piping a stream into\n`driver.io`.\n\n#### `driver.text(string)`\n\nSends a text message over the socket. If the socket handshake is not yet\ncomplete, the message will be queued until it is. Returns `true` if the message\nwas sent or queued, and `false` if the socket can no longer send messages.\n\nThis method is equivalent to `driver.messages.write(string)`.\n\n#### `driver.binary(buffer)`\n\nTakes a `Buffer` and sends it as a binary message. Will queue and return `true`\nor `false` the same way as the `text` method. It will also return `false` if\nthe driver does not support binary messages.\n\nThis method is equivalent to `driver.messages.write(buffer)`.\n\n#### `driver.ping(string = '', function() {})`\n\nSends a ping frame over the socket, queueing it if necessary. `string` and the\ncallback are both optional. If a callback is given, it will be invoked when the\nsocket receives a pong frame whose content matches `string`. Returns `false` if\nframes can no longer be sent, or if the driver does not support ping/pong.\n\n#### `driver.close()`\n\nInitiates the closing handshake if the socket is still open. For drivers with\nno closing handshake, this will result in the immediate execution of the\n`on('close')` driver. For drivers with a closing handshake, this sends a\nclosing frame and `emit('close')` will execute when a response is received or a\nprotocol error occurs.\n\n#### `driver.version`\n\nReturns the WebSocket version in use as a string. Will either be `hixie-75`,\n`hixie-76` or `hybi-$version`.\n\n#### `driver.protocol`\n\nReturns a string containing the selected subprotocol, if any was agreed upon\nusing the `Sec-WebSocket-Protocol` mechanism. This value becomes available\nafter `emit('open')` has fired.\n\n\n## License\n\n(The MIT License)\n\nCopyright (c) 2010-2013 James Coglan\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of\nthis software and associated documentation files (the 'Software'), to deal in\nthe Software without restriction, including without limitation the rights to\nuse, copy, modify, merge, publish, distribute, sublicense, and/or sell copies\nof the Software, and to permit persons to whom the Software is furnished to do\nso, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n\n", "readmeFilename": "README.md", "_id": "websocket-driver@0.3.2", - "_from": "websocket-driver@>=0.3.0" + "dist": { + "shasum": "f177ef6611390e2401ae47f35e8386dda987daca" + }, + "_from": "websocket-driver@>=0.3.0", + "_resolved": "https://registry.npmjs.org/websocket-driver/-/websocket-driver-0.3.2.tgz" } diff --git a/node_modules/coalesce/node_modules/sockjs/node_modules/faye-websocket/package.json b/node_modules/coalesce/node_modules/sockjs/node_modules/faye-websocket/package.json index e97437a5..8ac64232 100644 --- a/node_modules/coalesce/node_modules/sockjs/node_modules/faye-websocket/package.json +++ b/node_modules/coalesce/node_modules/sockjs/node_modules/faye-websocket/package.json @@ -37,5 +37,9 @@ "readme": "# faye-websocket\n\n* Travis CI build: [![Build\n status](https://secure.travis-ci.org/faye/faye-websocket-node.png)](http://travis-ci.org/faye/faye-websocket-node)\n* Autobahn tests: [server](http://faye.jcoglan.com/autobahn/servers/),\n [client](http://faye.jcoglan.com/autobahn/clients/)\n\nThis is a general-purpose WebSocket implementation extracted from the\n[Faye](http://faye.jcoglan.com) project. It provides classes for easily\nbuilding WebSocket servers and clients in Node. It does not provide a server\nitself, but rather makes it easy to handle WebSocket connections within an\nexisting [Node](http://nodejs.org/) application. It does not provide any\nabstraction other than the standard [WebSocket\nAPI](http://dev.w3.org/html5/websockets/).\n\nIt also provides an abstraction for handling\n[EventSource](http://dev.w3.org/html5/eventsource/) connections, which are\none-way connections that allow the server to push data to the client. They are\nbased on streaming HTTP responses and can be easier to access via proxies than\nWebSockets.\n\n\n## Installation\n\n```\n$ npm install faye-websocket\n```\n\n\n## Handling WebSocket connections in Node\n\nYou can handle WebSockets on the server side by listening for HTTP Upgrade\nrequests, and creating a new socket for the request. This socket object exposes\nthe usual WebSocket methods for receiving and sending messages. For example this\nis how you'd implement an echo server:\n\n```js\nvar WebSocket = require('faye-websocket'),\n http = require('http');\n\nvar server = http.createServer();\n\nserver.on('upgrade', function(request, socket, body) {\n if (WebSocket.isWebSocket(request)) {\n var ws = new WebSocket(request, socket, body);\n \n ws.on('message', function(event) {\n ws.send(event.data);\n });\n \n ws.on('close', function(event) {\n console.log('close', event.code, event.reason);\n ws = null;\n });\n }\n});\n\nserver.listen(8000);\n```\n\n`WebSocket` objects are also duplex streams, so you could replace the\n`ws.on('message', ...)` line with:\n\n```js\n ws.pipe(ws);\n```\n\nNote that under certain circumstances (notably a draft-76 client connecting\nthrough an HTTP proxy), the WebSocket handshake will not be complete after you\ncall `new WebSocket()` because the server will not have received the entire\nhandshake from the client yet. In this case, calls to `ws.send()` will buffer\nthe message in memory until the handshake is complete, at which point any\nbuffered messages will be sent to the client.\n\nIf you need to detect when the WebSocket handshake is complete, you can use the\n`onopen` event.\n\nIf the connection's protocol version supports it, you can call `ws.ping()` to\nsend a ping message and wait for the client's response. This method takes a\nmessage string, and an optional callback that fires when a matching pong\nmessage is received. It returns `true` iff a ping message was sent. If the\nclient does not support ping/pong, this method sends no data and returns\n`false`.\n\n```js\nws.ping('Mic check, one, two', function() {\n // fires when pong is received\n});\n```\n\n\n## Using the WebSocket client\n\nThe client supports both the plain-text `ws` protocol and the encrypted `wss`\nprotocol, and has exactly the same interface as a socket you would use in a web\nbrowser. On the wire it identifies itself as `hybi-13`.\n\n```js\nvar WebSocket = require('faye-websocket'),\n ws = new WebSocket.Client('ws://www.example.com/');\n\nws.on('open', function(event) {\n console.log('open');\n ws.send('Hello, world!');\n});\n\nws.on('message', function(event) {\n console.log('message', event.data);\n});\n\nws.on('close', function(event) {\n console.log('close', event.code, event.reason);\n ws = null;\n});\n```\n\nThe WebSocket client also lets you inspect the status and headers of the\nhandshake response via its `statusCode` and `headers` properties.\n\n\n## Subprotocol negotiation\n\nThe WebSocket protocol allows peers to select and identify the application\nprotocol to use over the connection. On the client side, you can set which\nprotocols the client accepts by passing a list of protocol names when you\nconstruct the socket:\n\n```js\nvar ws = new WebSocket.Client('ws://www.example.com/', ['irc', 'amqp']);\n```\n\nOn the server side, you can likewise pass in the list of protocols the server\nsupports after the other constructor arguments:\n\n```js\nvar ws = new WebSocket(request, socket, body, ['irc', 'amqp']);\n```\n\nIf the client and server agree on a protocol, both the client- and server-side\nsocket objects expose the selected protocol through the `ws.protocol` property.\n\n\n## Initialization options\n\nBoth the server- and client-side classes allow an options object to be passed\nin at initialization time, for example:\n\n```js\nvar ws = new WebSocket(request, socket, body, protocols, options);\nvar ws = new WebSocket.Client(url, protocols, options);\n```\n\n`protocols` is an array of subprotocols as described above, or `null`.\n`options` is an optional object containing any of these fields:\n\n* `headers` - an object containing key-value pairs representing HTTP headers to\n be sent during the handshake process\n* `ping` - an integer that sets how often the WebSocket should send ping\n frames, measured in seconds\n\n\n## WebSocket API\n\nBoth server- and client-side `WebSocket` objects support the following API.\n\n* `on('open', function(event) {})` fires when the socket connection is\n established. Event has no attributes.\n* `on('message', function(event) {})` fires when the socket receives a\n message. Event has one attribute, `data`, which is either a `String`\n (for text frames) or a `Buffer` (for binary frames).\n* `on('error', function(event) {})` fires when there is a protocol error\n due to bad data sent by the other peer. This event is purely informational,\n you do not need to implement error recover.\n* `on('close', function(event) {})` fires when either the client or the\n server closes the connection. Event has two optional attributes,\n `code` and `reason`, that expose the status code and message\n sent by the peer that closed the connection.\n* `send(message)` accepts either a `String` or a `Buffer` and sends a\n text or binary message over the connection to the other peer.\n* `ping(message = '', function() {})` sends a ping frame with an\n optional message and fires the callback when a matching pong is received.\n* `close(code, reason)` closes the connection, sending the given status\n code and reason text, both of which are optional.\n* `version` is a string containing the version of the `WebSocket`\n protocol the connection is using.\n* `protocol` is a string (which may be empty) identifying the\n subprotocol the socket is using.\n\n\n## Handling EventSource connections in Node\n\nEventSource connections provide a very similar interface, although because they\nonly allow the server to send data to the client, there is no `onmessage` API.\nEventSource allows the server to push text messages to the client, where each\nmessage has an optional event-type and ID.\n\n```js\nvar WebSocket = require('faye-websocket'),\n EventSource = WebSocket.EventSource,\n http = require('http');\n\nvar server = http.createServer();\n\nserver.on('request', function(request, response) {\n if (EventSource.isEventSource(request)) {\n var es = new EventSource(request, response);\n console.log('open', es.url, es.lastEventId);\n \n // Periodically send messages\n var loop = setInterval(function() { es.send('Hello') }, 1000);\n \n es.on('close', function() {\n clearInterval(loop);\n es = null;\n });\n \n } else {\n // Normal HTTP request\n response.writeHead(200, {'Content-Type': 'text/plain'});\n response.end('Hello');\n }\n});\n\nserver.listen(8000);\n```\n\nThe `send` method takes two optional parameters, `event` and `id`. The default\nevent-type is `'message'` with no ID. For example, to send a `notification`\nevent with ID `99`:\n\n```js\nes.send('Breaking News!', {event: 'notification', id: '99'});\n```\n\nThe `EventSource` object exposes the following properties:\n\n* `url` is a string containing the URL the client used to create the\n EventSource.\n* `lastEventId` is a string containing the last event ID received by the\n client. You can use this when the client reconnects after a dropped\n connection to determine which messages need resending.\n\nWhen you initialize an EventSource with ` new EventSource()`, you can pass\nconfiguration options after the `response` parameter. Available options are:\n\n* `headers` is an object containing custom headers to be set on the\n EventSource response.\n* `retry` is a number that tells the client how long (in seconds) it\n should wait after a dropped connection before attempting to reconnect.\n* `ping` is a number that tells the server how often (in seconds) to\n send 'ping' packets to the client to keep the connection open, to defeat\n timeouts set by proxies. The client will ignore these messages.\n\nFor example, this creates a connection that allows access from any origin, pings\nevery 15 seconds and is retryable every 10 seconds if the connection is broken:\n\n```js\nvar es = new EventSource(request, response, {\n headers: {'Access-Control-Allow-Origin': '*'},\n ping: 15,\n retry: 10\n});\n```\n\nYou can send a ping message at any time by calling `es.ping()`. Unlike\nWebSocket, the client does not send a response to this; it is merely to send\nsome data over the wire to keep the connection alive.\n\n\n## License\n\n(The MIT License)\n\nCopyright (c) 2010-2013 James Coglan\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of\nthis software and associated documentation files (the 'Software'), to deal in\nthe Software without restriction, including without limitation the rights to\nuse, copy, modify, merge, publish, distribute, sublicense, and/or sell copies\nof the Software, and to permit persons to whom the Software is furnished to do\nso, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n\n", "readmeFilename": "README.md", "_id": "faye-websocket@0.7.0", - "_from": "faye-websocket@0.7.0" + "dist": { + "shasum": "c16c50ec0d483357a8eafd1ec6fcc313d027f5be" + }, + "_from": "faye-websocket@0.7.0", + "_resolved": "https://registry.npmjs.org/faye-websocket/-/faye-websocket-0.7.0.tgz" } diff --git a/node_modules/coalesce/node_modules/sockjs/node_modules/node-uuid/package.json b/node_modules/coalesce/node_modules/sockjs/node_modules/node-uuid/package.json index c6d3d81f..bf72ee7c 100644 --- a/node_modules/coalesce/node_modules/sockjs/node_modules/node-uuid/package.json +++ b/node_modules/coalesce/node_modules/sockjs/node_modules/node-uuid/package.json @@ -31,5 +31,10 @@ }, "homepage": "https://github.com/broofa/node-uuid", "_id": "node-uuid@1.3.3", - "_from": "node-uuid@1.3.3" + "dist": { + "shasum": "d7a9a5131a4851c74f0836c74a37c1e1341a9fa7" + }, + "_from": "node-uuid@1.3.3", + "_resolved": "https://registry.npmjs.org/node-uuid/-/node-uuid-1.3.3.tgz", + "scripts": {} } diff --git a/node_modules/coalesce/node_modules/sockjs/package.json b/node_modules/coalesce/node_modules/sockjs/package.json index 1d16d9b8..edf63b23 100644 --- a/node_modules/coalesce/node_modules/sockjs/package.json +++ b/node_modules/coalesce/node_modules/sockjs/package.json @@ -28,5 +28,9 @@ "url": "https://github.com/sockjs/sockjs-node/issues" }, "_id": "sockjs@0.3.8", - "_from": "sockjs@~>0.3.1" + "dist": { + "shasum": "b512849ed629f7ec2372ded3061bb05735ee45e9" + }, + "_from": "sockjs@~>0.3.1", + "_resolved": "https://registry.npmjs.org/sockjs/-/sockjs-0.3.8.tgz" } diff --git a/node_modules/coalesce/package.json b/node_modules/coalesce/package.json index be628f8e..d64e5153 100644 --- a/node_modules/coalesce/package.json +++ b/node_modules/coalesce/package.json @@ -1,6 +1,6 @@ { "name": "coalesce", - "version": "0.1.9-bu", + "version": "0.1.9-bv", "author": { "name": "Mark Nadal" }, @@ -20,6 +20,10 @@ "main": "coalesce", "readme": "Coalesce\r\n========\r\n\r\n_Fuses your code into an emergent superstructure._\r\n\r\n[![The Tech Talk](http://dl.dropboxusercontent.com/u/4374976/screenshots/coalesce.png)](http://vimeo.com/85853754)\r\n\r\nAs simple as:\r\n```\r\nnpm install coalesce && node -e \"require('coalesce')({port:8888, sec: -2})\"\r\n```\r\n\r\nThat is it, now you can create infinite new projects, like this one:\r\n\r\n**hello.html**\r\n```\r\n\r\n\r\n\t\r\n\t\t
\r\n\t\t\tHello !\r\n\t\t
\r\n\t\t\r\n\t\r\n\r\n```\r\n**hello.js**\r\n```\r\nmodule.exports = require('theory')\r\n('hello', function(a){\r\n\r\n a.com.send({ what: \"World\", where: {on: 'magic'} });\r\n\r\n return (document.hello.to.onkeyup = function(m){\r\n\t\r\n\t\tm && m.what? document.hello.to.value = m.what :\r\n\t\ta.com.send({what: document.hello.to.value, where: 'magic' });\r\n\t\t\r\n });\r\n\r\n});\r\n```\r\nSave these two files in a subfolder called 'play' in the same directory as the install. (Don't want to copy/paste? Just clone this repo and run `node init.js` in it instead of the npm command.)\r\n\r\nNow load in 2 windows, side by side, the inputs will synchronize when you type!\r\n\r\nCuriosity perked? Check out the two test apps in the playground by simply navigating to them in your browser. Or, read on. Here are some quick hints at why it is awesome (skip this to continue to code examples).\r\n\r\n##Summary of Thoughts##\r\n1. Your module is automatically available to be asynchronously required anywhere else, node or browser - allowing you to manage your dependencies in your JS and not the HTML.\r\n2. Your modules get magically deployed and initialized when a browser requests them, or if otherwise specified in a startup configuration.\r\n3. Your module can optionally receive the request and provide a response, even though it runs in a separate process, already distributed and in parallel. Same setup for multiple machines when connected.\r\n4. Your module's primary communication practically runs off of function calls, even if it is across systems or multiple systems. Module to module communication is easy, loosely coupled directly to their functions.\r\n5. Not opinionated, works whether your code only wants to be RESTful, or only a thick client with sockets, or entirely P2P being relayed through the server.\r\n\r\n###...continued code examples###\r\nBut then you are like, \"yo, where is my $?\" and I reply \"I ain't your sugar daddy, foo'.\" so you then:\r\n```\r\nmodule.exports = require('theory')\r\n('hello', function(a){\r\n\t\r\n\t// your initialization code here.\r\n\t\r\n\treturn { world: $('input').val() }; // the module you export. \r\n\r\n},['http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js']);\r\n```\r\nYupe, that is right, you can declare and manage your dependencies all within your javascript!\r\n\r\nAll you need in your HTML is one script tag that requires your app from inside, as seen above:\r\n```\r\n\r\n```\r\nNow once your modularized code loads, it won't execute until all of your dependencies are loaded.\r\n\r\nThis finally makes it easy to manage any type of large project.\r\nIf one of your dependencies is also a module, which has dependencies within it, everything asynchronously cascades.\r\nThe Theory library makes sure any Inception style depth level of dependencies is all stacked up properly before your code runs.\r\n\r\nHey, afterall, Cobb's wife Mal lives in the Unconstructed Dream Space, and she is named after me*mAl*locate, which is a nightmare for your memory.\r\n(if you didn't laugh... ignore this ever happened)\r\n\r\nSo you are probably like, hey, that is what Theory does, but what is Coalesce? \r\n>Coalesce is the web that connects all of your modules, both Node and in the browser.\r\nBut it provides more than just a seamless TCP / HTTP / AJAX / Websocket communication layer for your apps, it also automatically distributes and deploys them.\r\n\r\nThis is kind of a throwback to PHP, but don't worry, in a good way.\r\nRestart Coalesce with `node -e \"require('coalesce')({port:8888})\"`, you run this once and it acts as the master web server.\r\nYou then create your app - let's overwrite hello.js, again, to this:\r\n```\r\nmodule.exports = require('theory')\r\n('hello', function(a){\r\n\t\r\n\tconsole.log(\"Running in both Node and on the page.\");\r\n\r\n});\r\n```\r\nWhen you fire up from your browser, your browser makes a request to load 'hello.js'.\r\nCoalesce then attempts to execute 'hello.js' as a separate Node process. \r\nIf it crashes, it assumes it is a client only script, like jQuery, and serves it as a static file and remembers to do so in future.\r\n(Note: The assumptions and static server behaviors can be modified or overwritten, as described in the API).\r\nHowever, if the code can run in Node it does, and in particular, if it is a Theory module, it automagically integrates.\r\n\r\nNow take this example, let's overwrite hello.js again:\r\n```\r\nmodule.exports = require('theory')\r\n('hello', function(a){\r\n\t\r\n\tconsole.log(\"Running in both Node and on the page.\");\r\n\t\r\n\tif( root.page ){\r\n\t\ta.com.send(\"Hello World, from the page!\");\r\n\t}\r\n\t\r\n\treturn (function(m){\r\n\t\t\r\n\t\tif( root.node ){\r\n\t\t\tconsole.log(m.what);\t\r\n\t\t}\r\n\t\t\r\n\t});\r\n\r\n});\r\n```\r\nNow when you refresh you should see your Node console print out the message that had been sent from the browser.\r\nThere are several things to learn from this.\r\n\r\n###Conclusion###\r\n1. Coalesce should have automatically roll reloaded (since hot reloading is dangerous) your server side hello.js for you without needing to restart Coalesce.\r\n2. Your module is exported and available on both client and server via `theory.hello` namespace, which is a function that takes the parameter `m` for 'message'.\r\n3. Your single file app should be running on both the server and the client, by using the globally available `root.node` and `root.page` we can determine the corresponding logic.\r\n4. Your module is initialized with a copy of Theory in the parameter, called `a` which is local to your module and provides an interface to your module's dependencies.\r\n5. It also holds the default utilities of Theory, such as the communication layer in `a.com` which is used to send a message to your server side 'hello' module.\r\n6. The returned function exported out in (3) receives this message, and then logs it out.\r\n\r\nNote, this is the same thing that happened earlier with the synchronizing inputs - except since that was client side only \r\n(the module crashed when it tried to access the `document` element, which is undefined in node) and security was disabled via `{sec: -2}`,\r\nthe message relayed through the server to all other windows where they were on 'magic' and displayed the message in the input.\r\n(Javascript's native `keyup` listener was bound to the exported module, which was responsible for then sending the input value).\r\n\r\nAt this point, you feel like you were following along, but now everything just exploded and you are probably confused.\r\n\r\nThe reason why, is because in just 20 LOC or less, you get access to a ton of power, which is exposed to you via raw primitives.\r\n\r\nRemember, elegant complexity is created from the emergence of simplicity. This is coalescence.\r\n\r\n## Messages ##\r\nBefore we talk about how to intercept HTTP requests and such, you must understand how the magic behaves.\r\nCoalesce hates opinionated frameworks, and is as unopinionated as possible. The one catch is how a message is structured.\r\nMessages are the glue that causes all your apps to work in unison, so they are vital to the core of everything.\r\nPardon the cross-disciplinary worlds, but Coalesce borrows the 'W's of journalism to describe information.\r\n\r\n**Who . What . When . Where . Why . How**\r\n\r\nThese little goodies are what produce the powerful flexibility of Coalesce, and therefore are required for the magic to happen.\r\nIf you cannot accept this one opinion, which enables you to be free from opinions everywhere else, then Coalesce is not for you.\r\n\r\n- **Who** An expandable object containing data relating to the recipient and the sender.\r\n\t- `{who: 'Mark'}` expands into `{who: { to: 'Mark' }}` which indicates the message is to be sent to Mark.\r\n\t- In Node, `m.who.tid` is the ID of the specific tab that sent the socket message.\r\n\t- In Node, `m.who.sid` is the session ID from the original HTTP request.\r\n\t- Server Examples:\r\n\t\t- `a.com.send({ what: \"This is sent back to the same tab which sent me this message.\", who: m.who.tid })`\r\n\t\t- `a.com.send({ what: \"I will be sent to every tab that is in this session.\", who: m.who.sid })`\r\n- **What** An expandable anything. This is the crux of the data you are actually sending, everything else is just metadata relating to the payload.\r\n\t- Client Examples:\r\n\t\t- `a.com.send(\"Hello world!\")` expands into and is accessible via `m.what`.\r\n\t\t- `a.com.send({ foo: 'bar' })` the value of 'bar' is accessible via `m.what.foo`.\r\n\t\t- `a.com.send({ foo: 'bar', who: 'Mark' })` expands into `{ who: {to: 'Mark'}, what: {foo: 'bar'} }`.\r\n\t\t- `a.com.send({ what: {foo: 'bar'}, who: {to: 'Mark'} })` is already expanded.\r\n- **When** Is a hyper precise millisecond timestamp of when the message was created.\r\n\t- It is 17 digits long, which is 4 digits longer than the normal `new Date().getTime()`.\r\n\t- It is not expandable.\r\n- **Where** Is an expandable object pertaining to pub/sub and where the message has been processed.\r\n\t- `{where: 'magic'}` expands into `{where: {at: 'magic'}}` which broadcasts the message to subscribers of the 'magic' channel.\r\n\t- `{where: {on: 'magic'}}` subscribes and broadcasts to the 'magic' channel.\r\n\t- `{where: {off: 'magic'}}` broadcasts and unsubscribes to the 'magic' channel.\r\n- **Why** Is not used, but can be optionally added if you want to provide an arbitrary comment about why the message was sent.\r\n- **How** Mandatory Metadata Object.\r\n\t- `m.how.way` holds the magical key which routes which way the object goes, by default is the name of the module.\r\n\t- Can overwrite the 'way' property to communicate with other modules, or directly to functions of a module using the dot notation.\r\n\t- Usage of the 'way' property, for now, will be described elsewhere.\r\n\t- You can attach any critical metadata, such as version numbers, etc.\r\n\r\nBecause communication between modules is so important, the Theory library provides many helper functions.\r\nDespite this, it is strongly recommended and encouraged you write your own helper functions ontop of the helper functions.\r\nNot to get too meta, but the Theory library also has helper functions to assist you in writing your own helper functions.\r\nIf this is not already an emphasis enough on how important this is,\r\nthen also note that the entire security of your app is controlled by what information you allow to flow through these APIs you create.\r\nBecause Coalesce is not opinionated, you have to enforce your own validation, sanitation, and app specific authorization.\r\n\r\nTherefore, writing your own abstraction ontop of the communication layer will substantially ease your own development and prevent vulnerabilities.\r\n\r\n## Intercepting HTTP ##\r\n\r\nNow we get to start to use Coalesce's API.\r\nThis means we're going to use the more robust and explicit form of declaring a module, rather than just the shorthand we have been using.\r\n```\r\nmodule.exports = require('theory')\r\n({name: 'hello'\r\n, author: 'Mark Nadal'\r\n, version: 5\r\n, dependencies: [\r\n 'fs'\r\n],state: { way: 'server' }\r\n, invincible: true\r\n, init: function(a){\r\n return {\r\n server: function(m){\r\n // HTTP Intercept:\r\n console.log(m);\r\n a.fs.writeFileSync(__dirname+'./lastReq.js', \"alert('The last request was at \"+Date()+\"')\");\r\n m.what.body = \"alert('Hello World!')\";\r\n a.com.reply(m);\r\n }\r\n }\r\n}});\r\n```\r\nNow refresh the page, we should get an ugly ol'alert message. What we are learning...\r\n\r\n1. Rather than parameters of name, initializing function, and optional dependencies - we can just have a single parameter that is similar to a package.json file.\r\n2. This also allows you to wrap it inside another self calling closure that returns an object, if you would like. This is the style seen in the examples, but not demonstrated here.\r\n3. The `state` property tells Coalesce where your module will intercept HTTP requests. In this case, we want to receive it in the 'server' function of our exported module.\r\n4. Because Coalesce will assume a script is client side only if it crashes, we activate the `invincible` tag to tell Coalesce to respawn this module server side if it does crash.\r\n5. As the console will show, we have access to the request `m.what.url`, `m.what.headers`, and `m.what.cookies`.\r\n6. In the same way the communication module is available via `a.com`, our dependencies are available, so we can easily use the filesystem module via `a.fs`. A dependency of `['./subdir/module-name']` is accessible via `a['module-name']`.\r\n7. We can modify the response, by setting a `m.what.body`, `m.what.type`, and so on.\r\n8. `a.com.reply` is a helper that accepts the message passed into the function, which you modify directly, and sends it back to whatever had sent it. It is used by Coalesce for HTTP replies, and by `a.com.ask` client side.\r\n9. You should never write code with alert messages, writing useless data directly to the filesystem on every request, and inline javascript code. Bleck, do as I say, not as I do.\r\n\r\nSo let's fiddle with the http function by overwriting it with this:\r\n```\r\n // HTTP Intercept:\r\n console.log(m);\r\n m.what.url.pathname = '/play/lastReq.js';\r\n m.what.type = 'js';\r\n a.com.reply(m);\r\n```\r\nRefresh and bam. It delivered the file we created previously by changing the route of the pathname.\r\n\r\nThis is interesting, though, because a lot of times we don't want our REST endpoint to be at some ugly path to filename, let alone then only be used to redirect to some other filename. We want the opposite, we want some pretty (extensionless) endpoint name which maps request(s) to our process. That way we could do things like `/hello` or `/hello/user/mark` or `/hello?name=mark`. Not all apps are like this, and therefore Coalesce should not force this, nor should it prevent it.\r\n\r\nIn order to configure this, we can't dynamically wait for our app to automatically be deployed - because the browser will never be requesting that file, but the pretty route instead! Therefore we must tell Coalesce to run our app at start up, so that way it will be ready and listening on that route. First, we need to update or create the initialization.\r\n\r\n**init.js**\r\n```\r\nrequire('coalesce')({\r\n\tport: 8888\r\n\t,run: ['./play/hello']\r\n});\r\n```\r\nSave or replace this to the install or repo folder, and restart Coalesce now with `node init.js`. Next update your hello.js to have a state proprety of `{ way: 'server', match: '/asdf', flow: -1 }`. Some quick points:\r\n\r\n1. Coalesce takes a single parameter which is an options object.\r\n2. You declare your routes in your app itself with the state property, not in the configuration - this makes things super flexible.\r\n3. Flow controls the priority or weight or ordering of your route. The static file server is at `0`, so negative numbers allow you to catch and respond to a request before the file on disk is sent - thus blocking or overwriting it, if you want, for security purposes. Positive numbers will only be received if the file doesn't already exist.\r\n4. Match is pretty much self descriptive, it is the path relative to the server that you want to listen on. You can also have dynamic routes, using basic string pattern matching symbols, that map into parameters.\r\n5. For anything more complex, do not use the `state.match`, instead send a regex as a string on `state.regex` and `state.flags` which Coalesce will evaluate.\r\n\r\nAlright, now let's update the http function of our hello.js file again:\r\n```\r\n // HTTP Intercept:\r\n console.log(m.what.url);\r\n\t\t\tm.what.body = \"Hello, \"+ (m.what.url.query.name || 'World') +\"!\";\r\n a.com.reply(m);\r\n```\r\nAwesome sauce, hit up and look what it says! Now try playing around with it yourself. That's all for now on this topic, folks.\r\n\r\n## Intercepting Sockets ##\r\nThis is done by default, upon `a.com.send` and mapped directly to your main module function. You can also communicate to other modules, via `a.com('yourOtherModule').send`, which will always pass through the server side module first. Once received, you then decide if you want to `a.com.reply` back to the client, or `m.where` client side you want to `a.com.send` it out to. Server to browser communication can only be emitted from and to the same module, unless you enable the `relay` property in the security options on your Coalesce initialization - but warning, this is a security vulnerability. This relay option was necessary for the examples to work.\r\n\r\nDespite this flexibility of intricacy, it is going to be highly recommended that you use Redis' pubsub anyways inside of your module, because it gives you an extra layer of control over the flow points of your app. Consider this comparison, by default Coalesce provides:\r\n\r\n1. Client emit --> 2. Server receive, sanitize, validate, process. Emit --> to another module 3. process, then Server emit --> 4. Client(s) receive.\r\n\r\nAdding in Redis, you can get this kind of fine grain precision:\r\n\r\n1. Client emit --> 2. Server receive, sanitize, validate, process in the context of the sender. Publish to recipients --> 3. Server receives, processes in the context of recipient, then Server emits --> each 4. Client receives.\r\n\r\nIf you think about this it pretty much gives you complete control over every possible aspect of any type of app logic, yet it is all within a fairly elegant flow structure. Although you are left with the added complexity of having to manage and handle Redis subscriptions for the clients in the server and making sure everything is atomic, especially in the context of your app being possibly run in parallel processes. Coalesce will not do this for you, because it treads on too many opinions, however helper modules for this may be released in the future to ease managing this for you - then you just include the corresponding module which matches whatever particular assumption you need for that specific app.\r\n\r\n## API ##\r\n\r\n### Config Options ###\r\n\r\n- `host` the hostname you want for the server. *`'localhost'`*\r\n- `port` the port which you want the server to listen on. *`80`*\r\n- `dir` the root directory for the server. *(defaults to the directory of file requiring coalesce)*\r\n- `sec` the security options object.\r\n - `relay` allows messages to pass through the server to other clients automatically if there is no matching module to route to. *`false`*\r\n - `incognito` no session cookie tracking, equivalent to a browser's incognito mode, except for the server. *`false`*\r\n - `key` same as https.createServer's key option, such as the contents of a key.pem file. *`''`*\r\n - `cert` same as https.createServer's cert option, such as the contents of a cert.pem file. *`''`*\r\n - rather than declaring `sec` as an object, you can set its value to one of the following **shorthands**:\r\n - `-2` == `{relay: true, incognito: true}`\r\n- `run` an array of paths you want to run when the server spins up. *`[]`*\r\n- `hook` some special hooks for debugging purposes that will get embedded into Coalesce such as:\r\n\t- `pre` a function which gets called at the beginning of every request. Good for any global request monitoring, like `console.log`ing the `req.url` for logging purposes. *`function(req,res){ }`*\r\n\t- `aft` a function which gets called after the request is handled. *`function(req,res){ }`*\r\n\t- `err` a function which gets called in case the static server encounters an error. *`function(req,res){ }`*\r\n- `com` the SockJS config options object, see SockJS's docs.\r\n\r\n**miscellaneous:**\r\n\r\n- `no_global_theory_src` prevents auto linking and caching Theory for global server side reference as well as client side HTML reference. *`false`*\r\n- `impatient` the millisecond timeout of how long a request should wait for a module to auto deploy itself and intercept the request before Coalesce hands it to the static server. *`3000`*\r\n\r\nExample:\r\n```\r\nvar Coalesce = require('coalesce')\r\n\t,opt = {};\r\n\r\nopt.port = 8888;\r\nopt.sec = { relay: true };\r\nopt.hook = { pre: function(req,res){\r\n\tconsole.log(req.url);\r\n}}\r\nopt.impatient = 5*1000;\r\nopt.com = {\r\n\tlog: function(level, m){\r\n\t\tif(level === 'error') \r\n\t\t\tconsole.log(m);\r\n\t}\r\n}\r\n\r\nCoalesce(opt);\r\n\r\nconsole.log(\"Coalesce @ \"+ opt.port);\r\n```\r\n\r\n### Module Options ###\r\n\r\n- `state` the state object, for intercepting HTTP requests, as detailed in the examples. *`{}`*\r\n - `m.what.headers` are the default headers from the request.\r\n - `m.what.method` whether 'post' or 'get' etc., always lower case.\r\n - `m.what.url` is an object concerning the URL.\r\n - `m.what.cookies` is the cookie object from the request. To set your own cookie, just add a property, like `m.what.cookies.name = 'value'`. Or if you want to add options, do `m.what.cookies.name = {value: 'value', httpOnly: true, 'Max-Age': 99999}` instead.\r\n - `m.what.form` if a form happened to be submitted, this is it.\r\n - `m.what.files` if files were uploaded, this is where you deal with them.\r\n - `m.what.body` assign anything to this, and it will become the body of the response.\r\n - `m.what.type` allows you to set the Content-Type.\r\n - `m.what.encoding` to set the Content-Encoding.\r\n - `m.what.cache` use `0` for forcing no cache, or manually provide a cache control value.\r\n - `m.what.status` in case you need to set an explicit status code.\r\n - `m.what.redirect` to redirect to another URL.\r\n- `invincible` a boolean as to whether you want this module to respawn server side, in case it crashes. *`false`*\r\n\r\nExample:\r\n>scroll up to see the example in the HTTP intercept section.\r\n\r\n### Messages ###\r\n>scroll up to see Messages section.\r\n\r\n## Random Ramblings... ##\r\nThis is just tossing up a quick getting started guide, but it obviously is pretty vague.\r\nSo I'll just explain as much as I can really quickly in a garbled mess.\r\nProgramming is just 9 primitives - booleans, numbers, strings, texts, arrays, objects combined with loops, functions, and if statements.\r\nGiven these constructs, you then have and do 3 basic things - data, manipulation, and communication.\r\nThe Theory library provides a solid foundation for this, an abstraction layer for modular Javascript regardless of server, client, or IE6.\r\nCoalesce creates the communication layer between all these modules, whether server to server, client to client, or server to client and vice versa,\r\nfor all protocols - TCP, HTTP, Websocket, or AJAX, all with proper dependency, routing, and event pub/sub.\r\nThis means when you write beautiful modules for your app, Coalesce automatically becomes a distributed scalable system because your files are physically separated.\r\n\r\n## Future ##\r\nObviously this is still under development, and my todo list is huge. Immediately, there needs to be configuration options for adding message queues (Redis, ZeroMQ, etc.), swapping websocket libraries (SockJS, Socket.IO, ws, etc.), and cookie storage, and so on - these are all things that should \"plug-in\" to replace the sensible defaults. Tests are critical to add. Further out, it is intended to be cross-machine, not just cross-processes, the setup and config for that should be easy-peasy. Perhaps not within the scope of Coalesce core, but to facilitate with cross-machine fusing, it would make sense if scaling features existed to detect disk/cpu/ram overload and then auto-spawn new machines that then linked up. Lots of devops there!\r\n\r\nHere is to the future, help me create it! In the meanwhile, please experiment and play with it, and join me!\r\n\r\n*Note:* If you run into any problems or if anything is confusing or not easy please let me know. I'll help you and then make sure to clarify and update things. Thanks!\r\n\r\nCrafted with love by Mark Nadal, whom is not responsible for any liabilities from the use of this code.\r\n", "readmeFilename": "README.md", - "_id": "coalesce@0.1.9-bu", - "_from": "coalesce@0.1.9-bu" + "_id": "coalesce@0.1.9-bv", + "dist": { + "shasum": "2375bc62667c27f21b2ba8588e5acecfca6f687a" + }, + "_from": "coalesce@0.1.9-bv", + "_resolved": "https://registry.npmjs.org/coalesce/-/coalesce-0.1.9-bv.tgz" } diff --git a/npm-shrinkwrap.json b/npm-shrinkwrap.json index 2b6a8566..787f664c 100644 --- a/npm-shrinkwrap.json +++ b/npm-shrinkwrap.json @@ -29,62 +29,75 @@ } }, "coalesce": { - "version": "0.1.9-bu", - "from": "coalesce@0.1.9-bu", + "version": "0.1.9-bv", + "from": "coalesce@0.1.9-bv", + "resolved": "https://registry.npmjs.org/coalesce/-/coalesce-0.1.9-bv.tgz", "dependencies": { "node-static": { "version": "0.7.1", "from": "node-static@0.7.1", + "resolved": "https://registry.npmjs.org/node-static/-/node-static-0.7.1.tgz", "dependencies": { "optimist": { "version": "0.6.1", "from": "optimist@>=0.3.4", + "resolved": "https://registry.npmjs.org/optimist/-/optimist-0.6.1.tgz", "dependencies": { "wordwrap": { "version": "0.0.2", - "from": "wordwrap@~0.0.2" + "from": "wordwrap@~0.0.2", + "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-0.0.2.tgz" }, "minimist": { "version": "0.0.8", - "from": "minimist@~0.0.1" + "from": "minimist@~0.0.1", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz" } } }, "colors": { "version": "0.6.2", - "from": "colors@>=0.6.0" + "from": "colors@>=0.6.0", + "resolved": "https://registry.npmjs.org/colors/-/colors-0.6.2.tgz" } } }, "formidable": { "version": "1.0.11", - "from": "formidable@1.0.11" + "from": "formidable@1.0.11", + "resolved": "https://registry.npmjs.org/formidable/-/formidable-1.0.11.tgz" }, "sockjs-client": { "version": "0.1.3", "from": "sockjs-client@~>0.1.3", + "resolved": "https://registry.npmjs.org/sockjs-client/-/sockjs-client-0.1.3.tgz", "dependencies": { "node-uuid": { "version": "1.3.3", - "from": "node-uuid@1.3.3" + "from": "node-uuid@1.3.3", + "resolved": "https://registry.npmjs.org/node-uuid/-/node-uuid-1.3.3.tgz" } } }, "sockjs": { "version": "0.3.8", "from": "sockjs@~>0.3.1", + "resolved": "https://registry.npmjs.org/sockjs/-/sockjs-0.3.8.tgz", "dependencies": { "node-uuid": { "version": "1.3.3", - "from": "node-uuid@1.3.3" + "from": "node-uuid@1.3.3", + "resolved": "https://registry.npmjs.org/node-uuid/-/node-uuid-1.3.3.tgz" }, "faye-websocket": { "version": "0.7.0", "from": "faye-websocket@0.7.0", + "resolved": "https://registry.npmjs.org/faye-websocket/-/faye-websocket-0.7.0.tgz", "dependencies": { "websocket-driver": { "version": "0.3.2", - "from": "websocket-driver@>=0.3.0" + "from": "websocket-driver@>=0.3.0", + "resolved": "https://registry.npmjs.org/websocket-driver/-/websocket-driver-0.3.2.tgz" } } } diff --git a/package.json b/package.json index 606bc9d6..b0e4171a 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ , "dependencies": { "mime": "~>1.2.11", "theory": "~>0.2.6", - "coalesce": "~>0.1.9-bu", + "coalesce": "~>0.1.9-bv", "aws-sdk": "~>2.0.0", "fakeredis": "~>0.1.3", "redis": "~>0.10.1",