chore: resend cleaning (#28)
This commit is contained in:
@@ -15,10 +15,6 @@ import { NextRequest } from 'next/server';
|
|||||||
|
|
||||||
export async function POST(request: NextRequest) {
|
export async function POST(request: NextRequest) {
|
||||||
try {
|
try {
|
||||||
if (!process.env.RESEND_KEY) {
|
|
||||||
throw new Error('RESEND_KEY is not set');
|
|
||||||
}
|
|
||||||
|
|
||||||
const body = await request.json();
|
const body = await request.json();
|
||||||
|
|
||||||
const validation = SubscribeFormSchema.safeParse(body);
|
const validation = SubscribeFormSchema.safeParse(body);
|
||||||
|
|||||||
@@ -14,11 +14,10 @@ import { NextRequest } from 'next/server';
|
|||||||
|
|
||||||
export async function POST(request: NextRequest) {
|
export async function POST(request: NextRequest) {
|
||||||
try {
|
try {
|
||||||
if (!process.env.RESEND_KEY) {
|
|
||||||
throw new Error('Resend variables not set');
|
|
||||||
}
|
|
||||||
const body = await request.json();
|
const body = await request.json();
|
||||||
|
|
||||||
const validation = UnsubscribeFormSchema.safeParse(body);
|
const validation = UnsubscribeFormSchema.safeParse(body);
|
||||||
|
|
||||||
if (!validation.success) {
|
if (!validation.success) {
|
||||||
return formatApiResponse(STATUS_BAD_REQUEST, BAD_REQUEST);
|
return formatApiResponse(STATUS_BAD_REQUEST, BAD_REQUEST);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,10 @@ export async function sender(
|
|||||||
recipients: string[],
|
recipients: string[],
|
||||||
{ subject, template }: EmailTemplate
|
{ subject, template }: EmailTemplate
|
||||||
) {
|
) {
|
||||||
|
if (!process.env.RESEND_KEY) {
|
||||||
|
throw new Error('RESEND_KEY is not set');
|
||||||
|
}
|
||||||
|
|
||||||
if (recipients.length === 0) {
|
if (recipients.length === 0) {
|
||||||
console.info(`${subject} email skipped for having zero recipients`);
|
console.info(`${subject} email skipped for having zero recipients`);
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
Reference in New Issue
Block a user