Format the repository with Prettier
CI has been running `prettier --check` against a tree that was never formatted, so the check reported 63 files and failed every run. Nothing here is a behaviour change: `pnpm lint` and the four typecheck builds pass exactly as before. conduit-bringup-artifacts is added to .prettierignore instead. Those files are captured bring-up reports, not maintained sources; reflowing them would only churn a record of what happened.
This commit is contained in:
@@ -23,9 +23,7 @@ export default async function daemonNodeRoutes(app: FastifyInstance) {
|
||||
// POST /api/nodes/heartbeat
|
||||
app.post('/heartbeat', { schema: HeartbeatSchema }, async (request) => {
|
||||
const token = extractBearerToken(
|
||||
typeof request.headers.authorization === 'string'
|
||||
? request.headers.authorization
|
||||
: undefined,
|
||||
typeof request.headers.authorization === 'string' ? request.headers.authorization : undefined,
|
||||
);
|
||||
|
||||
if (!token) {
|
||||
|
||||
@@ -94,28 +94,32 @@ export default async function nodeRoutes(app: FastifyInstance) {
|
||||
});
|
||||
|
||||
// PATCH /api/organizations/:orgId/nodes/:nodeId
|
||||
app.patch('/:nodeId', { schema: { ...NodeParamSchema, ...UpdateNodeSchema } }, async (request) => {
|
||||
const { orgId, nodeId } = request.params as { orgId: string; nodeId: string };
|
||||
await requirePermission(request, orgId, 'node.manage');
|
||||
app.patch(
|
||||
'/:nodeId',
|
||||
{ schema: { ...NodeParamSchema, ...UpdateNodeSchema } },
|
||||
async (request) => {
|
||||
const { orgId, nodeId } = request.params as { orgId: string; nodeId: string };
|
||||
await requirePermission(request, orgId, 'node.manage');
|
||||
|
||||
const body = request.body as Record<string, unknown>;
|
||||
const body = request.body as Record<string, unknown>;
|
||||
|
||||
const [updated] = await app.db
|
||||
.update(nodes)
|
||||
.set({ ...body, updatedAt: new Date() })
|
||||
.where(and(eq(nodes.id, nodeId), eq(nodes.organizationId, orgId)))
|
||||
.returning();
|
||||
const [updated] = await app.db
|
||||
.update(nodes)
|
||||
.set({ ...body, updatedAt: new Date() })
|
||||
.where(and(eq(nodes.id, nodeId), eq(nodes.organizationId, orgId)))
|
||||
.returning();
|
||||
|
||||
if (!updated) throw AppError.notFound('Node not found');
|
||||
if (!updated) throw AppError.notFound('Node not found');
|
||||
|
||||
await createAuditLog(app.db, request, {
|
||||
organizationId: orgId,
|
||||
action: 'node.update',
|
||||
metadata: { nodeId, ...body },
|
||||
});
|
||||
await createAuditLog(app.db, request, {
|
||||
organizationId: orgId,
|
||||
action: 'node.update',
|
||||
metadata: { nodeId, ...body },
|
||||
});
|
||||
|
||||
return updated;
|
||||
});
|
||||
return updated;
|
||||
},
|
||||
);
|
||||
|
||||
// DELETE /api/organizations/:orgId/nodes/:nodeId
|
||||
app.delete('/:nodeId', { schema: NodeParamSchema }, async (request, reply) => {
|
||||
@@ -244,30 +248,34 @@ export default async function nodeRoutes(app: FastifyInstance) {
|
||||
});
|
||||
|
||||
// POST /api/organizations/:orgId/nodes/:nodeId/allocations
|
||||
app.post('/:nodeId/allocations', { schema: { ...NodeParamSchema, ...CreateAllocationSchema } }, async (request, reply) => {
|
||||
const { orgId, nodeId } = request.params as { orgId: string; nodeId: string };
|
||||
await requirePermission(request, orgId, 'node.manage');
|
||||
app.post(
|
||||
'/:nodeId/allocations',
|
||||
{ schema: { ...NodeParamSchema, ...CreateAllocationSchema } },
|
||||
async (request, reply) => {
|
||||
const { orgId, nodeId } = request.params as { orgId: string; nodeId: string };
|
||||
await requirePermission(request, orgId, 'node.manage');
|
||||
|
||||
const { ip, ports } = request.body as { ip: string; ports: number[] };
|
||||
const { ip, ports } = request.body as { ip: string; ports: number[] };
|
||||
|
||||
const values = ports.map((port) => ({
|
||||
nodeId,
|
||||
ip,
|
||||
port,
|
||||
}));
|
||||
const values = ports.map((port) => ({
|
||||
nodeId,
|
||||
ip,
|
||||
port,
|
||||
}));
|
||||
|
||||
const created = await app.db
|
||||
.insert(allocations)
|
||||
.values(values)
|
||||
.onConflictDoNothing()
|
||||
.returning();
|
||||
const created = await app.db
|
||||
.insert(allocations)
|
||||
.values(values)
|
||||
.onConflictDoNothing()
|
||||
.returning();
|
||||
|
||||
await createAuditLog(app.db, request, {
|
||||
organizationId: orgId,
|
||||
action: 'allocation.create',
|
||||
metadata: { nodeId, ip, ports },
|
||||
});
|
||||
await createAuditLog(app.db, request, {
|
||||
organizationId: orgId,
|
||||
action: 'allocation.create',
|
||||
metadata: { nodeId, ip, ports },
|
||||
});
|
||||
|
||||
return reply.code(201).send({ data: created });
|
||||
});
|
||||
return reply.code(201).send({ data: created });
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user