26 lines
975 B
TypeScript
26 lines
975 B
TypeScript
import { Body, Controller, Headers, Post, UseGuards } from '@nestjs/common';
|
|
import { OptionalJwtAuthGuard } from '../../common/guards/optional-jwt-auth.guard';
|
|
import { CurrentUser } from '../../common/decorators/current-user.decorator';
|
|
import type { AuthUser } from '../../common/guards/jwt-auth.guard';
|
|
import { ClientErrorService } from './client-error.service';
|
|
import { ReportClientErrorDto } from './dto/client-error.dto';
|
|
|
|
@Controller('common')
|
|
export class ClientErrorController {
|
|
constructor(private readonly clientErrors: ClientErrorService) {}
|
|
|
|
/**
|
|
* 客户端报错上报(可匿名)。
|
|
* fatal/error → Nest 日志 + 落库 + 企微;warn → 仅日志/落库。
|
|
*/
|
|
@Post('client-errors')
|
|
@UseGuards(OptionalJwtAuthGuard)
|
|
report(
|
|
@Body() dto: ReportClientErrorDto,
|
|
@CurrentUser() user: AuthUser | undefined,
|
|
@Headers('x-client-app') clientApp?: string,
|
|
) {
|
|
return this.clientErrors.report(dto, user, clientApp);
|
|
}
|
|
}
|