Use constant instead of magic number
This commit is contained in:
parent
e5b3a90fae
commit
f30dfe0cee
1 changed files with 3 additions and 2 deletions
|
@ -1,5 +1,6 @@
|
||||||
import Fastify, { type FastifyReply, type FastifyRequest, type HookHandlerDoneFunction } from 'fastify'
|
import Fastify, { type FastifyReply, type FastifyRequest, type HookHandlerDoneFunction } from 'fastify'
|
||||||
import { readFileSync } from 'fs'
|
import { readFileSync } from 'fs'
|
||||||
|
import { constants as HttpConstants } from 'http2'
|
||||||
import { isAuthenticated } from '../../security'
|
import { isAuthenticated } from '../../security'
|
||||||
import type { HttpAdapter, HttpResponse, HttpServer } from './api'
|
import type { HttpAdapter, HttpResponse, HttpServer } from './api'
|
||||||
import fastifyAuth from '@fastify/auth'
|
import fastifyAuth from '@fastify/auth'
|
||||||
|
@ -68,8 +69,8 @@ export const fastifyServe: HttpAdapter = async (server: HttpServer) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
fastify.addHook('onResponse', (request: FastifyRequest, reply: FastifyReply) => {
|
fastify.addHook('onResponse', (request: FastifyRequest, reply: FastifyReply) => {
|
||||||
if (reply.statusCode >= 400) {
|
if (reply.statusCode >= HttpConstants.HTTP_STATUS_BAD_REQUEST) {
|
||||||
server.log?.warn(formatCombinedLog(request, reply))
|
server.log?.error(formatCombinedLog(request, reply))
|
||||||
} else if (server.config.debug) {
|
} else if (server.config.debug) {
|
||||||
server.log?.debug(formatCombinedLog(request, reply))
|
server.log?.debug(formatCombinedLog(request, reply))
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue