14 lines
944 B
TypeScript
14 lines
944 B
TypeScript
import { Body, Controller, Get, Header, Param, ParseUUIDPipe, Post, Req, UseGuards } from '@nestjs/common';
|
|
import { Throttle } from '@nestjs/throttler';
|
|
import { SupportChatService } from './support-chat.service';
|
|
import { SupportChatDto } from './support-chat.dto';
|
|
import { OptionalCustomerJwtGuard } from './support-chat.guard';
|
|
@Controller('support-chat')
|
|
export class SupportChatController {
|
|
constructor(private readonly service: SupportChatService) {}
|
|
@Get(':id') @UseGuards(OptionalCustomerJwtGuard) @Header('Cache-Control', 'no-store')
|
|
history(@Param('id', ParseUUIDPipe) id: string, @Req() req: { user?: { id: string } }) { return this.service.history(id, req.user); }
|
|
@Post('ask') @UseGuards(OptionalCustomerJwtGuard) @Throttle({ default: { limit: 10, ttl: 60000 } }) @Header('Cache-Control', 'no-store')
|
|
ask(@Body() dto: SupportChatDto, @Req() req: { user?: { id: string } }) { return this.service.ask(dto, req.user); }
|
|
}
|