added to remote repo

This commit is contained in:
Philipp
2026-05-21 08:18:29 +02:00
parent 8697c9f405
commit cc599b6e18
8049 changed files with 1096323 additions and 0 deletions
+32
View File
@@ -0,0 +1,32 @@
import { Router } from 'express';
import { activeJobForVm, latestJobForVm } from '../jobs.js';
import { listIncusVms } from '../validators.js';
export const vmsRouter = Router();
vmsRouter.get('/', async (_req, res, next) => {
try {
const vms = await listIncusVms();
res.json(vms.map((vm) => {
const activeJob = activeJobForVm(vm.name);
const latestJob = latestJobForVm(vm.name);
return {
name: vm.name,
status: vm.status,
activeJob: activeJob ? summarizeJob(activeJob) : null,
lastJobStatus: latestJob?.status || null,
};
}));
} catch (error) {
next(error);
}
});
function summarizeJob(job) {
return {
id: job.id,
type: job.type,
status: job.status,
currentStep: job.currentStep,
};
}