- Unify API: lib/api.ts uses /api/v1, inbox uses /api/inbox (rewrites) - Remove localhost refs: openapi, inbox page - Add rewrites: /api/inbox|tmc -> inbox-server, /api/v1 -> FastAPI - Add stub routes: knowledge/insights, recommendations, search, log-error - Transfer from PAPA: prompts (inspection, tmc), scripts, supabase, data/tmc-requests - Fix inbox-server: ORDER BY created_at, package.json - Remove redundant app/api/inbox/files route (rewrites handle it) - knowledge/ in gitignore (large PDFs) Co-authored-by: Cursor <cursoragent@cursor.com>
41 lines
1.3 KiB
TypeScript
41 lines
1.3 KiB
TypeScript
export interface Aircraft {
|
|
id: string;
|
|
registrationNumber: string;
|
|
serialNumber: string;
|
|
aircraftType: string;
|
|
model: string;
|
|
operator: string;
|
|
status: string;
|
|
flightHours?: number;
|
|
manufacturer?: string;
|
|
yearOfManufacture?: number;
|
|
maxTakeoffWeight?: number;
|
|
engineType?: string;
|
|
lastInspectionDate?: string;
|
|
nextInspectionDate?: string;
|
|
certificateExpiry?: string;
|
|
date?: string;
|
|
rating?: number;
|
|
notes?: string;
|
|
[key: string]: any;
|
|
}
|
|
|
|
const API_BASE = process.env.NEXT_PUBLIC_API_URL || "/api/v1";
|
|
|
|
export async function apiFetch(path: string, opts: RequestInit = {}) {
|
|
const res = await fetch(API_BASE + path, { ...opts, headers: { "Content-Type": "application/json", ...opts.headers } });
|
|
if (res.ok === false) throw new Error("API error: " + res.status);
|
|
return res.json();
|
|
}
|
|
|
|
export const aircraftApi = {
|
|
getAircraft: () => apiFetch("/aircraft"),
|
|
getAll: () => apiFetch("/aircraft"),
|
|
getById: (id: string) => apiFetch("/aircraft/" + id),
|
|
create: (data: any) => apiFetch("/aircraft", { method: "POST", body: JSON.stringify(data) }),
|
|
update: (id: string, data: any) => apiFetch("/aircraft/" + id, { method: "PUT", body: JSON.stringify(data) }),
|
|
delete: (id: string) => apiFetch("/aircraft/" + id, { method: "DELETE" }),
|
|
};
|
|
|
|
export default { fetch: apiFetch };
|