@@ -3,7 +3,7 @@ import { Queue, ConnectionOptions } from "bullmq";
33import { Value } from "@sinclair/typebox/value" ;
44import { ServerWebSocket } from "bun" ;
55
6- import { WebSocketBehaviour } from "../../interfaces/websocket-behaviour " ;
6+ import { WebSocketBehaviour , BufferSource } from "../../interfaces" ;
77import { respond , send } from "../utils" ;
88import { info } from "../../utils/log" ;
99import { QueueSchema , QueueSchemaType } from "../commands" ;
@@ -20,7 +20,9 @@ export const openQueue = async (ws: ServerWebSocket<QueueWebSocketData>) => {
2020 info ( `Queue connected for queue ${ queueName } ` ) ;
2121
2222 ws . data . queue = new Queue ( queueName , { connection } ) ;
23- ws . data . mb = new MessageBroker < object > ( async ( msg : string | Buffer ) => send ( ws , msg ) ) ;
23+ ws . data . mb = new MessageBroker < object > ( async ( msg : string | BufferSource ) =>
24+ send ( ws , msg )
25+ ) ;
2426} ;
2527
2628export const QueueController : WebSocketBehaviour = {
@@ -40,14 +42,16 @@ export const QueueController: WebSocketBehaviour = {
4042 if ( firstError ) {
4143 // The errors are difficult to read, so we'll just send a generic one
4244 // until we can do something better.
43- respond ( ws , parsedMessage . id , { err : { message : `Invalid message ${ message } ` , stack : "" } } )
45+ respond ( ws , parsedMessage . id , {
46+ err : { message : `Invalid message ${ message } ` , stack : "" } ,
47+ } ) ;
4448 return ;
4549 }
4650
4751 const queue = ws . data . queue ;
48- const { fn, args } : { fn : string , args : any [ ] } = parsedMessage . data ;
52+ const { fn, args } : { fn : string ; args : any [ ] } = parsedMessage . data ;
4953 try {
50- const queueMethod = ( < any > queue ) [ fn ] as Function
54+ const queueMethod = ( < any > queue ) [ fn ] as Function ;
5155 const result = await queueMethod . apply ( queue , args ) ;
5256 respond ( ws , parsedMessage . id , { ok : result } ) ;
5357 } catch ( err ) {
@@ -64,9 +68,9 @@ export const QueueController: WebSocketBehaviour = {
6468
6569 close : async ( ws , code , message ) => {
6670 info (
67- `WebSocket closed for queue (${ ws . data . queueName } ) with code ${ code } ${ message ? `and message ${ Buffer . from (
68- message
69- ) . toString ( ) } ` : "" } `
71+ `WebSocket closed for queue (${ ws . data . queueName } ) with code ${ code } ${
72+ message ? `and message ${ Buffer . from ( message ) . toString ( ) } ` : ""
73+ } `
7074 ) ;
7175
7276 const queue = ws . data . queue ;
0 commit comments