0.1.4 • Published 8 years ago
web6 v0.1.4
web6
Shim the "web" framework's socketHandler
function for node.js
v6.x
In theory, you can just add the digit 6
to your require('web')
and it
should work. If you know of any tests for "web" interface compatibility,
please let me know
so I can improve this shim to accomodate them.
Usage
from test/hello-server.js:
var web = require('web6'), makeApp = require('./hello-app.js'),
app, appOpts = { greeting: 'Hello World!' },
tcpServer = net.createServer(), tcpConnectionHandler;
if (cfg.announceExtras) {
appOpts.greeting += ('\n\nWere you looking for one of these extras?\n' +
cfg.announceExtras);
}
app = makeApp(appOpts); // function (request, respond) { … }
if (cfg.addExtras) { app = cfg.addExtras(app); }
tcpConnectionHandler = web.socketHandler(app, { debug: true });
tcpServer.on('connection', tcpConnectionHandler);
tcpServer.on('listening', announceServerUrl(tcpServer));
tcpServer.listen(cfg.port, cfg.iface);
More examples:
License
ISC