import type { Server } from 'node:http'
import type { AddressInfo } from 'node:net'
+
+import express, { type Express, type Request, type Response } from 'express'
import {
+ availableParallelism,
ClusterWorker,
- DynamicThreadPool,
- availableParallelism
+ DynamicThreadPool
} from 'poolifier'
-import express, { type Express, type Request, type Response } from 'express'
+
import {
type ClusterWorkerData,
type ClusterWorkerResponse,
.catch(emptyFunction)
})
+ let listenerPort: number | undefined
ExpressWorker.server = application.listen(port, () => {
+ listenerPort = (ExpressWorker.server.address() as AddressInfo).port
console.info(
- // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
- `⚡️[express server]: Express server is started in cluster worker at http://localhost:${port}/`
+ `⚡️[express server]: Express server is started in cluster worker at http://localhost:${listenerPort}/`
)
})
return {
status: true,
- port: (ExpressWorker.server.address() as AddressInfo)?.port ?? port
+ port: listenerPort ?? port
}
}