mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-02-19 13:00:32 -05:00
chore(api): migrate to fastify v5 (#57576)
This commit is contained in:
committed by
GitHub
parent
690d05c7b9
commit
89402caa9d
@@ -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);
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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');
|
||||
|
||||
Reference in New Issue
Block a user