X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=examples%2Ftypescript%2Fhttp-server-pool%2Ffastify-hybrid%2Fsrc%2Ffastify-worker.ts;h=4a697f3e255def59329478440f5f8d7ca205737e;hb=e69cc10a0b0e531f4bb7a33fc8728741d9a82533;hp=388730dcec9bda04a13315f4f0b5fb1814981266;hpb=a7263cc7976423d318bd3a82d1a60b2f39b6e2c5;p=poolifier.git 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 388730dc..4a697f3e 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 @@ -1,22 +1,25 @@ import type { AddressInfo } from 'node:net' -import { ClusterWorker } from 'poolifier' + import Fastify, { type FastifyInstance } from 'fastify' -import type { ClusterWorkerData, ClusterWorkerResponse } from './types.js' +import { ClusterWorker } from 'poolifier' + import { fastifyPoolifier } from './fastify-poolifier.js' +import type { ClusterWorkerData, ClusterWorkerResponse } from './types.js' class FastifyWorker extends ClusterWorker< -ClusterWorkerData, -ClusterWorkerResponse + ClusterWorkerData, + ClusterWorkerResponse > { private static fastify: FastifyInstance private static readonly startFastify = async ( workerData?: ClusterWorkerData ): Promise => { - const { port, ...fastifyPoolifierOptions } = workerData as ClusterWorkerData + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + const { port, ...fastifyPoolifierOptions } = workerData! FastifyWorker.fastify = Fastify({ - logger: true + logger: true, }) await FastifyWorker.fastify.register( @@ -42,7 +45,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, } } @@ -51,7 +54,7 @@ ClusterWorkerResponse killHandler: async () => { await FastifyWorker.fastify.pool.destroy() await FastifyWorker.fastify.close() - } + }, }) } }