Initial boilerplate scaffold for continuum-backend
Bun + ElysiaJS control plane: Drizzle/Postgres schema (printers, farms, print_jobs, pgvector frame_embeddings), R2 presigned URLs, Redis Streams frame ingestion queue, REST routes, and the /ws/edge/v1 edge-gateway WebSocket uplink.
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
import { Elysia, t } from "elysia";
|
||||
import { eq } from "drizzle-orm";
|
||||
import { db } from "../db";
|
||||
import { farms } from "../db/schema";
|
||||
|
||||
export const farmRoutes = new Elysia({ prefix: "/farms" })
|
||||
.get("/", async () => db.select().from(farms))
|
||||
.get("/:id", async ({ params, set }) => {
|
||||
const farm = await db.query.farms.findFirst({ where: eq(farms.id, params.id) });
|
||||
if (!farm) {
|
||||
set.status = 404;
|
||||
return { error: { code: "NOT_FOUND", message: `Farm ${params.id} not found` } };
|
||||
}
|
||||
return farm;
|
||||
})
|
||||
.post(
|
||||
"/",
|
||||
async ({ body, set }) => {
|
||||
const [farm] = await db
|
||||
.insert(farms)
|
||||
.values({
|
||||
name: body.name,
|
||||
ownerId: body.ownerId,
|
||||
edgeProxyToken: crypto.randomUUID(),
|
||||
location: body.location,
|
||||
})
|
||||
.returning();
|
||||
set.status = 201;
|
||||
return farm;
|
||||
},
|
||||
{
|
||||
body: t.Object({
|
||||
name: t.String({ minLength: 1 }),
|
||||
ownerId: t.String({ format: "uuid" }),
|
||||
location: t.Optional(t.String()),
|
||||
}),
|
||||
},
|
||||
);
|
||||
Reference in New Issue
Block a user