Optionalpath: string | string[]
Path(s) of the WebSocket request
Method decorator
contracts/common.md#principled-implementation The decorator records the route paths as metadata on the method, with an empty list for no path, and the adapter reads that metadata to build the route table.
contracts/common.md#clear-and-simple-design One decorator function that writes one metadata object.
contracts/common.md#prohibited-implementation-shortcuts It uses the reflect metadata API and does not touch the server.
WebSocket route decorator.
@WebSocketRoute()is a route decorator function for WebSocket routes. If you want to define a WebSocket route with this@WebSocketRoutedecorator, please don't forget to call the WebSocketAdaptor.upgrade function to the INestApplication instance.Also,
WebSocketRouteis a module containing parameter decorator functions of below for the@WebSocketRoutedecorated method, at the same time. Note that, every parameters must be decorated by one of the parameter decorators in theWebSocketRoutemodule. One thing more important is, WebSocketRoute.Acceptor decorated parameter must be defined in the method. If not, it would be both compilation/runtime error.For reference, key difference between
@WebSocketGateway()of NestJS and@WebSocketRoute()of Nestia is,@WebSocketRoute()can make multiple WebSocket routes by configuring paths, besides@WebSocketGateway()can't do it.Furthermore, if you build SDK (Software Development Kit) library through
@nestia/sdk, you can make safe WebSocket client taking advantages of TypeScript type hints and checks.