-
Book Overview & Buying
-
Table Of Contents
Nest.js: A Progressive Node.js Framework
By :
As mentioned in the beginning of this chapter, Nest.js comes with it own adapter, which uses socket.io. But the framework needs to be flexible and it can be used with any third party library. In order to provide a way to implement another library, you have the possibility to create your own adapter.
The adapter has to implement the WebSocketAdapter interface in order to implement the following methods. For example, we will use ws as a socket library in our new adapter. To use it, we will have to inject the app
into the constructor as follows:
exportclassWsAdapterimplementsWebSocketAdapter{constructor(privateapp:INestApplication){}/* ... */}
By doing this, we can get the httpServer in order to use it with the ws.
After that, we have to implement the create method in order to create the socket server.
exportclassWsAdapterimplementsWebSocketAdapter{/* ... */create(port:number){returnnewWebSocket.Server({server:this...
Change the font size
Change margin width
Change background colour