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
+7 -4
View File
@@ -1,11 +1,14 @@
const API_URL = process.env.API_URL ?? 'http://localhost:3001';
import { apiFetch } from '../../../_lib/api';
export const dynamic = 'force-dynamic';
export async function DELETE(
_req: Request,
{ params }: { params: Promise<{ id: string }> },
) {
): Promise<Response> {
const { id } = await params;
const res = await fetch(`${API_URL}/routes/${id}`, { method: 'DELETE' });
const res = await apiFetch(`/routes/${id}`, { method: 'DELETE' });
if (res.status === 204) return new Response(null, { status: 204 });
return Response.json(await res.json(), { status: res.status });
const body = await res.text();
return new Response(body, { status: res.status, headers: { 'Content-Type': 'application/json' } });
}
+13
View File
@@ -0,0 +1,13 @@
import { apiFetch, jsonResponse } from '../../../_lib/api';
export const dynamic = 'force-dynamic';
export async function POST(req: Request): Promise<Response> {
const body = await req.json();
const res = await apiFetch('/routes/batch', {
method: 'POST',
body: JSON.stringify(body),
});
const payload = await res.json();
return jsonResponse(payload, res.status);
}
+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);
}