+import { exit } from 'node:process'
+
import express, { type Express, type Request, type Response } from 'express'
+
import { requestHandlerPool } from './pool.js'
/**
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)
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)
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)
}