initial commit
This commit is contained in:
21
src/app/api/lxc/route.js
Normal file
21
src/app/api/lxc/route.js
Normal file
@@ -0,0 +1,21 @@
|
||||
import { NextResponse } from 'next/server';
|
||||
import { getNodes, getLXC } from '@/lib/proxmox';
|
||||
|
||||
/** @param {import('next').Request} _req */
|
||||
export async function GET(_req) {
|
||||
try {
|
||||
const nodes = await getNodes();
|
||||
const allLXC = [];
|
||||
|
||||
for (const node of nodes) {
|
||||
try {
|
||||
const lxcs = await getLXC(node.name);
|
||||
allLXC.push(...lxcs.map((lxc) => ({ ...lxc, node: node.name })));
|
||||
} catch { /* skip node */ }
|
||||
}
|
||||
|
||||
return NextResponse.json({ data: allLXC, timestamp: Date.now() });
|
||||
} catch (error) {
|
||||
return NextResponse.json({ error: error.message, data: null }, { status: 502 });
|
||||
}
|
||||
}
|
||||
12
src/app/api/nodes/route.js
Normal file
12
src/app/api/nodes/route.js
Normal file
@@ -0,0 +1,12 @@
|
||||
import { NextResponse } from 'next/server';
|
||||
import { getNodes } from '@/lib/proxmox';
|
||||
|
||||
/** @param {import('next').Request} _req */
|
||||
export async function GET(_req) {
|
||||
try {
|
||||
const data = await getNodes();
|
||||
return NextResponse.json({ data, timestamp: Date.now() });
|
||||
} catch (error) {
|
||||
return NextResponse.json({ error: error.message, data: null }, { status: 502 });
|
||||
}
|
||||
}
|
||||
12
src/app/api/status/route.js
Normal file
12
src/app/api/status/route.js
Normal file
@@ -0,0 +1,12 @@
|
||||
import { NextResponse } from 'next/server';
|
||||
import { getSummary } from '@/lib/proxmox';
|
||||
|
||||
/** @param {import('next').Request} _req */
|
||||
export async function GET(_req) {
|
||||
try {
|
||||
const data = await getSummary();
|
||||
return NextResponse.json({ data, timestamp: Date.now() });
|
||||
} catch (error) {
|
||||
return NextResponse.json({ error: error.message, data: null }, { status: 502 });
|
||||
}
|
||||
}
|
||||
21
src/app/api/vms/route.js
Normal file
21
src/app/api/vms/route.js
Normal file
@@ -0,0 +1,21 @@
|
||||
import { NextResponse } from 'next/server';
|
||||
import { getNodes, getVMs } from '@/lib/proxmox';
|
||||
|
||||
/** @param {import('next').Request} _req */
|
||||
export async function GET(_req) {
|
||||
try {
|
||||
const nodes = await getNodes();
|
||||
const allVMs = [];
|
||||
|
||||
for (const node of nodes) {
|
||||
try {
|
||||
const vms = await getVMs(node.name);
|
||||
allVMs.push(...vms.map((vm) => ({ ...vm, node: node.name })));
|
||||
} catch { /* skip node */ }
|
||||
}
|
||||
|
||||
return NextResponse.json({ data: allVMs, timestamp: Date.now() });
|
||||
} catch (error) {
|
||||
return NextResponse.json({ error: error.message, data: null }, { status: 502 });
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user