diff --git a/apps/api/eslint.config.js b/apps/api/eslint.config.js new file mode 100644 index 0000000..e3961f7 --- /dev/null +++ b/apps/api/eslint.config.js @@ -0,0 +1,11 @@ +import tseslint from "typescript-eslint"; + +export default tseslint.config( + ...tseslint.configs.recommended, + { + rules: { + "@typescript-eslint/no-explicit-any": "warn", + "@typescript-eslint/no-unused-vars": ["error", { argsIgnorePattern: "^_" }], + }, + } +); diff --git a/apps/api/package.json b/apps/api/package.json index 071a656..dd128d2 100644 --- a/apps/api/package.json +++ b/apps/api/package.json @@ -15,7 +15,9 @@ "@groombook/db": "workspace:*", "@groombook/types": "workspace:*", "@hono/node-server": "^1.13.7", + "@hono/zod-validator": "^0.4.3", "hono": "^4.6.17", + "jose": "^5.9.6", "openid-client": "^6.1.7", "zod": "^3.24.1" }, diff --git a/apps/api/src/routes/appointments.ts b/apps/api/src/routes/appointments.ts index 69c71f2..05f87cc 100644 --- a/apps/api/src/routes/appointments.ts +++ b/apps/api/src/routes/appointments.ts @@ -1,8 +1,7 @@ import { Hono } from "hono"; import { zValidator } from "@hono/zod-validator"; import { z } from "zod"; -import { and, eq, gte, lt, lte, ne } from "drizzle-orm"; -import { getDb, appointments } from "@groombook/db"; +import { and, eq, getDb, gte, lt, lte, ne, appointments } from "@groombook/db"; export const appointmentsRouter = new Hono(); @@ -144,13 +143,12 @@ appointmentsRouter.patch( .from(appointments) .where(eq(appointments.id, id)) .limit(1); - if (existing.length === 0) return c.json({ error: "Not found" }, 404); + const current = existing[0]; + if (!current) return c.json({ error: "Not found" }, 404); - const start = body.startTime - ? new Date(body.startTime) - : existing[0].startTime; - const end = body.endTime ? new Date(body.endTime) : existing[0].endTime; - const staffId = body.staffId ?? existing[0].staffId; + const start = body.startTime ? new Date(body.startTime) : current.startTime; + const end = body.endTime ? new Date(body.endTime) : current.endTime; + const staffId = body.staffId ?? current.staffId; if (end <= start) { return c.json({ error: "endTime must be after startTime" }, 422); diff --git a/apps/api/src/routes/clients.ts b/apps/api/src/routes/clients.ts index b1d9f7c..e560393 100644 --- a/apps/api/src/routes/clients.ts +++ b/apps/api/src/routes/clients.ts @@ -1,8 +1,7 @@ import { Hono } from "hono"; import { zValidator } from "@hono/zod-validator"; import { z } from "zod"; -import { eq } from "drizzle-orm"; -import { getDb, clients } from "@groombook/db"; +import { eq, getDb, clients } from "@groombook/db"; export const clientsRouter = new Hono(); diff --git a/apps/api/src/routes/pets.ts b/apps/api/src/routes/pets.ts index 73cb42a..5dc5869 100644 --- a/apps/api/src/routes/pets.ts +++ b/apps/api/src/routes/pets.ts @@ -1,8 +1,7 @@ import { Hono } from "hono"; import { zValidator } from "@hono/zod-validator"; import { z } from "zod"; -import { eq } from "drizzle-orm"; -import { getDb, pets } from "@groombook/db"; +import { eq, getDb, pets } from "@groombook/db"; export const petsRouter = new Hono(); @@ -42,8 +41,15 @@ petsRouter.get("/:id", async (c) => { petsRouter.post("/", zValidator("json", createPetSchema), async (c) => { const db = getDb(); - const body = c.req.valid("json"); - const [row] = await db.insert(pets).values(body).returning(); + const { weightKg, dateOfBirth, ...rest } = c.req.valid("json"); + const [row] = await db + .insert(pets) + .values({ + ...rest, + weightKg: weightKg?.toString(), + dateOfBirth: dateOfBirth ? new Date(dateOfBirth) : undefined, + }) + .returning(); return c.json(row, 201); }); @@ -52,10 +58,15 @@ petsRouter.patch( zValidator("json", updatePetSchema), async (c) => { const db = getDb(); - const body = c.req.valid("json"); + const { weightKg, dateOfBirth, ...rest } = c.req.valid("json"); const [row] = await db .update(pets) - .set({ ...body, updatedAt: new Date() }) + .set({ + ...rest, + weightKg: weightKg?.toString(), + dateOfBirth: dateOfBirth ? new Date(dateOfBirth) : undefined, + updatedAt: new Date(), + }) .where(eq(pets.id, c.req.param("id"))) .returning(); if (!row) return c.json({ error: "Not found" }, 404); diff --git a/apps/api/src/routes/services.ts b/apps/api/src/routes/services.ts index 1f9315a..621a797 100644 --- a/apps/api/src/routes/services.ts +++ b/apps/api/src/routes/services.ts @@ -1,8 +1,7 @@ import { Hono } from "hono"; import { zValidator } from "@hono/zod-validator"; import { z } from "zod"; -import { eq } from "drizzle-orm"; -import { getDb, services } from "@groombook/db"; +import { eq, getDb, services } from "@groombook/db"; export const servicesRouter = new Hono(); diff --git a/apps/api/src/routes/staff.ts b/apps/api/src/routes/staff.ts index 2149ed0..b305735 100644 --- a/apps/api/src/routes/staff.ts +++ b/apps/api/src/routes/staff.ts @@ -1,8 +1,7 @@ import { Hono } from "hono"; import { zValidator } from "@hono/zod-validator"; import { z } from "zod"; -import { eq } from "drizzle-orm"; -import { getDb, staff } from "@groombook/db"; +import { eq, getDb, staff } from "@groombook/db"; export const staffRouter = new Hono(); diff --git a/apps/api/vitest.config.ts b/apps/api/vitest.config.ts new file mode 100644 index 0000000..d913ed3 --- /dev/null +++ b/apps/api/vitest.config.ts @@ -0,0 +1,7 @@ +import { defineConfig } from "vitest/config"; + +export default defineConfig({ + test: { + passWithNoTests: true, + }, +}); diff --git a/apps/web/eslint.config.js b/apps/web/eslint.config.js new file mode 100644 index 0000000..e3961f7 --- /dev/null +++ b/apps/web/eslint.config.js @@ -0,0 +1,11 @@ +import tseslint from "typescript-eslint"; + +export default tseslint.config( + ...tseslint.configs.recommended, + { + rules: { + "@typescript-eslint/no-explicit-any": "warn", + "@typescript-eslint/no-unused-vars": ["error", { argsIgnorePattern: "^_" }], + }, + } +); diff --git a/apps/web/src/pages/Appointments.tsx b/apps/web/src/pages/Appointments.tsx index 58c126c..d088f2a 100644 --- a/apps/web/src/pages/Appointments.tsx +++ b/apps/web/src/pages/Appointments.tsx @@ -268,7 +268,7 @@ export function AppointmentsPage() {