build(deps-dev): apply updates
[poolifier.git] / examples / typescript / http-server-pool / fastify-worker_threads / src / main.ts
index f1271c6e13566ae1b80067a178579b9a3190cb6e..b9aba792c05a8e2459eecfac5a93457a4185da9a 100644 (file)
@@ -1,6 +1,9 @@
 import { dirname, extname, join } from 'node:path'
+import { exit } from 'node:process'
 import { fileURLToPath } from 'node:url'
+
 import Fastify from 'fastify'
+
 import { fastifyPoolifier } from './fastify-poolifier.js'
 
 /**
@@ -9,11 +12,12 @@ import { fastifyPoolifier } from './fastify-poolifier.js'
 
 const port = 8080
 const fastify = Fastify({
-  logger: true
+  logger: true,
 })
 
 const workerFile = join(
   dirname(fileURLToPath(import.meta.url)),
+  // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
   `worker${extname(fileURLToPath(import.meta.url))}`
 )
 
@@ -21,20 +25,20 @@ await fastify.register(fastifyPoolifier, {
   workerFile,
   enableTasksQueue: true,
   tasksQueueOptions: {
-    concurrency: 8
+    concurrency: 8,
   },
   errorHandler: (e: Error) => {
     fastify.log.error('Thread worker error:', e)
-  }
+  },
 })
 
-fastify.all('/api/echo', async (request) => {
+fastify.all('/api/echo', async request => {
   return (await fastify.execute({ body: request.body }, 'echo')).body
 })
 
 fastify.get<{
   Params: { number: number }
-}>('/api/factorial/:number', async (request) => {
+}>('/api/factorial/:number', async request => {
   const { number } = request.params
   return (await fastify.execute({ body: { number } }, 'factorial')).body
 })
@@ -43,5 +47,5 @@ try {
   await fastify.listen({ port })
 } catch (err) {
   fastify.log.error(err)
-  process.exit(1)
+  exit(1)
 }