Update package.json scripts, enhance layout with new components, and improve API error handling
Some checks failed
Deploy / deploy (push) Failing after 1h28m6s
Some checks failed
Deploy / deploy (push) Failing after 1h28m6s
- Added new scripts for database operations and temporary production in package.json. - Integrated KaydetBannerLazy component into the layout for improved user notifications. - Enhanced API error handling in the soru route to mark credit exhaustion. - Updated the IletisimPage for better button styling and user experience. - Refactored ListemPage to streamline user flow and improve session handling. - Removed unused ListePaneli component to clean up the codebase.
This commit is contained in:
19
src/app/api/netler/route.ts
Normal file
19
src/app/api/netler/route.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import { NextResponse, type NextRequest } from "next/server";
|
||||
import { netlerGetir } from "@/lib/db";
|
||||
|
||||
// Program satırındaki "netler" butonunun verisi: programa yerleşen son
|
||||
// kişinin yıl bazlı netleri (bkz. components/program-netleri.tsx). Veri
|
||||
// yılda bir değiştiği için istemci tarafında gönül rahatlığıyla cache'lenir.
|
||||
export function GET(request: NextRequest) {
|
||||
const id = request.nextUrl.searchParams.get("id") ?? "";
|
||||
if (!/^\d{1,12}$/.test(id)) {
|
||||
return NextResponse.json(
|
||||
{ error: "Geçerli bir program kimliği gerekli." },
|
||||
{ status: 400 },
|
||||
);
|
||||
}
|
||||
return NextResponse.json(
|
||||
{ netler: netlerGetir(id) },
|
||||
{ headers: { "Cache-Control": "public, max-age=86400" } },
|
||||
);
|
||||
}
|
||||
@@ -2,7 +2,11 @@ import { eq, desc, asc } from "drizzle-orm";
|
||||
import type { NextRequest } from "next/server";
|
||||
import { getSession } from "@/lib/session";
|
||||
import { appDb, schema } from "@/lib/appdb";
|
||||
import { spendCreditForMessage, grantCredits } from "@/lib/credits";
|
||||
import {
|
||||
spendCreditForMessage,
|
||||
grantCredits,
|
||||
krediBittiIsaretle,
|
||||
} from "@/lib/credits";
|
||||
import { anahtarVar, SORUMLULUK_REDDI } from "@/lib/ai/client";
|
||||
import { sohbetAkisi } from "@/lib/ai/cagri";
|
||||
import { listeOzetiCikar, type RaporSonuc } from "@/lib/ai/rapor";
|
||||
@@ -147,6 +151,7 @@ export async function POST(request: NextRequest) {
|
||||
});
|
||||
if (!harcama.ok) {
|
||||
if (harcama.error === "INSUFFICIENT") {
|
||||
await krediBittiIsaretle(session.user.id);
|
||||
return Response.json(
|
||||
{ error: "Kredin bitti.", code: "INSUFFICIENT" },
|
||||
{ status: 402 },
|
||||
|
||||
38
src/app/api/tadimlik/route.ts
Normal file
38
src/app/api/tadimlik/route.ts
Normal file
@@ -0,0 +1,38 @@
|
||||
// Tadımlık satırı servisi: client sihirbaz kategorisini (localStorage'da
|
||||
// yaşar, SSR göremez) bildirir; SEÇİM sunucuda yapılır (PRD kısıtı). Havuz
|
||||
// batch üretilmiştir — bu uç LLM'e istek atmaz, salt SELECT'tir.
|
||||
|
||||
import { NextResponse } from "next/server";
|
||||
import { PUAN_TURLERI, type PuanTuruKey } from "@/lib/db";
|
||||
import { KATEGORILER } from "@/lib/kategoriler";
|
||||
import { kategoriSlugBul, tadimlikSec } from "@/lib/tadimlik-havuzu";
|
||||
|
||||
const GECERLI_KATEGORI_SLUGLARI = new Set(KATEGORILER.map(kategoriSlugBul));
|
||||
|
||||
export async function GET(istek: Request) {
|
||||
const url = new URL(istek.url);
|
||||
const sira = Number.parseInt(url.searchParams.get("sira") ?? "", 10);
|
||||
const tur = url.searchParams.get("tur") ?? "";
|
||||
|
||||
if (
|
||||
!Number.isFinite(sira) ||
|
||||
sira < 1 ||
|
||||
sira > 4_000_000 ||
|
||||
!(tur in PUAN_TURLERI)
|
||||
) {
|
||||
return NextResponse.json({ tadimlik: null }, { status: 400 });
|
||||
}
|
||||
|
||||
const kategoriParam = url.searchParams.get("kategori");
|
||||
const kategoriSlug =
|
||||
kategoriParam && GECERLI_KATEGORI_SLUGLARI.has(kategoriParam)
|
||||
? kategoriParam
|
||||
: undefined;
|
||||
|
||||
const tadimlik = await tadimlikSec(sira, tur as PuanTuruKey, kategoriSlug);
|
||||
return NextResponse.json(
|
||||
{ tadimlik },
|
||||
// Satırlar kova granülaritesinde statik; 1 saat cache yeterli.
|
||||
{ headers: { "Cache-Control": "public, max-age=3600" } },
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user