-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserverLogs.ts
More file actions
29 lines (25 loc) · 781 Bytes
/
Copy pathserverLogs.ts
File metadata and controls
29 lines (25 loc) · 781 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import { Manager } from '@/manager';
export async function GET(request: Request): Promise<Response> {
const url = new URL(request.url);
const serverName = url.searchParams.get('serverName') || '';
const lines = Number(url.searchParams.get('lines') || '120');
if (!serverName) {
return Response.json(
{ status: 'error', message: 'Missing serverName' },
{ status: 400 },
);
}
try {
const data = await Manager.readServerLogs(serverName, lines);
return Response.json({ status: 'ok', data }, { status: 200 });
} catch (error) {
console.error('Failed to read server logs:', error);
return Response.json(
{ status: 'error', message: 'Failed to read server logs' },
{ status: 500 },
);
}
}
export default {
GET,
};