From f30dfe0ceed5cce2296a0897af3a1ff713c72c4a Mon Sep 17 00:00:00 2001 From: Lars Strojny Date: Thu, 24 Nov 2022 20:18:48 +0100 Subject: [PATCH] Use constant instead of magic number --- src/adapters/http/fastify.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/adapters/http/fastify.ts b/src/adapters/http/fastify.ts index da9f093..114c0f7 100644 --- a/src/adapters/http/fastify.ts +++ b/src/adapters/http/fastify.ts @@ -1,5 +1,6 @@ import Fastify, { type FastifyReply, type FastifyRequest, type HookHandlerDoneFunction } from 'fastify' import { readFileSync } from 'fs' +import { constants as HttpConstants } from 'http2' import { isAuthenticated } from '../../security' import type { HttpAdapter, HttpResponse, HttpServer } from './api' import fastifyAuth from '@fastify/auth' @@ -68,8 +69,8 @@ export const fastifyServe: HttpAdapter = async (server: HttpServer) => { } fastify.addHook('onResponse', (request: FastifyRequest, reply: FastifyReply) => { - if (reply.statusCode >= 400) { - server.log?.warn(formatCombinedLog(request, reply)) + if (reply.statusCode >= HttpConstants.HTTP_STATUS_BAD_REQUEST) { + server.log?.error(formatCombinedLog(request, reply)) } else if (server.config.debug) { server.log?.debug(formatCombinedLog(request, reply)) }