34 lines
996 B
TypeScript
34 lines
996 B
TypeScript
import { NextRequest, NextResponse } from 'next/server'
|
|
import { BotLogger } from '@/remote-control/shared/logger'
|
|
|
|
export async function GET(request: NextRequest) {
|
|
const searchParams = request.nextUrl.searchParams
|
|
const limit = parseInt(searchParams.get('limit') || '100')
|
|
const offset = parseInt(searchParams.get('offset') || '0')
|
|
const platform = searchParams.get('platform') as 'discord' | 'dingtalk' | null
|
|
const eventType = searchParams.get('eventType') || null
|
|
const severity = searchParams.get('severity') as 'info' | 'warning' | 'error' | null
|
|
|
|
const { logs, total } = BotLogger.getLogs({
|
|
limit,
|
|
offset,
|
|
platform: platform || undefined,
|
|
eventType: eventType || undefined,
|
|
severity: severity || undefined,
|
|
})
|
|
|
|
return NextResponse.json({
|
|
logs,
|
|
total,
|
|
hasMore: offset + logs.length < total,
|
|
})
|
|
}
|
|
|
|
export async function DELETE() {
|
|
BotLogger.clear()
|
|
return NextResponse.json({
|
|
success: true,
|
|
message: '日志已清空',
|
|
})
|
|
}
|