X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=examples%2Ftypescript%2Fhttp-server-pool%2Ffastify-hybrid%2Fsrc%2Ffastify-worker.ts;h=8e4713cfae2df7e3a158c6191a3ec57fc3d8060f;hb=b5be0ef35f36ab0cac675bec672df33fb88ae863;hp=e21eb58c01294014fd9557f067c6544bcfcca18a;hpb=85d2a65ad4435211edf06c035f87425594044bd2;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 e21eb58c..8e4713cf 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,8 +1,10 @@ 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, @@ -13,7 +15,7 @@ ClusterWorkerResponse private static readonly startFastify = async ( workerData?: ClusterWorkerData ): Promise => { - const { port, ...fastifyPoolifierOptions } = workerData as ClusterWorkerData + const { port, ...fastifyPoolifierOptions } = workerData! FastifyWorker.fastify = Fastify({ logger: true @@ -24,7 +26,7 @@ ClusterWorkerResponse fastifyPoolifierOptions ) - FastifyWorker.fastify.all('/api/echo', async (request) => { + FastifyWorker.fastify.all('/api/echo', async request => { return ( await FastifyWorker.fastify.execute({ data: request.body }, 'echo') ).data @@ -32,7 +34,7 @@ ClusterWorkerResponse FastifyWorker.fastify.get<{ Params: { number: number } - }>('/api/factorial/:number', async (request) => { + }>('/api/factorial/:number', async request => { const { number } = request.params return ( await FastifyWorker.fastify.execute({ data: { number } }, 'factorial')