Skip to content

Commit 8f5d5ae

Browse files
committed
revert: restore /gateway/restart backward-compat route (accidentally included)
1 parent 8ffc63a commit 8f5d5ae

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

kiloclaw/src/routes/api.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,32 @@ adminApi.post('/machine/restart', async c => {
6262
}
6363
});
6464

65+
// TODO: Remove after frontend rollout to /api/admin/machine/restart
66+
// POST /api/admin/gateway/restart - Backward-compat alias for machine restart
67+
adminApi.post('/gateway/restart', async c => {
68+
const stub = resolveStub(c);
69+
const body = (await c.req.json().catch(() => ({}))) as Record<string, unknown>;
70+
const rawTag = typeof body.imageTag === 'string' ? body.imageTag : undefined;
71+
72+
if (rawTag && !isValidImageTag(rawTag)) {
73+
return c.json({ success: false, error: 'Invalid image tag format' }, 400);
74+
}
75+
76+
const imageTag = rawTag;
77+
const result = await stub.restartMachine(imageTag ? { imageTag } : undefined);
78+
79+
if (result.success) {
80+
return c.json({
81+
success: true,
82+
message: imageTag
83+
? `Machine restarting with image tag: ${imageTag}...`
84+
: 'Machine restarting with updated configuration...',
85+
});
86+
} else {
87+
return c.json({ success: false, error: result.error }, 500);
88+
}
89+
});
90+
6591
// Mount admin API routes under /admin
6692
api.route('/admin', adminApi);
6793

0 commit comments

Comments
 (0)