12 getOrdersByUser
13} from "../database/queries.ts";
14import type { ApiResponse, Product, Order } from "../../shared/types.ts";
15
16const store = new Hono();
22 const products = await getAllProducts(category);
23
24 const response: ApiResponse<Product[]> = {
25 success: true,
26 data: products
56 }
57
58 const response: ApiResponse<Product> = {
59 success: true,
60 data: product
102 await addToCart(userPayload.userId, product_id, quantity);
103
104 const response: ApiResponse<null> = {
105 success: true,
106 message: 'Item added to cart successfully'
126 const total = cartItems.reduce((sum, item) => sum + item.total_price, 0);
127
128 const response: ApiResponse<{ items: any[], total: number }> = {
129 success: true,
130 data: { items: cartItems, total }
156 await removeFromCart(userPayload.userId, productId);
157
158 const response: ApiResponse<null> = {
159 success: true,
160 message: 'Item removed from cart successfully'
205 await clearCart(userPayload.userId);
206
207 const response: ApiResponse<{ orderId: number, total: number }> = {
208 success: true,
209 data: { orderId, total: totalAmount },
227 const orders = await getOrdersByUser(userPayload.userId);
228
229 const response: ApiResponse<Order[]> = {
230 success: true,
231 data: orders
9 getVetAppointmentsByUser
10} from "../database/queries.ts";
11import type { ServiceBookingForm, ApiResponse, GroomingAppointment, VetAppointment } from "../../shared/types.ts";
12
13const services = new Hono();
18 const groomingServices = await getGroomingServices();
19
20 const response: ApiResponse<any[]> = {
21 success: true,
22 data: groomingServices
73 const appointmentId = await createGroomingAppointment(appointmentData);
74
75 const response: ApiResponse<{ appointmentId: number }> = {
76 success: true,
77 data: { appointmentId },
95 const appointments = await getGroomingAppointmentsByUser(userPayload.userId);
96
97 const response: ApiResponse<GroomingAppointment[]> = {
98 success: true,
99 data: appointments
115 const vetServices = await getVeterinaryServices();
116
117 const response: ApiResponse<any[]> = {
118 success: true,
119 data: vetServices
170 const appointmentId = await createVetAppointment(appointmentData);
171
172 const response: ApiResponse<{ appointmentId: number }> = {
173 success: true,
174 data: { appointmentId },
192 const appointments = await getVetAppointmentsByUser(userPayload.userId);
193
194 const response: ApiResponse<VetAppointment[]> = {
195 success: true,
196 data: appointments
10 updateAdoptionApplicationStatus
11} from "../database/queries.ts";
12import type { PetRegistrationForm, AdoptionApplicationForm, ApiResponse, Pet, AdoptionApplication } from "../../shared/types.ts";
13
14const pets = new Hono();
20 const allPets = await getAllPets(status);
21
22 const response: ApiResponse<Pet[]> = {
23 success: true,
24 data: allPets
54 }
55
56 const response: ApiResponse<Pet> = {
57 success: true,
58 data: pet
95 const petId = await createPet(petData);
96
97 const response: ApiResponse<{ petId: number }> = {
98 success: true,
99 data: { petId },
165 await updatePetStatus(petId, 'pending');
166
167 const response: ApiResponse<{ applicationId: number }> = {
168 success: true,
169 data: { applicationId },
212 const applications = await getAdoptionApplicationsByPet(petId);
213
214 const response: ApiResponse<AdoptionApplication[]> = {
215 success: true,
216 data: applications
260 }
261
262 const response: ApiResponse<null> = {
263 success: true,
264 message: `Application ${status} successfully`
3import { setCookie, getCookie } from "https://esm.sh/hono@3.11.7/cookie";
4import { createUser, getUserByEmail, getUserPasswordHash, getUserById } from "../database/queries.ts";
5import type { UserRegistrationForm, LoginForm, ApiResponse, User } from "../../shared/types.ts";
6
7const auth = new Hono();
80 });
81
82 const response: ApiResponse<{ user: Omit<User, 'password_hash'>, token: string }> = {
83 success: true,
84 data: {
145 });
146
147 const response: ApiResponse<{ user: User, token: string }> = {
148 success: true,
149 data: { user, token },
174 }
175
176 const response: ApiResponse<User> = {
177 success: true,
178 data: user
74}
75
76export function capitalizeFirst(str: string): string {
77 return str.charAt(0).toUpperCase() + str.slice(1);
78}
136}
137
138// API Response types
139export interface ApiResponse<T> {
140 success: boolean;
141 data?: T;
75## Technology Stack
76
77- **Backend**: Hono (TypeScript API framework)
78- **Frontend**: React 18.2.0 with TypeScript
79- **Database**: SQLite
83## Getting Started
84
85The application is automatically deployed on Val Town. The main entry point is `/backend/index.ts` which serves both the API and frontend.
86
87## API Endpoints
88
89### Authentication
90- `POST /api/auth/register` - User registration
91- `POST /api/auth/login` - User login
92- `GET /api/auth/profile` - Get user profile
93
94### Pets
95- `GET /api/pets` - List available pets
96- `POST /api/pets` - Register a pet for adoption
97- `GET /api/pets/:id` - Get pet details
98- `POST /api/pets/:id/adopt` - Submit adoption application
99
100### Services
101- `GET /api/services/grooming` - List grooming services
102- `POST /api/services/grooming/book` - Book grooming appointment
103- `GET /api/services/veterinary` - List vet services
104- `POST /api/services/veterinary/book` - Book vet appointment
105
106### Store
107- `GET /api/store/products` - List pet supplies
108- `POST /api/store/cart` - Add to cart
109- `POST /api/store/checkout` - Process order
24
25// Game stats endpoint (could be extended for leaderboards)
26app.get("/api/stats", (c) => {
27 return c.json({
28 gameTitle: "Owl-Man",
1import { useState, useEffect } from "react";
2
3const PROJECT_ENDPOINT = "/api/project";
4const FILES_ENDPOINT = "/api/project-files";
5
6export function useProject(projectId: string, branchId?: string) {
1import { useState, useEffect } from "react";
2
3const ENDPOINT = "/api/projects-loader";
4
5export function useProjects() {