Single-page applications, http or websockets, for connection / express?

This is a single page web application question and my question is in bold.

WARNING: I am unlikely to be an expert on this subject and please correct me if I am mistaken regarding my understanding of how HTTP and WebSockets work.

My understanding of how the HTTP restful API works is that they are stateless. We use tools like connect.session () to embed some state types in our applications at a higher level. Since each individual request is new, we need a way to re-identify ourselves on the server, so we create a unique token that is sent back and forth.

Connecting session middleware solves this for us pretty cool. Drop it on your middleware stack and you have awesome-sauce sessions attached to every request for your entire application. Sprinkle in some kind of handshake, and you can transfer this session information to socket.io quite easily, even more surprisingly. Use RedisStore to save information to separate it from your connect / express application, and this is even more amazing. Here we are talking about a double rainbow.

So now you can theoretically have a one-page application that is independent of connectivity / sessions, because you don't need more than 1 session (initial handshake) when it comes to working with websites. socket.io already gives you easy access to this sessionId, the problem is resolved.


:

  • .
  • , .
  • .
  • "OK!" "NOPE!".
  • , connect.session() .

:

  • .
  • .
  • .
  • .
  • "!". "NOPE!" .
  • , -, , ?

, ? , :

  • logger dev
  • Favicon
  • bodyparser
  • ( , connect/express, , anyauth)

, , . - , , , . , , , -.

-, http. index.html, http, websocket ? socket.io HTTP-, HTTP, , - ?

- ? ? , / - , html ?

+5
2
+1

, , ( socket.io), -, .

"", . - node.js , , socket.io.

0

All Articles