mirror of
https://github.com/Mintplex-Labs/express-ws.git
synced 2026-07-19 22:33:55 -04:00
27 lines
486 B
JavaScript
Executable File
27 lines
486 B
JavaScript
Executable File
#!/usr/bin/env node
|
|
|
|
var express = require('express');
|
|
var expressWs = require('..')
|
|
|
|
var app = expressWs(express());
|
|
|
|
app.use(function (req, res, next) {
|
|
console.log('middleware');
|
|
req.testing = 'testing';
|
|
return next();
|
|
});
|
|
|
|
app.get('/', function(req, res, next){
|
|
console.log('get route', req.testing);
|
|
res.end();
|
|
});
|
|
|
|
app.ws('/', function(ws, req) {
|
|
ws.on('message', function(msg) {
|
|
console.log(msg);
|
|
});
|
|
console.log('socket', req.testing);
|
|
});
|
|
|
|
app.listen(3000)
|