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,
private static readonly startFastify = async (
workerData?: ClusterWorkerData
): Promise<ClusterWorkerResponse> => {
- const { port, ...fastifyPoolifierOptions } = workerData as ClusterWorkerData
+ const { port, ...fastifyPoolifierOptions } = workerData!
FastifyWorker.fastify = Fastify({
logger: true
await FastifyWorker.fastify.listen({ port })
return {
status: true,
- port: (FastifyWorker.fastify.server.address() as AddressInfo)?.port
+ port: (FastifyWorker.fastify.server.address() as AddressInfo).port
}
}