Compare commits
3 Commits
4d13570f0b
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
70f299295d
|
|||
|
e085d4436a
|
|||
|
401c65762b
|
@@ -1,5 +1,7 @@
|
||||
node_modules/
|
||||
dist/
|
||||
bun.lockb
|
||||
bun.lock
|
||||
.env
|
||||
.env.local
|
||||
drizzle/
|
||||
|
||||
@@ -14,16 +14,16 @@ bun run dev
|
||||
|
||||
## Layout
|
||||
|
||||
- `src/db/` — Drizzle schema (`printers`, `farms`, `print_jobs`, `frame_embeddings`)
|
||||
- `src/db/` - Drizzle schema (`printers`, `farms`, `print_jobs`, `frame_embeddings`)
|
||||
and client, pointed at pgCat. `src/db/validators.ts` derives Elysia/TypeBox
|
||||
request validators straight from the Drizzle tables via `drizzle-typebox`,
|
||||
so the Postgres schema and the API validators come from one definition
|
||||
instead of two hand-synced ones.
|
||||
- `src/s3/` — R2 presigned URL helpers (`PUT` for client uploads, `GET` for the
|
||||
- `src/s3/` - R2 presigned URL helpers (`PUT` for client uploads, `GET` for the
|
||||
edge proxy).
|
||||
- `src/queue/` — Redis client + `XADD` helper pushing onto `stream:camera_frames`
|
||||
- `src/queue/` - Redis client + `XADD` helper pushing onto `stream:camera_frames`
|
||||
for `continuum-ai-worker`.
|
||||
- `src/routes/` — `/auth`, `/farms`, `/printers`, `/jobs`, and the edge-gateway
|
||||
- `src/routes/` - `/auth`, `/farms`, `/printers`, `/jobs`, and the edge-gateway
|
||||
WebSocket at `/ws/edge/v1`.
|
||||
|
||||
`frame_embeddings.embedding` requires the `vector` extension:
|
||||
|
||||
+1
-1
@@ -26,7 +26,7 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"drizzle-kit": "^0.24.2",
|
||||
"@types/bun": "^1.1.10",
|
||||
"bun-types": "^1.1.10",
|
||||
"typescript": "^5.6.2"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,14 +2,14 @@ import { createInsertSchema, createSelectSchema } from "drizzle-typebox";
|
||||
import { t } from "elysia";
|
||||
import { printers, printJobs } from "./schema";
|
||||
|
||||
// Generated straight from the Drizzle table definitions in `./schema` — this
|
||||
// Generated straight from the Drizzle table definitions in `./schema` - this
|
||||
// is the *only* place these shapes are defined. The Postgres column and the
|
||||
// Elysia request/response validator can no longer drift apart: change a
|
||||
// column in `./schema/printers.ts` and both the DB migration and the API
|
||||
// validator below pick it up automatically.
|
||||
//
|
||||
// The second argument overrides fields Drizzle can't infer correctly for an
|
||||
// insert — `id` is DB-generated (defaultRandom()) so it must be optional on
|
||||
// insert - `id` is DB-generated (defaultRandom()) so it must be optional on
|
||||
// the way in, even though it's required on the way out.
|
||||
export const PrinterInsertSchema = createInsertSchema(printers, {
|
||||
id: t.Optional(t.String({ format: "uuid" })),
|
||||
|
||||
+2
-2
@@ -14,9 +14,9 @@ const app = new Elysia()
|
||||
.use(cors())
|
||||
.use(swagger({ path: "/docs" }))
|
||||
.get("/health", async () => {
|
||||
const [{ ok }] = await db.execute<{ ok: number }>(sql`select 1 as ok`);
|
||||
const rows = await db.execute<{ ok: number }>(sql`select 1 as ok`);
|
||||
const redisPing = await redis.ping();
|
||||
return { status: "ok", db: ok === 1, redis: redisPing === "PONG" };
|
||||
return { status: "ok", db: rows[0]?.ok === 1, redis: redisPing === "PONG" };
|
||||
})
|
||||
.use(authRoutes)
|
||||
.use(farmRoutes)
|
||||
|
||||
@@ -29,7 +29,7 @@ export const printerRoutes = new Elysia({ prefix: "/printers" })
|
||||
set.status = 201;
|
||||
return printer;
|
||||
},
|
||||
// Derived from `printers` via drizzle-typebox — see src/db/validators.ts.
|
||||
// Derived from `printers` via drizzle-typebox - see src/db/validators.ts.
|
||||
// Add or rename a column in the schema and this validator updates itself.
|
||||
{ body: PrinterInsertSchema },
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user