fix(broker): accept pubkey in mesh create + use in member row
Some checks failed
CI / Lint (push) Has been cancelled
CI / Typecheck (push) Has been cancelled
CI / Broker tests (Postgres) (push) Has been cancelled
CI / Docker build (linux/amd64) (push) Has been cancelled

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Alejandro Gutiérrez
2026-04-13 19:02:09 +01:00
parent 0d53f2ae52
commit 4561076904

View File

@@ -5031,7 +5031,7 @@ import { meshPermission } from "@turbostarter/db/schema/mesh";
/** POST /cli/mesh/create — create a new mesh via CLI. */
async function handleCliMeshCreate(req: IncomingMessage, res: ServerResponse, started: number): Promise<void> {
let body: { user_id: string; name: string; slug?: string; template?: string; description?: string };
let body: { user_id: string; name: string; pubkey?: string; slug?: string; template?: string; description?: string };
try {
const chunks: Buffer[] = [];
for await (const chunk of req) chunks.push(chunk as Buffer);
@@ -5073,9 +5073,10 @@ async function handleCliMeshCreate(req: IncomingMessage, res: ServerResponse, st
// Create owner member
const memberId = generateId();
const peerPubkey = body.pubkey ?? "pending";
await db.execute(sql`
INSERT INTO mesh.member (id, mesh_id, user_id, peer_pubkey, display_name, role)
VALUES (${memberId}, ${meshId}, ${body.user_id}, ${"pending"}, ${body.name + "-owner"}, ${"admin"})
VALUES (${memberId}, ${meshId}, ${body.user_id}, ${peerPubkey}, ${body.name + "-owner"}, ${"admin"})
`);
writeJson(res, 200, { id: meshId, slug, name: body.name, member_id: memberId });