diff --git a/src/lib/server/db/index.ts b/src/lib/server/db/index.ts index 64e4e54..4830d97 100644 --- a/src/lib/server/db/index.ts +++ b/src/lib/server/db/index.ts @@ -36,7 +36,7 @@ export async function getTenantDb( .limit(1); if (tenant.length === 0) { - throw new Error(`Tenant with ID ${tenantId} not found`); + throw new Error(`Tenant or client not found`); } // Create tenant-specific database connection @@ -62,7 +62,7 @@ export async function getTenant(tenantId: string): Promise { tenantId, emailHashPrefix: emailHash.slice(0, 8), }); - return json({ error: "Client not found" }, { status: 404 }); + return json({ error: "Tenant or client not found" }, { status: 404 }); } const tunnel = tunnelResult[0]; diff --git a/src/routes/api/tenants/[id]/appointments/challenge/__tests__/challenge-api.test.ts b/src/routes/api/tenants/[id]/appointments/challenge/__tests__/challenge-api.test.ts index 153efc5..36af689 100644 --- a/src/routes/api/tenants/[id]/appointments/challenge/__tests__/challenge-api.test.ts +++ b/src/routes/api/tenants/[id]/appointments/challenge/__tests__/challenge-api.test.ts @@ -174,7 +174,7 @@ describe("Challenge API Route", () => { const data = await response.json(); expect(response.status).toBe(404); - expect(data.error).toBe("Client not found"); + expect(data.error).toBe("Tenant or client not found"); }); it("should handle database errors", async () => { diff --git a/src/routes/api/tenants/[id]/appointments/my-appointments/+server.ts b/src/routes/api/tenants/[id]/appointments/my-appointments/+server.ts index 5059257..9103b92 100644 --- a/src/routes/api/tenants/[id]/appointments/my-appointments/+server.ts +++ b/src/routes/api/tenants/[id]/appointments/my-appointments/+server.ts @@ -171,7 +171,7 @@ export const GET: RequestHandler = async ({ request, params }) => { tenantId, emailHashPrefix: validatedEmailHash.slice(0, 8), }); - throw new ValidationError("Client not found"); + throw new ValidationError("Tenant or client not found"); } const tunnel = tunnelResult[0]; diff --git a/src/routes/api/tenants/[id]/appointments/my-appointments/__tests__/my-appointments.test.ts b/src/routes/api/tenants/[id]/appointments/my-appointments/__tests__/my-appointments.test.ts index 785a58d..3714c21 100644 --- a/src/routes/api/tenants/[id]/appointments/my-appointments/__tests__/my-appointments.test.ts +++ b/src/routes/api/tenants/[id]/appointments/my-appointments/__tests__/my-appointments.test.ts @@ -182,7 +182,7 @@ describe("GET /api/tenants/[id]/appointments/my-appointments", () => { const data = await response.json(); expect(response.status).toBe(422); - expect(data.error).toBe("Client not found"); + expect(data.error).toBe("Tenant or client not found"); }); it("should return 422 when email hash is empty", async () => { diff --git a/src/routes/api/tenants/[id]/appointments/verify-challenge/+server.ts b/src/routes/api/tenants/[id]/appointments/verify-challenge/+server.ts index ef50f47..eba66e0 100644 --- a/src/routes/api/tenants/[id]/appointments/verify-challenge/+server.ts +++ b/src/routes/api/tenants/[id]/appointments/verify-challenge/+server.ts @@ -187,7 +187,7 @@ export const POST: RequestHandler = async ({ request, params }) => { challengeId, emailHashPrefix: storedChallenge.emailHash.slice(0, 8), }); - throw new NotFoundError("Client not found"); + throw new NotFoundError("Tenant or client not found"); } const tunnel = tunnelResult[0]; diff --git a/src/routes/api/tenants/[id]/clients/pin-reset/complete/+server.ts b/src/routes/api/tenants/[id]/clients/pin-reset/complete/+server.ts index a85c7f3..1e5f713 100644 --- a/src/routes/api/tenants/[id]/clients/pin-reset/complete/+server.ts +++ b/src/routes/api/tenants/[id]/clients/pin-reset/complete/+server.ts @@ -100,7 +100,7 @@ registerOpenAPIRoute("/tenants/{id}/clients/pin-reset/complete", "POST", { }, }, "404": { - description: "Token or client not found", + description: "Tenant or client not found", content: { "application/json": { schema: { $ref: "#/components/schemas/Error" }, diff --git a/src/routes/api/tenants/[id]/clients/pin-reset/init/+server.ts b/src/routes/api/tenants/[id]/clients/pin-reset/init/+server.ts index be2a379..4aefaff 100644 --- a/src/routes/api/tenants/[id]/clients/pin-reset/init/+server.ts +++ b/src/routes/api/tenants/[id]/clients/pin-reset/init/+server.ts @@ -99,7 +99,7 @@ registerOpenAPIRoute("/tenants/{id}/clients/pin-reset/init", "POST", { }, }, "404": { - description: "Client not found", + description: "Tenant or client not found", content: { "application/json": { schema: { $ref: "#/components/schemas/Error" }, diff --git a/src/routes/api/tenants/[id]/clients/pin-reset/init/__tests__/pin-reset-init.test.ts b/src/routes/api/tenants/[id]/clients/pin-reset/init/__tests__/pin-reset-init.test.ts index a92501f..75bf6e1 100644 --- a/src/routes/api/tenants/[id]/clients/pin-reset/init/__tests__/pin-reset-init.test.ts +++ b/src/routes/api/tenants/[id]/clients/pin-reset/init/__tests__/pin-reset-init.test.ts @@ -80,7 +80,7 @@ describe("POST /api/tenants/[id]/clients/pin-reset/init", () => { }); it("should return 404 when client not found", async () => { - mockPinResetService.createResetToken.mockRejectedValue(new Error("Client not found")); + mockPinResetService.createResetToken.mockRejectedValue(new Error("Tenant or client not found")); const request = new Request("http://localhost/api", { method: "POST",