From 1fa0cdf5c1471f14c09c7a33131f14f13215996b Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Wed, 16 Aug 2023 17:38:54 +0200 Subject: [PATCH] fix: fix possible null property exception in 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/express-hybrid/src/express-worker.ts | 6 ++---- .../http-server-pool/fastify-cluster/src/worker.ts | 2 +- .../http-server-pool/fastify-hybrid/src/fastify-worker.ts | 2 +- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/examples/typescript/http-server-pool/express-hybrid/src/express-worker.ts b/examples/typescript/http-server-pool/express-hybrid/src/express-worker.ts index 56fad6d1..901c2072 100644 --- a/examples/typescript/http-server-pool/express-hybrid/src/express-worker.ts +++ b/examples/typescript/http-server-pool/express-hybrid/src/express-worker.ts @@ -71,14 +71,12 @@ ClusterWorkerResponse ExpressWorker.server = application.listen(port, () => { console.info( // eslint-disable-next-line @typescript-eslint/restrict-template-expressions - `⚡️[express server]: Express server is started in cluster worker at http://localhost:${workerData?.port}/` + `⚡️[express server]: Express server is started in cluster worker at http://localhost:${port}/` ) }) return { status: true, - port: - (ExpressWorker.server.address() as AddressInfo)?.port ?? - workerData?.port + port: (ExpressWorker.server.address() as AddressInfo)?.port ?? port } } 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 d70b76dd..283a223e 100644 --- a/examples/typescript/http-server-pool/fastify-cluster/src/worker.ts +++ b/examples/typescript/http-server-pool/fastify-cluster/src/worker.ts @@ -36,7 +36,7 @@ class FastifyWorker extends ClusterWorker { await FastifyWorker.fastify.listen({ port }) return { status: true, - port: (FastifyWorker.fastify.server.address() as AddressInfo).port + port: (FastifyWorker.fastify.server.address() as AddressInfo)?.port } } diff --git a/examples/typescript/http-server-pool/fastify-hybrid/src/fastify-worker.ts b/examples/typescript/http-server-pool/fastify-hybrid/src/fastify-worker.ts index e21eb58c..0566ee01 100644 --- a/examples/typescript/http-server-pool/fastify-hybrid/src/fastify-worker.ts +++ b/examples/typescript/http-server-pool/fastify-hybrid/src/fastify-worker.ts @@ -42,7 +42,7 @@ ClusterWorkerResponse await FastifyWorker.fastify.listen({ port }) return { status: true, - port: (FastifyWorker.fastify.server.address() as AddressInfo).port + port: (FastifyWorker.fastify.server.address() as AddressInfo)?.port } } -- 2.34.1