Feat: Add System Control (Standby Mode) and Resource Monitor

This commit is contained in:
cawcenter
2025-12-14 19:50:05 -05:00
parent f7997cdd88
commit 88d3157cd9
8 changed files with 274 additions and 1 deletions

View File

@@ -0,0 +1,33 @@
import type { APIRoute } from 'astro';
import { system } from '@/lib/system/SystemController';
// GET: Retrieve current metrics and state
export const GET: APIRoute = async () => {
const metrics = await system.getMetrics();
return new Response(JSON.stringify(metrics), {
status: 200,
headers: { 'Content-Type': 'application/json' }
});
};
// POST: Toggle state
export const POST: APIRoute = async ({ request }) => {
try {
const body = await request.json();
if (body.action === 'toggle') {
const newState = system.toggle();
return new Response(JSON.stringify({
success: true,
state: newState,
message: `System is now ${newState.toUpperCase()}`
}));
}
return new Response(JSON.stringify({ error: 'Invalid action' }), { status: 400 });
} catch (e: any) {
return new Response(JSON.stringify({ error: e.message }), { status: 500 });
}
};