Merge dependabot/npm_and_yarn/examples/typescript/http-server-pool/express-worker_thr...
[poolifier.git] / examples / typescript / http-server-pool / fastify-hybrid / src / fastify-worker.ts
index 7a09a1ce38666ea1a0ad45e056adb4a1f89f8034..9c2cb3c52d57e95f5452e624a0bde9ffd4e1a4ed 100644 (file)
@@ -14,6 +14,7 @@ ClusterWorkerResponse
     workerData?: ClusterWorkerData
   ): Promise<ClusterWorkerResponse> => {
     const { port } = workerData as ClusterWorkerData
+
     FastifyWorker.fastify = Fastify({
       logger: true
     })
@@ -22,8 +23,8 @@ ClusterWorkerResponse
 
     FastifyWorker.fastify.all('/api/echo', async (request) => {
       return (
-        await FastifyWorker.fastify.execute({ body: request.body }, 'echo')
-      ).body
+        await FastifyWorker.fastify.execute({ data: request.body }, 'echo')
+      ).data
     })
 
     FastifyWorker.fastify.get<{
@@ -31,8 +32,8 @@ ClusterWorkerResponse
     }>('/api/factorial/:number', async (request) => {
       const { number } = request.params
       return (
-        await FastifyWorker.fastify.execute({ body: { number } }, 'factorial')
-      ).body
+        await FastifyWorker.fastify.execute({ data: { number } }, 'factorial')
+      ).data
     })
 
     await FastifyWorker.fastify.listen({ port })
@@ -45,6 +46,7 @@ ClusterWorkerResponse
   public constructor () {
     super(FastifyWorker.startFastify, {
       killHandler: async () => {
+        await FastifyWorker.fastify.pool.destroy()
         await FastifyWorker.fastify.close()
       }
     })