初始化模版工程
This commit is contained in:
33
app/api/remote-control/logs/route.ts
Normal file
33
app/api/remote-control/logs/route.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
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: '日志已清空',
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user