TypeScript/Bun project scaffold

- Stack: Bun, Hono, Drizzle ORM, Zod, Handlebars, Pino
- Models: ticket, queue, transaction, scrip, template, custom_field, user, lifecycle
- Scrip engine: prepare/commit two-phase dispatch, template rendering, mock actions
- Lifecycle validator: state machine transition validation with wildcard support
- Routes: health, tickets (full CRUD + preview + transactions), queues, scrips, custom-fields, lifecycles
- Middleware: Pino logging, error handler
- Database: Drizzle ORM schema + initial migration (10 tables)
- Type-check: passes (tsc --noEmit, zero errors)
This commit is contained in:
Gjermund Høsøien Wiggen
2026-06-07 21:21:50 +02:00
parent 7be1810162
commit 1136227510
35 changed files with 2595 additions and 0 deletions

36
src/routes/queues.ts Normal file
View File

@@ -0,0 +1,36 @@
import { Hono } from 'hono';
import { HTTPException } from 'hono/http-exception';
import type { Db } from '../db/index.ts';
import { queues } from '../db/schema.ts';
import { asc } from 'drizzle-orm';
import { CreateQueueSchema } from '../models/queue.ts';
export function createQueuesRouter(db: Db): Hono {
const router = new Hono();
router.get('/', async (c) => {
const result = await db.query.queues.findMany({
orderBy: asc(queues.name),
});
return c.json(result);
});
router.post('/', async (c) => {
const body = await c.req.json();
const parsed = CreateQueueSchema.parse(body);
const [queue] = await db.insert(queues).values({
name: parsed.name,
description: parsed.description ?? null,
lifecycle_id: parsed.lifecycle_id ?? null,
}).returning();
if (!queue) {
throw new HTTPException(500, { message: 'Failed to create queue' });
}
return c.json(queue, 201);
});
return router;
}