build(deps): bump poolifier
[poolifier.git] / examples / typescript / websocket-server-pool / ws-worker_threads / src / main.ts
index c8478366a77dc18faa0219cbe809935c1ab5669a..7a162499d8f91417246fe1b94289b62083ec584d 100644 (file)
@@ -1,6 +1,7 @@
 import { type RawData, WebSocketServer } from 'ws'
-import { type DataPayload, type MessagePayload, MessageType } from './types.js'
+
 import { requestHandlerPool } from './pool.js'
+import { type DataPayload, type MessagePayload, MessageType } from './types.js'
 
 const port = 8080
 const wss = new WebSocketServer({ port }, () => {
@@ -31,7 +32,7 @@ wss.on('connection', ws => {
                 data: response.data
               })
             )
-            return null
+            return undefined
           })
           .catch(emptyFunction)
         break
@@ -40,12 +41,15 @@ wss.on('connection', ws => {
           .execute({ data }, 'factorial')
           .then(response => {
             ws.send(
-              JSON.stringify({
-                type: MessageType.factorial,
-                data: response.data
-              })
+              JSON.stringify(
+                {
+                  type: MessageType.factorial,
+                  data: response.data
+                },
+                (_, v) => (typeof v === 'bigint' ? v.toString() : v)
+              )
             )
-            return null
+            return undefined
           })
           .catch(emptyFunction)
         break