From d68ce4c613425da9055e0d1e7cfc82bd4385328f Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Sat, 12 Aug 2023 00:23:34 +0200 Subject: [PATCH] refactor: cleanup promise usage in fastify example MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- .eslintrc.js | 1 + .../typescript/http-server-pool/fastify/src/main.ts | 10 ++++------ 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 44b9c5d2..3a35e685 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -37,6 +37,7 @@ module.exports = defineConfig({ 'warn', { skipWords: [ + 'axios', 'benoit', 'benny', 'browserslist', diff --git a/examples/typescript/http-server-pool/fastify/src/main.ts b/examples/typescript/http-server-pool/fastify/src/main.ts index c17de65b..8a617c6f 100644 --- a/examples/typescript/http-server-pool/fastify/src/main.ts +++ b/examples/typescript/http-server-pool/fastify/src/main.ts @@ -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 { -- 2.34.1