Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 8c184dddbd |
@@ -91,12 +91,10 @@ jobs:
|
|||||||
- name: Build and push API image
|
- name: Build and push API image
|
||||||
uses: docker/build-push-action@v6
|
uses: docker/build-push-action@v6
|
||||||
with:
|
with:
|
||||||
provenance: false
|
|
||||||
context: .
|
context: .
|
||||||
file: Dockerfile
|
file: Dockerfile
|
||||||
target: runner
|
target: runner
|
||||||
push: true
|
push: true
|
||||||
provenance: false
|
|
||||||
tags: |
|
tags: |
|
||||||
git.farh.net/groombook/api:${{ steps.version.outputs.tag }}
|
git.farh.net/groombook/api:${{ steps.version.outputs.tag }}
|
||||||
${{ github.ref == 'refs/heads/main' && 'git.farh.net/groombook/api:latest' || '' }}
|
${{ github.ref == 'refs/heads/main' && 'git.farh.net/groombook/api:latest' || '' }}
|
||||||
@@ -106,12 +104,10 @@ jobs:
|
|||||||
- name: Build and push Migrate image
|
- name: Build and push Migrate image
|
||||||
uses: docker/build-push-action@v6
|
uses: docker/build-push-action@v6
|
||||||
with:
|
with:
|
||||||
provenance: false
|
|
||||||
context: .
|
context: .
|
||||||
file: Dockerfile
|
file: Dockerfile
|
||||||
target: migrate
|
target: migrate
|
||||||
push: true
|
push: true
|
||||||
provenance: false
|
|
||||||
tags: |
|
tags: |
|
||||||
git.farh.net/groombook/migrate:${{ steps.version.outputs.tag }}
|
git.farh.net/groombook/migrate:${{ steps.version.outputs.tag }}
|
||||||
${{ github.ref == 'refs/heads/main' && 'git.farh.net/groombook/migrate:latest' || '' }}
|
${{ github.ref == 'refs/heads/main' && 'git.farh.net/groombook/migrate:latest' || '' }}
|
||||||
@@ -121,12 +117,10 @@ jobs:
|
|||||||
- name: Build and push Seed image
|
- name: Build and push Seed image
|
||||||
uses: docker/build-push-action@v6
|
uses: docker/build-push-action@v6
|
||||||
with:
|
with:
|
||||||
provenance: false
|
|
||||||
context: .
|
context: .
|
||||||
file: Dockerfile
|
file: Dockerfile
|
||||||
target: seed
|
target: seed
|
||||||
push: true
|
push: true
|
||||||
provenance: false
|
|
||||||
tags: |
|
tags: |
|
||||||
git.farh.net/groombook/seed:${{ steps.version.outputs.tag }}
|
git.farh.net/groombook/seed:${{ steps.version.outputs.tag }}
|
||||||
${{ github.ref == 'refs/heads/main' && 'git.farh.net/groombook/seed:latest' || '' }}
|
${{ github.ref == 'refs/heads/main' && 'git.farh.net/groombook/seed:latest' || '' }}
|
||||||
@@ -136,12 +130,10 @@ jobs:
|
|||||||
- name: Build and push Reset image
|
- name: Build and push Reset image
|
||||||
uses: docker/build-push-action@v6
|
uses: docker/build-push-action@v6
|
||||||
with:
|
with:
|
||||||
provenance: false
|
|
||||||
context: .
|
context: .
|
||||||
file: Dockerfile
|
file: Dockerfile
|
||||||
target: reset
|
target: reset
|
||||||
push: true
|
push: true
|
||||||
provenance: false
|
|
||||||
tags: |
|
tags: |
|
||||||
git.farh.net/groombook/reset:${{ steps.version.outputs.tag }}
|
git.farh.net/groombook/reset:${{ steps.version.outputs.tag }}
|
||||||
${{ github.ref == 'refs/heads/main' && 'git.farh.net/groombook/reset:latest' || '' }}
|
${{ github.ref == 'refs/heads/main' && 'git.farh.net/groombook/reset:latest' || '' }}
|
||||||
|
|||||||
@@ -36,19 +36,6 @@ const DEMO_PET = {
|
|||||||
weightKg: "30.00",
|
weightKg: "30.00",
|
||||||
};
|
};
|
||||||
|
|
||||||
const UAT_CLIENT = {
|
|
||||||
name: "UAT Customer",
|
|
||||||
email: "uat-customer@groombook.dev",
|
|
||||||
phone: "555-0100",
|
|
||||||
address: "1 UAT Lane, Test City, CA 90210",
|
|
||||||
status: "active" as const,
|
|
||||||
};
|
|
||||||
|
|
||||||
const UAT_PETS = [
|
|
||||||
{ name: "Bella", species: "Dog", breed: "Poodle", coatType: "curly" as const, weightKg: "20.00" },
|
|
||||||
{ name: "Max", species: "Dog", breed: "Labrador Retriever", coatType: "short" as const, weightKg: "30.00" },
|
|
||||||
];
|
|
||||||
|
|
||||||
const DEMO_SERVICES = [
|
const DEMO_SERVICES = [
|
||||||
{ id: "b0000001-0000-0000-0000-000000000001", name: "Bath & Brush", description: "Full bath, blow-dry, brush out, and ear cleaning", basePriceCents: 4500, durationMinutes: 45 },
|
{ id: "b0000001-0000-0000-0000-000000000001", name: "Bath & Brush", description: "Full bath, blow-dry, brush out, and ear cleaning", basePriceCents: 4500, durationMinutes: 45 },
|
||||||
{ id: "b0000001-0000-0000-0000-000000000002", name: "Full Groom — Small", description: "Complete grooming for dogs under 25 lbs", basePriceCents: 6500, durationMinutes: 60 },
|
{ id: "b0000001-0000-0000-0000-000000000002", name: "Full Groom — Small", description: "Complete grooming for dogs under 25 lbs", basePriceCents: 6500, durationMinutes: 60 },
|
||||||
@@ -56,7 +43,7 @@ const DEMO_SERVICES = [
|
|||||||
{ id: "b0000001-0000-0000-0000-000000000004", name: "Nail Trim", description: "Nail clipping and filing", basePriceCents: 1500, durationMinutes: 15 },
|
{ id: "b0000001-0000-0000-0000-000000000004", name: "Nail Trim", description: "Nail clipping and filing", basePriceCents: 1500, durationMinutes: 15 },
|
||||||
];
|
];
|
||||||
|
|
||||||
adminSeedRouter.post("/", async (c) => {
|
adminSeedRouter.post("/seed", async (c) => {
|
||||||
// Refuse to run when AUTH_DISABLED — dev environments use direct-DB seeding
|
// Refuse to run when AUTH_DISABLED — dev environments use direct-DB seeding
|
||||||
if (process.env.AUTH_DISABLED === "true") {
|
if (process.env.AUTH_DISABLED === "true") {
|
||||||
return c.json(
|
return c.json(
|
||||||
@@ -141,51 +128,6 @@ adminSeedRouter.post("/", async (c) => {
|
|||||||
results.push(`Created pet '${DEMO_PET.name}' for Demo Client (id: ${created!.id})`);
|
results.push(`Created pet '${DEMO_PET.name}' for Demo Client (id: ${created!.id})`);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ── Client: UAT Customer ──────────────────────────────────────────────────
|
|
||||||
const [existingUatClient] = await db
|
|
||||||
.select()
|
|
||||||
.from(clients)
|
|
||||||
.where(eq(clients.email, UAT_CLIENT.email));
|
|
||||||
|
|
||||||
let uatClientId: string;
|
|
||||||
if (existingUatClient) {
|
|
||||||
uatClientId = existingUatClient.id;
|
|
||||||
results.push(`Client '${UAT_CLIENT.name}' already exists (id: ${uatClientId})`);
|
|
||||||
} else {
|
|
||||||
const [created] = await db.insert(clients).values(UAT_CLIENT).returning();
|
|
||||||
uatClientId = created!.id;
|
|
||||||
results.push(`Created client '${UAT_CLIENT.name}' (id: ${uatClientId})`);
|
|
||||||
}
|
|
||||||
|
|
||||||
// ── Pets: UAT Customer's Pets ─────────────────────────────────────────────
|
|
||||||
const existingUatPets = await db
|
|
||||||
.select()
|
|
||||||
.from(pets)
|
|
||||||
.where(eq(pets.clientId, uatClientId));
|
|
||||||
|
|
||||||
for (const uatPet of UAT_PETS) {
|
|
||||||
const existingPet = existingUatPets.find(
|
|
||||||
(p) => p.name === uatPet.name && p.species === uatPet.species
|
|
||||||
);
|
|
||||||
if (existingPet) {
|
|
||||||
results.push(`Pet '${uatPet.name}' already exists for UAT Customer (id: ${existingPet.id})`);
|
|
||||||
} else {
|
|
||||||
const [created] = await db
|
|
||||||
.insert(pets)
|
|
||||||
.values({
|
|
||||||
clientId: uatClientId,
|
|
||||||
name: uatPet.name,
|
|
||||||
species: uatPet.species,
|
|
||||||
breed: uatPet.breed,
|
|
||||||
coatType: uatPet.coatType,
|
|
||||||
weightKg: uatPet.weightKg,
|
|
||||||
dateOfBirth: new Date("2019-01-01T00:00:00Z"),
|
|
||||||
})
|
|
||||||
.returning();
|
|
||||||
results.push(`Created pet '${uatPet.name}' for UAT Customer (id: ${created!.id})`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return c.json({
|
return c.json({
|
||||||
message: "Seed complete",
|
message: "Seed complete",
|
||||||
details: results,
|
details: results,
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ export function getDb() {
|
|||||||
if (_db) return _db;
|
if (_db) return _db;
|
||||||
const url = process.env.DATABASE_URL;
|
const url = process.env.DATABASE_URL;
|
||||||
if (!url) throw new Error("DATABASE_URL is not set");
|
if (!url) throw new Error("DATABASE_URL is not set");
|
||||||
const client = postgres(url, { max: 10, connect_timeout: 5 });
|
const client = postgres(url, { max: 10 });
|
||||||
_db = drizzle(client, { schema });
|
_db = drizzle(client, { schema });
|
||||||
return _db;
|
return _db;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import {
|
|||||||
unique,
|
unique,
|
||||||
uuid,
|
uuid,
|
||||||
} from "drizzle-orm/pg-core";
|
} from "drizzle-orm/pg-core";
|
||||||
|
import type { MedicalAlert } from "@groombook/types";
|
||||||
|
|
||||||
// ─── Enums ────────────────────────────────────────────────────────────────────
|
// ─── Enums ────────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
@@ -164,6 +165,10 @@ export const pets = pgTable(
|
|||||||
specialCareNotes: text("special_care_notes"),
|
specialCareNotes: text("special_care_notes"),
|
||||||
coatType: coatTypeEnum("coat_type"),
|
coatType: coatTypeEnum("coat_type"),
|
||||||
petSizeCategory: petSizeCategoryEnum("pet_size_category"),
|
petSizeCategory: petSizeCategoryEnum("pet_size_category"),
|
||||||
|
temperamentScore: integer("temperament_score"),
|
||||||
|
temperamentFlags: jsonb("temperament_flags").$type<string[]>().default([]),
|
||||||
|
medicalAlerts: jsonb("medical_alerts").$type<MedicalAlert[]>().default([]),
|
||||||
|
preferredCuts: jsonb("preferred_cuts").$type<string[]>().default([]),
|
||||||
customFields: jsonb("custom_fields").$type<Record<string, string>>().notNull().default({}),
|
customFields: jsonb("custom_fields").$type<Record<string, string>>().notNull().default({}),
|
||||||
photoKey: text("photo_key"),
|
photoKey: text("photo_key"),
|
||||||
photoUploadedAt: timestamp("photo_uploaded_at"),
|
photoUploadedAt: timestamp("photo_uploaded_at"),
|
||||||
|
|||||||
+4
-9
@@ -59,9 +59,6 @@ app.use(
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Health check — no auth required, registered on app at full path before auth middleware
|
// Health check — no auth required, registered on app at full path before auth middleware
|
||||||
// /health: used by Dockerfile HEALTHCHECK and K8s readinessProbe/livenessProbe (port 3000 direct)
|
|
||||||
app.get("/health", (c) => c.json({ status: "ok" }));
|
|
||||||
// /api/health: used by Gateway HTTPRoute (/api/* → API pod)
|
|
||||||
app.get("/api/health", (c) => c.json({ status: "ok" }));
|
app.get("/api/health", (c) => c.json({ status: "ok" }));
|
||||||
|
|
||||||
// Public booking routes — no auth required, must be registered before auth middleware
|
// Public booking routes — no auth required, must be registered before auth middleware
|
||||||
@@ -285,16 +282,14 @@ startReminderScheduler();
|
|||||||
|
|
||||||
function shutdown() {
|
function shutdown() {
|
||||||
console.log("Shutting down gracefully...");
|
console.log("Shutting down gracefully...");
|
||||||
// SIGTERM/SIGINT → server.close() → callback → process.exit(0)
|
|
||||||
// If graceful close takes >8s, force-exit to avoid being killed undrained
|
|
||||||
setTimeout(() => {
|
|
||||||
console.error("Graceful close timeout — forcing exit");
|
|
||||||
process.exit(1);
|
|
||||||
}, 8_000);
|
|
||||||
server.close(() => {
|
server.close(() => {
|
||||||
console.log("HTTP server closed");
|
console.log("HTTP server closed");
|
||||||
process.exit(0);
|
process.exit(0);
|
||||||
});
|
});
|
||||||
|
setTimeout(() => {
|
||||||
|
console.error("Forced shutdown after timeout");
|
||||||
|
process.exit(1);
|
||||||
|
}, 10_000);
|
||||||
}
|
}
|
||||||
|
|
||||||
process.on("SIGTERM", shutdown);
|
process.on("SIGTERM", shutdown);
|
||||||
|
|||||||
+1
-3
@@ -186,9 +186,7 @@ export async function initAuth(): Promise<void> {
|
|||||||
const discoveryUrlStr = `${providerConfig.issuerUrl}/.well-known/openid-configuration`;
|
const discoveryUrlStr = `${providerConfig.issuerUrl}/.well-known/openid-configuration`;
|
||||||
let oidcConfig: Record<string, string> = {};
|
let oidcConfig: Record<string, string> = {};
|
||||||
try {
|
try {
|
||||||
const discoveryRes = await fetch(discoveryUrlStr, {
|
const discoveryRes = await fetch(discoveryUrlStr);
|
||||||
signal: AbortSignal.timeout(5000),
|
|
||||||
});
|
|
||||||
if (discoveryRes.ok) {
|
if (discoveryRes.ok) {
|
||||||
const discovery = await discoveryRes.json() as {
|
const discovery = await discoveryRes.json() as {
|
||||||
authorization_endpoint?: string;
|
authorization_endpoint?: string;
|
||||||
|
|||||||
@@ -36,19 +36,6 @@ const DEMO_PET = {
|
|||||||
weightKg: "30.00",
|
weightKg: "30.00",
|
||||||
};
|
};
|
||||||
|
|
||||||
const UAT_CLIENT = {
|
|
||||||
name: "UAT Customer",
|
|
||||||
email: "uat-customer@groombook.dev",
|
|
||||||
phone: "555-0100",
|
|
||||||
address: "1 UAT Lane, Test City, CA 90210",
|
|
||||||
status: "active" as const,
|
|
||||||
};
|
|
||||||
|
|
||||||
const UAT_PETS = [
|
|
||||||
{ name: "Bella", species: "Dog", breed: "Poodle", coatType: "curly", weightKg: "20.00" },
|
|
||||||
{ name: "Max", species: "Dog", breed: "Labrador Retriever", coatType: "short", weightKg: "30.00" },
|
|
||||||
];
|
|
||||||
|
|
||||||
const DEMO_SERVICES = [
|
const DEMO_SERVICES = [
|
||||||
{ id: "b0000001-0000-0000-0000-000000000001", name: "Bath & Brush", description: "Full bath, blow-dry, brush out, and ear cleaning", basePriceCents: 4500, durationMinutes: 45 },
|
{ id: "b0000001-0000-0000-0000-000000000001", name: "Bath & Brush", description: "Full bath, blow-dry, brush out, and ear cleaning", basePriceCents: 4500, durationMinutes: 45 },
|
||||||
{ id: "b0000001-0000-0000-0000-000000000002", name: "Full Groom — Small", description: "Complete grooming for dogs under 25 lbs", basePriceCents: 6500, durationMinutes: 60 },
|
{ id: "b0000001-0000-0000-0000-000000000002", name: "Full Groom — Small", description: "Complete grooming for dogs under 25 lbs", basePriceCents: 6500, durationMinutes: 60 },
|
||||||
@@ -56,7 +43,7 @@ const DEMO_SERVICES = [
|
|||||||
{ id: "b0000001-0000-0000-0000-000000000004", name: "Nail Trim", description: "Nail clipping and filing", basePriceCents: 1500, durationMinutes: 15 },
|
{ id: "b0000001-0000-0000-0000-000000000004", name: "Nail Trim", description: "Nail clipping and filing", basePriceCents: 1500, durationMinutes: 15 },
|
||||||
];
|
];
|
||||||
|
|
||||||
adminSeedRouter.post("/", async (c) => {
|
adminSeedRouter.post("/seed", async (c) => {
|
||||||
// Refuse to run when AUTH_DISABLED — dev environments use direct-DB seeding
|
// Refuse to run when AUTH_DISABLED — dev environments use direct-DB seeding
|
||||||
if (process.env.AUTH_DISABLED === "true") {
|
if (process.env.AUTH_DISABLED === "true") {
|
||||||
return c.json(
|
return c.json(
|
||||||
@@ -141,51 +128,6 @@ adminSeedRouter.post("/", async (c) => {
|
|||||||
results.push(`Created pet '${DEMO_PET.name}' for Demo Client (id: ${created!.id})`);
|
results.push(`Created pet '${DEMO_PET.name}' for Demo Client (id: ${created!.id})`);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ── Client: UAT Customer ──────────────────────────────────────────────────
|
|
||||||
const [existingUatClient] = await db
|
|
||||||
.select()
|
|
||||||
.from(clients)
|
|
||||||
.where(eq(clients.email, UAT_CLIENT.email));
|
|
||||||
|
|
||||||
let uatClientId: string;
|
|
||||||
if (existingUatClient) {
|
|
||||||
uatClientId = existingUatClient.id;
|
|
||||||
results.push(`Client '${UAT_CLIENT.name}' already exists (id: ${uatClientId})`);
|
|
||||||
} else {
|
|
||||||
const [created] = await db.insert(clients).values(UAT_CLIENT).returning();
|
|
||||||
uatClientId = created!.id;
|
|
||||||
results.push(`Created client '${UAT_CLIENT.name}' (id: ${uatClientId})`);
|
|
||||||
}
|
|
||||||
|
|
||||||
// ── Pets: UAT Customer's Pets ─────────────────────────────────────────────
|
|
||||||
const existingUatPets = await db
|
|
||||||
.select()
|
|
||||||
.from(pets)
|
|
||||||
.where(eq(pets.clientId, uatClientId));
|
|
||||||
|
|
||||||
for (const uatPet of UAT_PETS) {
|
|
||||||
const existing = existingUatPets.find(
|
|
||||||
(p) => p.name === uatPet.name && p.species === uatPet.species
|
|
||||||
);
|
|
||||||
if (existing) {
|
|
||||||
results.push(`Pet '${uatPet.name}' already exists for UAT Customer (id: ${existing.id})`);
|
|
||||||
} else {
|
|
||||||
const [created] = await db
|
|
||||||
.insert(pets)
|
|
||||||
.values({
|
|
||||||
clientId: uatClientId,
|
|
||||||
name: uatPet.name,
|
|
||||||
species: uatPet.species,
|
|
||||||
breed: uatPet.breed,
|
|
||||||
coatType: uatPet.coatType as any,
|
|
||||||
weightKg: uatPet.weightKg,
|
|
||||||
dateOfBirth: new Date("2019-01-01T00:00:00Z"),
|
|
||||||
})
|
|
||||||
.returning();
|
|
||||||
results.push(`Created pet '${uatPet.name}' for UAT Customer (id: ${created!.id})`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return c.json({
|
return c.json({
|
||||||
message: "Seed complete",
|
message: "Seed complete",
|
||||||
details: results,
|
details: results,
|
||||||
|
|||||||
Reference in New Issue
Block a user