build(deps-dev): apply updates
[poolifier.git] / examples / typescript / http-server-pool / express-worker_threads / src / main.ts
index 970cf4d0d52f9f8bd78f47d19e5b89d4ba61f047..615143646507d8e2f33922426384a19e8e5e906c 100644 (file)
@@ -1,4 +1,7 @@
+import { exit } from 'node:process'
+
 import express, { type Express, type Request, type Response } from 'express'
+
 import { requestHandlerPool } from './pool.js'
 
 /**
@@ -21,7 +24,7 @@ expressApp.use(express.json())
 expressApp.all('/api/echo', (req: Request, res: Response) => {
   requestHandlerPool
     .execute({ body: req.body }, 'echo')
-    .then((response) => {
+    .then(response => {
       return res.send(response.body).end()
     })
     .catch(emptyFunction)
@@ -30,8 +33,8 @@ expressApp.all('/api/echo', (req: Request, res: Response) => {
 expressApp.get('/api/factorial/:number', (req: Request, res: Response) => {
   const { number } = req.params
   requestHandlerPool
-    .execute({ body: { number: parseInt(number) } }, 'factorial')
-    .then((response) => {
+    .execute({ body: { number: Number.parseInt(number) } }, 'factorial')
+    .then(response => {
       return res.send(response.body).end()
     })
     .catch(emptyFunction)
@@ -40,10 +43,10 @@ expressApp.get('/api/factorial/:number', (req: Request, res: Response) => {
 try {
   expressApp.listen(port, () => {
     console.info(
-      `⚡️[express server]: Express server is started at http://localhost:${port}/`
+      `⚡️[express server]: Express server is started at http://localhost:${port.toString()}/`
     )
   })
 } catch (err) {
   console.error(err)
-  process.exit(1)
+  exit(1)
 }