I discover socket.io and chat exemple here : https://github.com/rauchg/chat-example/blob/master/index.js
They use directly require('express')
AND require('socket.io')
.
So what the
differences, the advantages, to use : require('express.io')
like here http://express-io.org/ ?
It's just to win one line? Seriously? or there is another layer with new tools?
I recently, today, looked at express.io and when i installed the node module npm reported:
Added 55 packages from 44 contributors and audited 2606 packages in 32.816s
Found 25 vulnerabilities (11 low, 5 moderate, 9 high)
run
npm audit fix
to fix them, ornpm audit
for detailsnpm audit fix fixed two of the low vulnerabilities.
When I removed express.io npm reported:
removed 57 packages and audited 2539 packages in 8.976s
found 0 vulnerabilities
So as much as I would like to use the really nice routing features, I don't feel this is appropriate for production until the dependencies are fixed.
I have been using express.io in my node app. I found that the principal advantage is that you can mix the normal express routes with socket routes.
Let me explain a real example:
In my app I have a nodejs REST API with an Angular clients. My clients need to show some real time notifications that were created by an administrator calling an express post request.
At the beginning I put a time interval in angular to consult all the notifications, running it every 5 seconds.
With a few clients it works perfect but when clients increased my server was overloaded. Each client was requesting notifications despite them not having new notifications. So I decided to start using socket.io to send real time notifications.
If my administrator saves a new notification, the server broadcasts the notification through the socket.
The problem here was that the administrator calls a normal POST request in express and I needed to broadcast using socket.io, so I integrate express.io and I can redirect normal express request to a socket.io method to do an emit.