Refactor: Fully migrated to direct PostgreSQL, implemented Public API v1, fixed Vercel deployment conflicts, and updated documentation

This commit is contained in:
mstfyldz
2026-03-12 21:54:57 +03:00
parent 321f25a15c
commit 515d513c1f
29 changed files with 1002 additions and 675 deletions

View File

@@ -1,5 +1,5 @@
import { NextRequest, NextResponse } from 'next/server';
import { supabaseAdmin } from '@/lib/supabase-admin';
import { db } from '@/lib/db';
import { cookies } from 'next/headers';
export async function POST(req: NextRequest) {
@@ -12,20 +12,15 @@ export async function POST(req: NextRequest) {
// 1. Resolve merchant by ID or short_id
const isUUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(identifier);
const queryText = isUUID
? 'SELECT * FROM merchants WHERE id = $1 LIMIT 1'
: 'SELECT * FROM merchants WHERE short_id = $1 LIMIT 1';
const result = await db.query(queryText, [identifier]);
const merchant = result.rows[0];
const query = supabaseAdmin
.from('merchants')
.select('*');
if (isUUID) {
query.eq('id', identifier);
} else {
query.eq('short_id', identifier);
}
const { data: merchant, error } = await query.single();
if (error || !merchant) {
if (!merchant) {
return NextResponse.json({ error: 'Firma bulunamadı.' }, { status: 404 });
}