UNPKG

@nestjs/websockets

Version:

Nest - modern, fast, powerful node.js web framework (@websockets)

13 lines (12 loc) 567 B
import { GATEWAY_METADATA, GATEWAY_OPTIONS, PORT_METADATA, } from '../constants.js'; export function WebSocketGateway(portOrOptions, options) { const isPortInt = Number.isInteger(portOrOptions); // eslint-disable-next-line prefer-const let [port, opt] = isPortInt ? [portOrOptions, options] : [0, portOrOptions]; opt = opt || {}; return (target) => { Reflect.defineMetadata(GATEWAY_METADATA, true, target); Reflect.defineMetadata(PORT_METADATA, port, target); Reflect.defineMetadata(GATEWAY_OPTIONS, opt, target); }; }