Summary
In this chapter you learned how to set up the server side, in order to use the:
socket.io
library provided by the Nest.jsIoAdapter
ws
library with a custom adapter
You also set up a gateway in order to handle the events sent by the client side.
You’ve seen how to set up the client side to use the socket.io-client
or WebSocket
client to connect the socket to the server. This was done on the same port as the HTTP server, and you learned how to send and catch the data returned by the server or the exception in case of an error.
And finally, you learned how to set up the authentication using middleware in order to check the socket token provided and identify if the user is authenticated or not to be able to access the handler in the cases of an IoAdapter
or a custom adapter.
The next chapter will cover microservices with Nest.js.