Merge dependabot/npm_and_yarn/examples/typescript/http-server-pool/express-cluster...
[poolifier.git] / examples / typescript / http-server-pool / fastify-hybrid / src / fastify-worker.ts
index 9c2cb3c52d57e95f5452e624a0bde9ffd4e1a4ed..0566ee014dd75e8520f93ee154f304018707f70d 100644 (file)
@@ -13,13 +13,16 @@ ClusterWorkerResponse
   private static readonly startFastify = async (
     workerData?: ClusterWorkerData
   ): Promise<ClusterWorkerResponse> => {
-    const { port } = workerData as ClusterWorkerData
+    const { port, ...fastifyPoolifierOptions } = workerData as ClusterWorkerData
 
     FastifyWorker.fastify = Fastify({
       logger: true
     })
 
-    await FastifyWorker.fastify.register(fastifyPoolifier, workerData)
+    await FastifyWorker.fastify.register(
+      fastifyPoolifier,
+      fastifyPoolifierOptions
+    )
 
     FastifyWorker.fastify.all('/api/echo', async (request) => {
       return (
@@ -39,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
     }
   }