chore: update TS and Fastify (#52157)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Sboonny <muhammedelruby@gmail.com>
Co-authored-by: Shaun Hamilton <shauhami020@gmail.com>
Co-authored-by: Oliver Eyton-Williams <ojeytonwilliams@gmail.com>
This commit is contained in:
renovate[bot]
2023-11-07 17:22:59 +05:30
committed by GitHub
parent 0325ea4373
commit 87e1ae21a5
34 changed files with 466 additions and 303 deletions
+1 -1
View File
@@ -20,7 +20,7 @@
"date-fns": "2.30.0",
"dotenv": "16.3.1",
"fast-uri": "2.3.0",
"fastify": "4.21.0",
"fastify": "4.24.3",
"fastify-auth0-verify": "1.2.1",
"fastify-plugin": "4.5.1",
"joi": "17.11.0",
+1
View File
@@ -49,6 +49,7 @@ export const challengeRoutes: FastifyPluginCallbackTypebox = (
) => {
const challenges = getChallenges();
// @ts-expect-error - @fastify/csrf-protection needs to update their types
// eslint-disable-next-line @typescript-eslint/unbound-method
fastify.addHook('onRequest', fastify.csrfProtection);
fastify.addHook('onRequest', fastify.authenticateSession);
+1
View File
@@ -29,6 +29,7 @@ export const donateRoutes: FastifyPluginCallbackTypebox = (
// The order matters here, since we want to reject invalid cross site requests
// before checking if the user is authenticated.
// @ts-expect-error - @fastify/csrf-protection needs to update their types
// eslint-disable-next-line @typescript-eslint/unbound-method
fastify.addHook('onRequest', fastify.csrfProtection);
fastify.addHook('onRequest', fastify.authenticateSession);
+37 -3
View File
@@ -1,5 +1,18 @@
import { type FastifyPluginCallbackTypebox } from '@fastify/type-provider-typebox';
import type { FastifyError, FastifyReply, FastifyRequest } from 'fastify';
import {
TypeBoxTypeProvider,
type FastifyPluginCallbackTypebox
} from '@fastify/type-provider-typebox';
import type {
ContextConfigDefault,
FastifyError,
FastifyReply,
FastifyRequest,
RawReplyDefaultExpression,
RawRequestDefaultExpression,
RawServerDefault,
RouteGenericInterface
} from 'fastify';
import { ResolveFastifyReplyType } from 'fastify/types/type-provider';
import { getMinutes, isBefore, sub } from 'date-fns';
import { isProfane } from 'no-profanity';
@@ -63,14 +76,35 @@ export const settingRoutes: FastifyPluginCallbackTypebox = (
) => {
// The order matters here, since we want to reject invalid cross site requests
// before checking if the user is authenticated.
// @ts-expect-error - @fastify/csrf-protection needs to update their types
// eslint-disable-next-line @typescript-eslint/unbound-method
fastify.addHook('onRequest', fastify.csrfProtection);
fastify.addHook('onRequest', fastify.authenticateSession);
type CommonResponseSchema = {
response: { 400: (typeof schemas.updateMyProfileUI.response)[400] };
};
// TODO: figure out if there's a nicer way to generate this type
type UpdateReplyType = FastifyReply<
RawServerDefault,
RawRequestDefaultExpression<RawServerDefault>,
RawReplyDefaultExpression<RawServerDefault>,
RouteGenericInterface,
ContextConfigDefault,
CommonResponseSchema,
TypeBoxTypeProvider,
ResolveFastifyReplyType<
TypeBoxTypeProvider,
CommonResponseSchema,
RouteGenericInterface
>
>;
function updateErrorHandler(
error: FastifyError,
request: FastifyRequest,
reply: FastifyReply
reply: UpdateReplyType
) {
if (error.validation) {
void reply.code(400);
+1
View File
@@ -56,6 +56,7 @@ export const userRoutes: FastifyPluginCallbackTypebox = (
_options,
done
) => {
// @ts-expect-error - @fastify/csrf-protection needs to update their types
// eslint-disable-next-line @typescript-eslint/unbound-method
fastify.addHook('onRequest', fastify.csrfProtection);
fastify.addHook('onRequest', fastify.authenticateSession);
+32
View File
@@ -46,6 +46,10 @@ export const schemas = {
message: Type.Literal('flash.privacy-updated'),
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')
@@ -61,6 +65,10 @@ export const schemas = {
message: Type.Literal('flash.updated-themes'),
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')
@@ -101,6 +109,10 @@ export const schemas = {
message: Type.Literal('flash.updated-socials'),
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')
@@ -116,6 +128,10 @@ export const schemas = {
message: Type.Literal('flash.keyboard-shortcut-updated'),
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')
@@ -131,6 +147,10 @@ export const schemas = {
message: Type.Literal('flash.subscribe-to-quincy-updated'),
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')
@@ -146,6 +166,10 @@ export const schemas = {
message: Type.Literal('buttons.accepted-honesty'),
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')
@@ -180,6 +204,10 @@ export const schemas = {
message: Type.Literal('flash.privacy-updated'),
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')
@@ -691,6 +719,10 @@ export const schemas = {
200: Type.Object({
msUsername: Type.String()
}),
400: Type.Object({
type: Type.Literal('error'),
message: Type.Literal('flash.ms.transcript.link-err-1')
}),
404: Type.Object({
type: Type.Literal('error'),
message: Type.Literal('flash.ms.transcript.link-err-2')