build: make eslint configuration use strict type checking
[poolifier.git] / examples / typescript / http-server-pool / express-hybrid / src / express-worker.ts
index c6174a991d23c7ff18066f64486a1b2550de0fab..8cc041d4ee20c5f8e1fac45c96914019abcc2d9e 100644 (file)
@@ -1,5 +1,5 @@
-import type { Server } from 'http'
-import type { AddressInfo } from 'net'
+import type { Server } from 'node:http'
+import type { AddressInfo } from 'node:net'
 import {
   ClusterWorker,
   DynamicThreadPool,
@@ -32,7 +32,7 @@ ClusterWorkerResponse
     workerData?: ClusterWorkerData
   ): ClusterWorkerResponse => {
     const { port, workerFile, minWorkers, maxWorkers, ...poolOptions } =
-      workerData as ClusterWorkerData
+      workerData!
 
     ExpressWorker.requestHandlerPool = new DynamicThreadPool<
     ThreadWorkerData<DataPayload>,
@@ -52,7 +52,7 @@ ClusterWorkerResponse
     application.all('/api/echo', (req: Request, res: Response) => {
       ExpressWorker.requestHandlerPool
         .execute({ data: req.body }, 'echo')
-        .then((response) => {
+        .then(response => {
           return res.send(response.data).end()
         })
         .catch(emptyFunction)
@@ -62,7 +62,7 @@ ClusterWorkerResponse
       const { number } = req.params
       ExpressWorker.requestHandlerPool
         .execute({ data: { number: parseInt(number) } }, 'factorial')
-        .then((response) => {
+        .then(response => {
           return res.send(response.data).end()
         })
         .catch(emptyFunction)
@@ -70,13 +70,12 @@ ClusterWorkerResponse
 
     ExpressWorker.server = application.listen(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}/`
       )
     })
     return {
       status: true,
-      port: (ExpressWorker.server.address() as AddressInfo)?.port ?? port
+      port: (ExpressWorker.server.address() as AddressInfo).port
     }
   }