11// @ts -nocheck
22
3- import { Body , Controller , Get , Param , Post , Query , Res , UseGuards } from '@nestjs/common' ;
3+ import { Body , Controller , Get , HttpStatus , Param , Post , Query , Res , UseGuards } from '@nestjs/common' ;
4+ import {
5+ ApiTags ,
6+ ApiOperation ,
7+ ApiBearerAuth ,
8+ ApiParam ,
9+ ApiQuery ,
10+ ApiBody ,
11+ ApiResponse ,
12+ } from '@nestjs/swagger' ;
413import { Response } from 'express' ;
514import { JwtAuthGuard } from '../auth/guards/jwt-auth.guard' ;
615import { CurrentUser } from '../auth/decorators/current-user.decorator' ;
716import { AuthUserPayload } from '../auth/types/auth-user.type' ;
8- import { DownloadDocumentDto , RequestSignedUploadDto } from './dto/document-access.dto' ;
17+ import {
18+ DownloadDocumentDto ,
19+ RequestSignedUploadDto ,
20+ SignedUploadUrlResponseDto ,
21+ } from './dto/document-access.dto' ;
922import { DocumentsService } from './documents.service' ;
1023import { SignedUrlService } from './signed-url/signed-url.service' ;
1124import { SignedUrlOperation } from './signed-url/signed-url-provider.interface' ;
1225
26+ @ApiTags ( 'Documents' )
27+ @ApiBearerAuth ( )
1328@Controller ( 'documents' )
1429@UseGuards ( JwtAuthGuard )
1530export class DocumentsDownloadController {
@@ -24,6 +39,23 @@ export class DocumentsDownloadController {
2439 * Then we redirect to a short-lived signed GET URL.
2540 */
2641 @Get ( ':id/download' )
42+ @ApiOperation ( {
43+ summary : 'Download a document' ,
44+ description : 'Authorizes access and redirects to a short-lived signed download URL.' ,
45+ } )
46+ @ApiParam ( { name : 'id' , description : 'Document ID' } )
47+ @ApiQuery ( {
48+ name : 'versionId' ,
49+ required : false ,
50+ description : 'Optional version ID to download a specific version' ,
51+ type : String ,
52+ } )
53+ @ApiResponse ( {
54+ status : HttpStatus . FOUND ,
55+ description : 'Redirects to a signed download URL' ,
56+ } )
57+ @ApiResponse ( { status : HttpStatus . NOT_FOUND , description : 'Document or version not found' } )
58+ @ApiResponse ( { status : HttpStatus . FORBIDDEN , description : 'Access denied' } )
2759 async download (
2860 @Param ( 'id' ) id : string ,
2961 @Query ( ) query : DownloadDocumentDto ,
@@ -101,6 +133,18 @@ export class DocumentsDownloadController {
101133 * for backward compatibility and will continue to work indefinitely.
102134 */
103135 @Post ( 'signed-upload-url' )
136+ @ApiOperation ( {
137+ summary : 'Request a signed upload URL' ,
138+ description : 'Returns a pre-signed URL for client-side direct upload to object storage.' ,
139+ } )
140+ @ApiBody ( { type : RequestSignedUploadDto } )
141+ @ApiResponse ( {
142+ status : HttpStatus . OK ,
143+ description : 'Signed upload URL generated' ,
144+ type : SignedUploadUrlResponseDto ,
145+ } )
146+ @ApiResponse ( { status : HttpStatus . BAD_REQUEST , description : 'Invalid request data' } )
147+ @ApiResponse ( { status : HttpStatus . FORBIDDEN , description : 'Access denied' } )
104148 async requestSignedUploadUrl (
105149 @Body ( ) dto : RequestSignedUploadDto ,
106150 @CurrentUser ( ) user : AuthUserPayload ,
0 commit comments