From 59871fc66f06c12679fcdbcd5de1c15542b60d2f Mon Sep 17 00:00:00 2001 From: shialoth Date: Wed, 30 Apr 2025 23:35:01 +0530 Subject: [PATCH] removed unnecessary route --- src/app/dashboard/api/orders/route.ts | 70 --------------------------- 1 file changed, 70 deletions(-) delete mode 100644 src/app/dashboard/api/orders/route.ts diff --git a/src/app/dashboard/api/orders/route.ts b/src/app/dashboard/api/orders/route.ts deleted file mode 100644 index 6df271b..0000000 --- a/src/app/dashboard/api/orders/route.ts +++ /dev/null @@ -1,70 +0,0 @@ -import { NextRequest, NextResponse } from 'next/server'; -import { createClient } from '@supabase/supabase-js'; -import nodemailer from 'nodemailer'; - -const supabase = createClient( - process.env.SUPABASE_URL!, - process.env.SUPABASE_SERVICE_ROLE_KEY! -); - -const emailUser = process.env.EMAIL_USER!; -const emailPass = process.env.EMAIL_PASS!; -const businessEmail = process.env.BUSINESS_EMAIL!; - -export async function POST(req: NextRequest) { - try { - const { gpuId, userEmail, txSignature, amountSol, status } = await req.json(); - - if (!gpuId || !userEmail || !amountSol || !status) { - return NextResponse.json({ error: 'Missing required fields' }, { status: 400 }); - } - - if (!['pending', 'success', 'failed'].includes(status)) { - return NextResponse.json({ error: 'Invalid status value' }, { status: 400 }); - } - - const { error } = await supabase.from('orders').insert({ - gpu_id: gpuId, - user_email: userEmail, - amount_sol: amountSol, - sol_tx_signature: txSignature || null, - status, - }); - - if (error) { - console.error('[Supabase error]', error); - return NextResponse.json({ error: 'Database error' }, { status: 500 }); - } - - // Send confirmation email - const transporter = nodemailer.createTransport({ - service: 'gmail', - auth: { - user: emailUser, - pass: emailPass, - }, - }); - - await transporter.sendMail({ - from: `"GPU Store" <${emailUser}>`, - to: userEmail, - subject: `GPU Payment ${status === 'success' ? 'Confirmed' : 'Attempted'}`, - html: ` -

Hi,

-

Your order for GPU ID ${gpuId} has status: ${status}.

-

Amount: ${amountSol} SOL

- ${ - txSignature - ? `

Transaction: ${txSignature}

` - : '

No transaction was recorded.

' - } -

Thank you for using our platform.

- `, - }); - - return NextResponse.json({ message: 'Order recorded and email sent' }); - } catch (err: any) { - console.error('[Order API Error]', err); - return NextResponse.json({ error: 'Server error' }, { status: 500 }); - } -}