Link node.js / Express / Connect / Socket.io

I'm confused. The main question I have is when to use pure node.js, when should I use the / MVC framework, such as "express" or "connect".

I know that express simply adds a ton of functionality to connect, but what is it really useful for? Suppose I want all my HTTP files to do against the Apache server and do only partial things using node.js (e.g. WebSocket, CouchDB connections, etc.).

Does it make sense to use "express" or "connect" in this scenario for any reason?

As far as I know, Socket.IO also processes HTTP requests as a backup, so that would be enough to use Socket.IO for these needs?

What else is a big advantage with Express / Connect?

+3
source share
2 answers

Express (or Connect) is an application platform for HTTP web applications. This is the entry point to your application. It provides some very general functions, such as:

  • HTTP server
  • URL routing
  • Args request
  • Session

It also allows you to easily use other functional functions (they are called middleware), such as authentication processing, templating.

pub/sub- SocketIO - API, Socket.io( S.io):

var io = require('socket.io').listen(80);

io.sockets.on('connection', function (socket) {
    socket.emit('news', { hello: 'world' });
    socket.on('my other event', function (data) {
        console.log(data);
    });
});

Socket.io , API, (?) Express (. How )

+5

, Expressjs Jade, . - , , , , . , mixins, , .. html . , expressjs , javascript, stylesheets directory... , html- - . , http- .

0

All Articles