mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-05-28 18:26:54 +00:00
fix(api): linting issues with fastify (#65278)
This commit is contained in:
committed by
GitHub
parent
3c5ef03e6f
commit
f908382e94
@@ -1,4 +1,4 @@
|
||||
import type { FastifyPluginCallback } from 'fastify';
|
||||
import type { FastifyError, FastifyPluginCallback } from 'fastify';
|
||||
import * as Sentry from '@sentry/node';
|
||||
import fp from 'fastify-plugin';
|
||||
|
||||
@@ -22,7 +22,7 @@ const errorHandling: FastifyPluginCallback = (fastify, _options, done) => {
|
||||
|
||||
fastify.decorate('Sentry', Sentry);
|
||||
|
||||
fastify.setErrorHandler((error, request, reply) => {
|
||||
fastify.setErrorHandler((error: FastifyError, request, reply) => {
|
||||
const logger = fastify.log.child({ req: request });
|
||||
const accepts = request.accepts().type(['json', 'html']);
|
||||
const { returnTo } = getRedirectParams(request);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { type FastifyPluginCallbackTypebox } from '@fastify/type-provider-typebox';
|
||||
import type { FastifyInstance } from 'fastify';
|
||||
import type { FastifyError, FastifyInstance } from 'fastify';
|
||||
import { differenceInMinutes } from 'date-fns';
|
||||
import validator from 'validator';
|
||||
|
||||
@@ -134,7 +134,7 @@ export const settingRoutes: FastifyPluginCallbackTypebox = (
|
||||
_options,
|
||||
done
|
||||
) => {
|
||||
fastify.setErrorHandler((error, request, reply) => {
|
||||
fastify.setErrorHandler((error: FastifyError, request, reply) => {
|
||||
const logger = fastify.log.child({ req: request });
|
||||
if (error.validation) {
|
||||
logger.warn({ validationError: error.validation });
|
||||
|
||||
@@ -13,6 +13,10 @@ export const updateMyAbout = {
|
||||
message: Type.Literal('flash.updated-about-me'),
|
||||
type: Type.Literal('success')
|
||||
}),
|
||||
400: Type.Object({
|
||||
message: Type.Literal('flash.wrong-updating'),
|
||||
type: Type.Literal('danger')
|
||||
}),
|
||||
500: Type.Object({
|
||||
message: Type.Literal('flash.wrong-updating'),
|
||||
type: Type.Literal('danger')
|
||||
|
||||
@@ -14,6 +14,10 @@ export const reportUser = {
|
||||
email: Type.String()
|
||||
})
|
||||
}),
|
||||
403: Type.Object({
|
||||
type: Type.Literal('danger'),
|
||||
message: Type.Literal('flash.report-error')
|
||||
}),
|
||||
404: Type.Object({
|
||||
type: Type.Literal('danger'),
|
||||
message: Type.Literal('flash.report-error')
|
||||
|
||||
Reference in New Issue
Block a user