chore: some refactor and cleaning

This commit is contained in:
2024-12-30 06:54:01 +01:00
parent 5c75e9390e
commit e39026c259
15 changed files with 5029 additions and 7233 deletions

View File

@@ -11,14 +11,11 @@ import {
} from '@utils/statusCodes';
import { ResponseType, UnsubscribeFormSchema } from '@utils/validationSchemas';
import { NextRequest } from 'next/server';
import { Resend } from 'resend';
export const dynamic = 'force-dynamic'; // defaults to force-static
export async function POST(request: NextRequest) {
try {
if (!process.env.RESEND_KEY || !process.env.RESEND_AUDIENCE) {
throw new Error('RESEND_AUDIENCE is not set');
if (!process.env.RESEND_KEY) {
throw new Error('Resend variables not set');
}
const body = await request.json();
const validation = UnsubscribeFormSchema.safeParse(body);
@@ -44,14 +41,6 @@ export async function POST(request: NextRequest) {
}
});
const resend = new Resend(process.env.RESEND_KEY);
await resend.contacts.update({
id: user.resendId,
audienceId: process.env.RESEND_AUDIENCE,
unsubscribed: true
});
const sent = await sender([email], UnsubscribeTemplate());
if (!sent) {