mirror of
https://github.com/lukevella/rallly.git
synced 2025-04-29 18:26:34 +02:00
🚧 Temporarily disable message queue (#1449)
This commit is contained in:
parent
3f405003fd
commit
9b606bdbdc
3 changed files with 25 additions and 31 deletions
|
@ -1,28 +1,33 @@
|
|||
import * as Sentry from "@sentry/nextjs";
|
||||
import { verifySignatureAppRouter } from "@upstash/qstash/dist/nextjs";
|
||||
import type { NextRequest } from "next/server";
|
||||
import { NextResponse } from "next/server";
|
||||
|
||||
import { getEmailClient } from "@/utils/emails";
|
||||
|
||||
import { verifySignature } from "./verify-signature";
|
||||
export const POST = async (req: NextRequest) => {
|
||||
/**
|
||||
* We need to call verifySignatureAppRouter inside the route handler
|
||||
* to avoid the build breaking when env vars are not set.
|
||||
*/
|
||||
return verifySignatureAppRouter(async (req: NextRequest) => {
|
||||
const body = await req.json();
|
||||
|
||||
export const POST = verifySignature(async (req: NextRequest) => {
|
||||
const body = await req.json();
|
||||
// TODO: Add validation for templateName and options
|
||||
|
||||
// TODO: Add validation for templateName and options
|
||||
const emailClient = getEmailClient(body.locale);
|
||||
|
||||
const emailClient = getEmailClient(body.locale);
|
||||
try {
|
||||
await emailClient.sendTemplate(body.templateName, body.options);
|
||||
|
||||
try {
|
||||
await emailClient.sendTemplate(body.templateName, body.options);
|
||||
return NextResponse.json({ success: true });
|
||||
} catch (error) {
|
||||
Sentry.captureException(error);
|
||||
|
||||
return NextResponse.json({ success: true });
|
||||
} catch (error) {
|
||||
Sentry.captureException(error);
|
||||
|
||||
return NextResponse.json(
|
||||
{ success: false, error: "Failed to send email" },
|
||||
{ status: 500 },
|
||||
);
|
||||
}
|
||||
});
|
||||
return NextResponse.json(
|
||||
{ success: false, error: "Failed to send email" },
|
||||
{ status: 500 },
|
||||
);
|
||||
}
|
||||
})(req);
|
||||
};
|
||||
|
|
|
@ -1,12 +0,0 @@
|
|||
import { verifySignatureAppRouter } from "@upstash/qstash/dist/nextjs";
|
||||
import type { NextRequest } from "next/server";
|
||||
|
||||
export async function verifySignature(
|
||||
handler: (req: NextRequest) => Promise<Response>,
|
||||
) {
|
||||
/**
|
||||
* We need to call verifySignatureAppRouter inside the route handler
|
||||
* to avoid the build breaking when env vars are not set.
|
||||
*/
|
||||
return (req: NextRequest) => verifySignatureAppRouter(handler)(req);
|
||||
}
|
|
@ -72,12 +72,13 @@ export class EmailClient {
|
|||
templateName: T,
|
||||
options: SendEmailOptions<T>,
|
||||
) {
|
||||
const isQueueEnabled = false; // TODO: Enable this
|
||||
const createEmailJob = async () => {
|
||||
const client = createQstashClient();
|
||||
|
||||
if (client) {
|
||||
if (client && isQueueEnabled) {
|
||||
const queue = client.queue({
|
||||
queueName: "emails",
|
||||
queueName: "emails-mq",
|
||||
});
|
||||
|
||||
queue
|
||||
|
|
Loading…
Add table
Reference in a new issue