FindMyCarmatches.ts14 matches
1import { Hono } from "https://esm.sh/hono@3.11.7";
2import type { CarMatch, ApiResponse } from "../../shared/types.ts";
3import {
4getMatches,
39);
40
41const response: ApiResponse<any[]> = {
42success: true,
43data: enrichedMatches
46return c.json(response);
47} catch (error) {
48const response: ApiResponse<null> = {
49success: false,
50error: error instanceof Error ? error.message : "Unknown error occurred"
59const id = parseInt(c.req.param("id"));
60if (isNaN(id)) {
61const response: ApiResponse<null> = {
62success: false,
63error: "Invalid match ID"
68const { status } = await c.req.json();
69if (!['pending', 'confirmed', 'rejected'].includes(status)) {
70const response: ApiResponse<null> = {
71success: false,
72error: "Invalid status. Must be 'pending', 'confirmed', or 'rejected'"
80
81if (!match) {
82const response: ApiResponse<null> = {
83success: false,
84error: "Match not found"
95}
96
97const response: ApiResponse<null> = {
98success: true,
99message: `Match status updated to ${status}${status === 'confirmed' ? '. Car owners have been notified.' : ''}`
102return c.json(response);
103} catch (error) {
104const response: ApiResponse<null> = {
105success: false,
106error: error instanceof Error ? error.message : "Unknown error occurred"
115const stolenCarId = parseInt(c.req.param("stolenCarId"));
116if (isNaN(stolenCarId)) {
117const response: ApiResponse<null> = {
118success: false,
119error: "Invalid stolen car ID"
135);
136
137const response: ApiResponse<any[]> = {
138success: true,
139data: enrichedMatches
142return c.json(response);
143} catch (error) {
144const response: ApiResponse<null> = {
145success: false,
146error: error instanceof Error ? error.message : "Unknown error occurred"
155const foundCarId = parseInt(c.req.param("foundCarId"));
156if (isNaN(foundCarId)) {
157const response: ApiResponse<null> = {
158success: false,
159error: "Invalid found car ID"
175);
176
177const response: ApiResponse<any[]> = {
178success: true,
179data: enrichedMatches
182return c.json(response);
183} catch (error) {
184const response: ApiResponse<null> = {
185success: false,
186error: error instanceof Error ? error.message : "Unknown error occurred"
19await createTables();
2021// API Routes
22app.route("/api/stolen", stolenRoutes);
23app.route("/api/found", foundRoutes);
24app.route("/api/matches", matchRoutes);
25app.route("/api/search", searchRoutes);
2627// Health check endpoint
28app.get("/api/health", (c) => {
29return c.json({
30status: "healthy",
31timestamp: new Date().toISOString(),
32service: "Lost Cars Finder API"
33});
34});
46const initialData = {
47timestamp: new Date().toISOString(),
48apiBase: "/api"
49};
5076<div class="bg-blue-50 p-4 rounded-lg">
77<p class="text-sm text-blue-800">
78API is running at <code>/api</code> -
79<a href="/api/health" class="underline">Check health</a>
80</p>
81</div>
94error: "Endpoint not found",
95available_endpoints: [
96"GET /api/health",
97"GET /api/stolen",
98"POST /api/stolen",
99"GET /api/found",
100"POST /api/found",
101"GET /api/matches",
102"GET /api/search"
103]
104}, 404);
1import { Hono } from "https://esm.sh/hono@3.11.7";
2import type { FoundCar, ApiResponse } from "../../shared/types.ts";
3import {
4createFoundCarReport,
31const cars = await getFoundCars(Object.keys(cleanFilters).length > 0 ? cleanFilters : undefined);
32
33const response: ApiResponse<FoundCar[]> = {
34success: true,
35data: cars
38return c.json(response);
39} catch (error) {
40const response: ApiResponse<null> = {
41success: false,
42error: error instanceof Error ? error.message : "Unknown error occurred"
51const id = parseInt(c.req.param("id"));
52if (isNaN(id)) {
53const response: ApiResponse<null> = {
54success: false,
55error: "Invalid car ID"
60const car = await getFoundCarById(id);
61if (!car) {
62const response: ApiResponse<null> = {
63success: false,
64error: "Found car not found"
67}
6869const response: ApiResponse<FoundCar> = {
70success: true,
71data: car
74return c.json(response);
75} catch (error) {
76const response: ApiResponse<null> = {
77success: false,
78error: error instanceof Error ? error.message : "Unknown error occurred"
92
93if (missingFields.length > 0) {
94const response: ApiResponse<null> = {
95success: false,
96error: `Missing required fields: ${missingFields.join(', ')}`
152}
153
154const response: ApiResponse<FoundCar> = {
155success: true,
156data: createdCar!,
160return c.json(response, 201);
161} catch (error) {
162const response: ApiResponse<null> = {
163success: false,
164error: error instanceof Error ? error.message : "Unknown error occurred"
173const id = parseInt(c.req.param("id"));
174if (isNaN(id)) {
175const response: ApiResponse<null> = {
176success: false,
177error: "Invalid car ID"
182const { status } = await c.req.json();
183if (!['active', 'matched', 'resolved'].includes(status)) {
184const response: ApiResponse<null> = {
185success: false,
186error: "Invalid status. Must be 'active', 'matched', or 'resolved'"
192const existingCar = await getFoundCarById(id);
193if (!existingCar) {
194const response: ApiResponse<null> = {
195success: false,
196error: "Found car not found"
202const updatedCar = await getFoundCarById(id);
203
204const response: ApiResponse<FoundCar> = {
205success: true,
206data: updatedCar!,
210return c.json(response);
211} catch (error) {
212const response: ApiResponse<null> = {
213success: false,
214error: error instanceof Error ? error.message : "Unknown error occurred"
223const id = parseInt(c.req.param("id"));
224if (isNaN(id)) {
225const response: ApiResponse<null> = {
226success: false,
227error: "Invalid car ID"
232const matches = await findPotentialMatches(id);
233
234const response: ApiResponse<any[]> = {
235success: true,
236data: matches
239return c.json(response);
240} catch (error) {
241const response: ApiResponse<null> = {
242success: false,
243error: error instanceof Error ? error.message : "Unknown error occurred"
34});
3536const response = await fetch(`/api/search?${params}`);
37const data = await response.json();
38
Advertappadvertisements.ts5 matches
10User,
11CreateAdvertisementRequest,
12ApiResponse,
13Advertisement,
14AdvertisementWithLeads
23const ads = await getAdvertisementsByUser(user.id);
24
25const response: ApiResponse<Advertisement[]> = {
26success: true,
27data: ads
84};
85
86const response: ApiResponse<Advertisement> = {
87success: true,
88data: responseAd
123};
124
125const response: ApiResponse<AdvertisementWithLeads> = {
126success: true,
127data: responseAd
158};
159
160const response: ApiResponse<typeof responseStats> = {
161success: true,
162data: responseStats
untitled-1096Calendar.tsx3 matches
24const endDate = getViewEndDate();
25
26const response = await fetch(`/api/events/range?start=${startDate.toISOString()}&end=${endDate.toISOString()}`);
27const result = await response.json();
28
109
110try {
111const response = await fetch(`/api/events/${eventId}`, {
112method: 'DELETE'
113});
354key={mode}
355onClick={() => setViewMode(mode)}
356className={`px-3 py-1 text-sm rounded capitalize ${
357viewMode === mode
358? 'bg-blue-600 text-white'
AlxprojectREADME.md8 matches
14```
15โโโ backend/
16โ โโโ index.ts # Main API server with OpenAI integration
17โโโ frontend/
18โ โโโ index.html # Main application interface
33## Technology Stack
3435- **Backend**: Hono + OpenAI API
36- **Frontend**: React + TailwindCSS
37- **AI**: GPT-4o-mini for concept explanations
38- **Styling**: Custom CSS with gradient backgrounds and animations
3940## API Endpoints
4142- `GET /` - Main application interface
43- `POST /api/explain` - Get AI-powered explanations for biostatistics terms
44- `GET /api/health` - Health check endpoint
45- `GET /frontend/*` - Static frontend assets
46- `GET /shared/*` - Shared TypeScript types
68- Comprehensive coverage of biostatistics curriculum
6970## API Endpoints
7172- `GET /` - Main application interface
73- `POST /api/explain` - Get AI-powered explanations for biostatistics concepts
74- `GET /api/health` - Health check endpoint
7576## Example Usage
untitled-1096App.tsx3 matches
32try {
33setLoading(true);
34const response = await fetch('/api/dashboard');
35const result = await response.json();
36if (result.success) {
75const toggleTodoComplete = async (todo: TodoItem) => {
76try {
77const response = await fetch(`/api/todos/${todo.id}/toggle`, {
78method: 'PATCH'
79});
300301try {
302const url = editingTodo ? `/api/todos/${editingTodo.id}` : '/api/todos';
303const method = editingTodo ? 'PUT' : 'POST';
304
Alxprojectindex.tsx1 match
3031try {
32const response = await fetch("/api/explain", {
33method: "POST",
34headers: { "Content-Type": "application/json" },