From: Jérôme Benoit Date: Sat, 12 Aug 2023 23:18:47 +0000 (+0200) Subject: refactor: cleanup examples X-Git-Tag: v2.6.25~11 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=abdb851534195a6ec554bbb2c38501044d27f6b7;p=poolifier.git refactor: cleanup examples Signed-off-by: Jérôme Benoit --- diff --git a/examples/typescript/http-server-pool/fastify-cluster/src/worker.ts b/examples/typescript/http-server-pool/fastify-cluster/src/worker.ts index 28658797..f679b4a6 100644 --- a/examples/typescript/http-server-pool/fastify-cluster/src/worker.ts +++ b/examples/typescript/http-server-pool/fastify-cluster/src/worker.ts @@ -13,6 +13,7 @@ const factorial: (n: number) => number = n => { const startFastify = async ( workerData?: WorkerData ): Promise => { + const { port } = workerData as WorkerData const fastify = Fastify({ logger: true }) @@ -28,7 +29,7 @@ const startFastify = async ( return { number: factorial(number) } }) - await fastify.listen({ port: workerData?.port }) + await fastify.listen({ port }) return { status: true, port: (fastify.server.address() as AddressInfo).port diff --git a/examples/typescript/websocket-server-pool/ws-cluster/src/worker.ts b/examples/typescript/websocket-server-pool/ws-cluster/src/worker.ts index e2751f72..f4fc3b7f 100644 --- a/examples/typescript/websocket-server-pool/ws-cluster/src/worker.ts +++ b/examples/typescript/websocket-server-pool/ws-cluster/src/worker.ts @@ -16,10 +16,11 @@ const factorial: (n: number) => number = n => { } const startWebSocketServer = (workerData?: WorkerData): WorkerResponse => { - const wss = new WebSocketServer({ port: workerData?.port }, () => { + const { port } = workerData as WorkerData + const wss = new WebSocketServer({ port }, () => { console.info( `⚡️[ws server]: WebSocket server is started on worker at ws://localhost:${ - workerData?.port as number + port }/` ) })