Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
const startFastify = async (
workerData?: WorkerData
): Promise<WorkerResponse> => {
+ const { port } = workerData as WorkerData
const fastify = Fastify({
logger: true
})
return { number: factorial(number) }
})
- await fastify.listen({ port: workerData?.port })
+ await fastify.listen({ port })
return {
status: true,
port: (fastify.server.address() as AddressInfo).port
}
const startWebSocketServer = (workerData?: WorkerData): WorkerResponse => {
- const wss = new WebSocketServer({ port: workerData?.port }, () => {
+ const { port } = workerData as WorkerData
+ const wss = new WebSocketServer({ port }, () => {
console.info(
`⚡️[ws server]: WebSocket server is started on worker at ws://localhost:${
- workerData?.port as number
+ port
}/`
)
})