chore(api): migrate to fastify v5 (#57576)

This commit is contained in:
Oliver Eyton-Williams
2025-06-02 04:37:57 +02:00
committed by GitHub
parent 690d05c7b9
commit 89402caa9d
14 changed files with 301 additions and 298 deletions

View File

@@ -15,7 +15,6 @@ async function setupServer() {
const fastify = Fastify({ logger: true, disableRequestLogging: true });
await fastify.register(cookies);
await fastify.register(csrf);
// @ts-expect-error - @fastify/csrf-protection needs to update their types
// eslint-disable-next-line @typescript-eslint/unbound-method
fastify.addHook('onRequest', fastify.csrfProtection);

View File

@@ -3,13 +3,6 @@ import Fastify from 'fastify';
import mailer from './mailer';
describe('mailer', () => {
it('should throw if not given a provider', async () => {
const fastify = Fastify();
await expect(fastify.register(mailer)).rejects.toThrow(
"The mailer plugin must be passed a provider via register's options."
);
});
it('should send an email via the provider', async () => {
const fastify = Fastify();
const send = jest.fn();

View File

@@ -28,13 +28,6 @@ const plugin: FastifyPluginCallback<{ provider: MailProvider }> = (
) => {
const { provider } = options;
if (!provider)
return done(
Error(
"The mailer plugin must be passed a provider via register's options."
)
);
fastify.decorate('sendEmail', async (args: SendEmailArgs) => {
const logger = fastify.log.child({ args });
logger.info('Sending Email');