ws.on('error', console.error)
ws.on('message', (message: RawData) => {
const { type, data } = JSON.parse(
- // eslint-disable-next-line @typescript-eslint/no-base-to-string
message.toString()
) as MessagePayload<DataPayload>
switch (type) {
ws.send(
JSON.stringify({
type: MessageType.echo,
- data: response.data
+ data: response.data,
})
)
return undefined
JSON.stringify(
{
type: MessageType.factorial,
- data: response.data
+ data: response.data,
},
(_, v) => (typeof v === 'bigint' ? v.toString() : v)
)