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

21
lib/api-auth.ts Normal file
View File

@@ -0,0 +1,21 @@
import { db } from './db';
export async function validateApiKey(apiKey: string | null) {
if (!apiKey) return null;
try {
const result = await db.query(
'SELECT * FROM merchants WHERE api_key = $1 LIMIT 1',
[apiKey]
);
if (result.rows.length === 0) {
return null;
}
return result.rows[0];
} catch (error) {
console.error('API Key Validation Error:', error);
return null;
}
}