good forst commit

This commit is contained in:
2026-06-09 02:02:40 +05:30
parent 801c1d7121
commit 249d759e6a
215 changed files with 15425 additions and 1240 deletions
+13 -10
View File
@@ -1,19 +1,22 @@
const API_URL = process.env.API_URL ?? 'http://localhost:3001';
import { apiFetch, jsonResponse } from '../../_lib/api';
export async function GET(req: Request) {
export const dynamic = 'force-dynamic';
export async function GET(req: Request): Promise<Response> {
const { searchParams } = new URL(req.url);
const url = new URL(`${API_URL}/routes`);
searchParams.forEach((v, k) => url.searchParams.set(k, v));
const res = await fetch(url, { cache: 'no-store' });
return Response.json(await res.json(), { status: res.status });
const query = searchParams.toString();
const path = query ? `/routes?${query}` : '/routes';
const res = await apiFetch(path);
const body = await res.json();
return jsonResponse(body, res.status);
}
export async function POST(req: Request) {
export async function POST(req: Request): Promise<Response> {
const body = await req.json();
const res = await fetch(`${API_URL}/routes`, {
const res = await apiFetch('/routes', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(body),
});
return Response.json(await res.json(), { status: res.status });
const payload = await res.json();
return jsonResponse(payload, res.status);
}