14ed19497f
- Add cut_style, shampoo_preference, special_care_notes, custom_fields columns to pets table - Add grooming_visit_logs table to track per-visit grooming details (cut, products, notes) - Extend pets API to accept and return new profile fields - Add /api/grooming-logs endpoint (GET by petId, POST, DELETE) - Update Pet type with new fields; add GroomingVisitLog type - Update Clients page: grooming preferences section in pet card, "Log visit" button, visit history panel showing last 3 visits, expanded pet form with grooming preferences Co-authored-by: Groom Book CTO <cto@groombook.app> Co-authored-by: Paperclip <noreply@paperclip.ing>
58 lines
1.9 KiB
TypeScript
58 lines
1.9 KiB
TypeScript
import { serve } from "@hono/node-server";
|
|
import { Hono } from "hono";
|
|
import { logger } from "hono/logger";
|
|
import { cors } from "hono/cors";
|
|
import { clientsRouter } from "./routes/clients.js";
|
|
import { petsRouter } from "./routes/pets.js";
|
|
import { servicesRouter } from "./routes/services.js";
|
|
import { appointmentsRouter } from "./routes/appointments.js";
|
|
import { staffRouter } from "./routes/staff.js";
|
|
import { invoicesRouter } from "./routes/invoices.js";
|
|
import { bookRouter } from "./routes/book.js";
|
|
import { reportsRouter } from "./routes/reports.js";
|
|
import { appointmentGroupsRouter } from "./routes/appointmentGroups.js";
|
|
import { groomingLogsRouter } from "./routes/groomingLogs.js";
|
|
import { authMiddleware } from "./middleware/auth.js";
|
|
import { startReminderScheduler } from "./services/reminders.js";
|
|
|
|
const app = new Hono();
|
|
|
|
// Global middleware
|
|
app.use("*", logger());
|
|
app.use(
|
|
"/api/*",
|
|
cors({
|
|
origin: process.env.CORS_ORIGIN ?? "http://localhost:5173",
|
|
credentials: true,
|
|
})
|
|
);
|
|
|
|
// Health check (no auth required)
|
|
app.get("/health", (c) => c.json({ status: "ok" }));
|
|
|
|
// Public booking routes — no auth required, must be registered before auth middleware
|
|
app.route("/api/book", bookRouter);
|
|
|
|
// Protected API routes
|
|
const api = app.basePath("/api");
|
|
api.use("*", authMiddleware);
|
|
|
|
api.route("/clients", clientsRouter);
|
|
api.route("/pets", petsRouter);
|
|
api.route("/services", servicesRouter);
|
|
api.route("/appointments", appointmentsRouter);
|
|
api.route("/staff", staffRouter);
|
|
api.route("/invoices", invoicesRouter);
|
|
api.route("/reports", reportsRouter);
|
|
api.route("/appointment-groups", appointmentGroupsRouter);
|
|
api.route("/grooming-logs", groomingLogsRouter);
|
|
|
|
const port = Number(process.env.PORT ?? 3000);
|
|
console.log(`API server listening on port ${port}`);
|
|
serve({ fetch: app.fetch, port });
|
|
|
|
// Start background reminder scheduler (runs every minute to check for upcoming appointments)
|
|
startReminderScheduler();
|
|
|
|
export default app;
|