refactor: cleanup promise usage in fastify example
authorJérôme Benoit <jerome.benoit@sap.com>
Fri, 11 Aug 2023 22:23:34 +0000 (00:23 +0200)
committerJérôme Benoit <jerome.benoit@sap.com>
Fri, 11 Aug 2023 22:23:34 +0000 (00:23 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
.eslintrc.js
examples/typescript/http-server-pool/fastify/src/main.ts

index 44b9c5d292ec749151288997c2f578797c78564a..3a35e685c40aa1c39f042d9e326c48be5c0fc0d5 100644 (file)
@@ -37,6 +37,7 @@ module.exports = defineConfig({
       'warn',
       {
         skipWords: [
+          'axios',
           'benoit',
           'benny',
           'browserslist',
index c17de65b9628e3b818030ecb7a2259195c7da6db..8a617c6fa4ca3ae25dd5f326a4ae5e557c7b5c84 100644 (file)
@@ -28,17 +28,15 @@ await fastify.register(fastifyPoolifier, {
   }
 })
 
-fastify.all('/api/echo', async (request, reply) => {
-  await reply.send((await fastify.execute({ body: request.body }, 'echo')).body)
+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, reply) => {
+}>('/api/factorial/:number', async request => {
   const { number } = request.params
-  await reply.send(
-    (await fastify.execute({ body: { number } }, 'factorial')).body
-  )
+  return (await fastify.execute({ body: { number } }, 'factorial')).body
 })
 
 try {