
Security News
Feross on the 10 Minutes or Less Podcast: Nobody Reads the Code
Socket CEO Feross Aboukhadijeh joins 10 Minutes or Less, a podcast by Ali Rohde, to discuss the recent surge in open source supply chain attacks.
Nexy is a middleware based TCP framework for Node. Inspired by Sencha's connect. Written for Multiplayer Games.
Warning: This is a work in progress. Please do not use yet.
Installation
npm install nexy
Simple Chat Server
var Nexy = require('nexy'),
app = Nexy.createServer();
// see details about message keys below
app.set('msg:key', 'type');
// connection pool
app.set('clients', []);
// param middleware here (see below)
app.route('join', function(req, res) {
var nick = req.params.nick;
// add joining client to pool
app.get('clients').push({ nickname: nick, socket: res });
// tell all other connected clients that `nick` has joined
app.get('clients').forEach(function(client, i, array) {
client.socket.send({ type: 'joined', nick: nick });
});
});
app.listen(2101);
Simple Chat Client
var Nexy = require('nexy'),
app = Nexy.createClient();
// see details about message keys below
app.set('msg:key', 'type');
// param middleware here (see below)
// first message to initialize communication
app.connect(2101, function(res) {
res.write(JSON.stringify({ type: 'join', nick: 'iAmMaj' }));
});
app.route('joined', function(req, res) {
console.log(req.params.nick + ' has joined the chatroom');
});
Simple Middleware
Add this to the client and server so you can use
req.params.*.
// param middleware
app.use(function(req, res, next) {
req.params = req;
next();
});
###Message Key
Unlike HTTP servers, TCP server doesn't know where to route your request unless you specify what type of data you are sending on the message itself.
By default Nexy will expect the following payload:
{ method: 'roomchat', nick: 'iAmMaj', message: 'secret' }
If you set the msg:key to:
app.set('msg:key', 'type');
Then Nexy will expect the following payload:
{ type: 'roomchat', nick: 'iAmMaj', message: 'secret' }
If you set the msg:key to:
app.set('msg:key', 'MyCustomType');
Then Nexy will expect the following payload:
{ MyCustomType: 'roomchat', nick: 'iAmMaj', message: 'secret' }
Note: In binary this is the identity.
JSON is a very heavy format and is not efficient enough, so we can use binary structures instead.
Format
< size > < id > < content >
----
size : uint16
identity : uint16
content : mix
order : LittleEndian
----
< Buffer 05 00 01 00 03 >
size : 5
identity : 1
content : 3
###Example
Binary Chat Server
var Nexy = require('nexy'),
app = Nexy.createServer();
// see details about message keys below
app.set('msg:key', 'type');
// connection pool
app.set('clients', []);
// param middleware here (see below)
app.route('join', function(req, res) {
var nick = req.params.nick;
// add joining client to pool
app.get('clients').push({ nickname: nick, socket: res });
// tell all other connected clients that `nick` has joined
app.get('clients').forEach(function(client, i, array) {
client.socket.send({ type: 'joined', nick: nick });
client.socket.write('\x05\x00\x01\x00\x03');
});
});
app.listen(2101);
Binary Chat Client
var Nexy = require('nexy'),
app = Nexy.createClient();
// see details about message keys below
app.set('msg:key', 'type');
// param middleware here (see below)
// first message to initialize communication
app.connect(2101, function(res) {
res.write(JSON.stringify({ type: 'join', nick: 'iAmMaj' }));
res.write('\x05\x00\x01\x00\x03');
});
app.route('joined', function(req, res) {
console.log(req.params.nick + ' has joined the chatroom');
});
Param Parser Middleware
// param middleware
app.use(function(req, res, next) {
req.params = req;
next();
});
FAQs
High performance game network framework
The npm package nexy receives a total of 5 weekly downloads. As such, nexy popularity was classified as not popular.
We found that nexy demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Socket CEO Feross Aboukhadijeh joins 10 Minutes or Less, a podcast by Ali Rohde, to discuss the recent surge in open source supply chain attacks.

Research
/Security News
Campaign of 108 extensions harvests identities, steals sessions, and adds backdoors to browsers, all tied to the same C2 infrastructure.

Security News
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.