Spaces:
Sleeping
Sleeping
File size: 1,936 Bytes
9ffaa46 d8ea863 9ffaa46 2f666f7 9ffaa46 d8ea863 9ffaa46 | 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 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 | import {
Controller,
Post,
Get,
Body,
UseGuards,
Req,
HttpCode,
HttpStatus,
Param,
} from '@nestjs/common';
import {
ApiTags,
ApiBearerAuth,
ApiOperation,
ApiOkResponse,
ApiUnauthorizedResponse,
} from '@nestjs/swagger';
import { JwtAuthGuard } from '../auth/jwt-auth.guard';
import { AuthenticatedRequest } from '../../common/interfaces/authenticated-request.interface';
import { DocumentGenerationService } from './document-generation.service';
import { GenerateDocumentDto } from './dto/generate-document.dto';
@ApiTags('Document Generation')
@ApiBearerAuth()
@ApiUnauthorizedResponse({ description: 'Missing or invalid JWT token' })
@Controller('document-generation')
@UseGuards(JwtAuthGuard)
export class DocumentGenerationController {
constructor(private readonly service: DocumentGenerationService) {}
@Post('generate')
@HttpCode(HttpStatus.OK)
@ApiOperation({
summary: 'Generate a document (cover letter, email, or personal statement)',
description: 'Returns the generated document content along with a documentId for retrieval.',
})
@ApiOkResponse({
description: 'Document generated successfully',
schema: {
example: {
documentId: 'uuid',
title: 'Cover Letter: Acme Corp',
content: 'Dear Hiring Manager...',
},
},
})
async generate(
@Req() req: AuthenticatedRequest,
@Body() dto: GenerateDocumentDto,
) {
return this.service.generate(req.user.id, dto);
}
@Get('history')
@ApiOperation({ summary: 'Get the current user past generated documents' })
async history(@Req() req: AuthenticatedRequest) {
return this.service.getHistory(req.user.id);
}
@Get(':id')
@ApiOperation({ summary: 'Get details of a specific generated document' })
async getDocument(
@Req() req: AuthenticatedRequest,
@Param('id') id: string,
) {
return this.service.getDocumentDetail(req.user.id, id);
}
}
|