From abdb851534195a6ec554bbb2c38501044d27f6b7 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Sun, 13 Aug 2023 01:18:47 +0200 Subject: [PATCH] refactor: cleanup examples MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- .../http-server-pool/fastify-cluster/src/worker.ts | 3 ++- .../websocket-server-pool/ws-cluster/src/worker.ts | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) 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 }/` ) }) -- 2.34.1