managarten/apps-archived/inventory/apps/backend/src/document/document.controller.ts
Till-JS 44897ae758 chore: archive inventory, presi, storage apps
Move these apps to apps-archived/ as they are not actively developed:
- inventory: Inventory management app
- presi: Presentation tool
- storage: Cloud storage app

These can be reactivated by moving back to apps/ when needed.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-05 15:22:38 +01:00

50 lines
1.4 KiB
TypeScript

import {
Controller,
Post,
Delete,
Get,
Param,
UseGuards,
UseInterceptors,
UploadedFile,
Body,
} from '@nestjs/common';
import { FileInterceptor } from '@nestjs/platform-express';
import { JwtAuthGuard, CurrentUser, CurrentUserData } from '@manacore/shared-nestjs-auth';
import { DocumentService } from './document.service';
import type { DocumentType } from '@inventory/shared';
@Controller('api/v1/items/:itemId/documents')
@UseGuards(JwtAuthGuard)
export class DocumentController {
constructor(private readonly documentService: DocumentService) {}
@Post()
@UseInterceptors(FileInterceptor('document', { limits: { fileSize: 20 * 1024 * 1024 } }))
async uploadDocument(
@CurrentUser() user: CurrentUserData,
@Param('itemId') itemId: string,
@UploadedFile() file: Express.Multer.File,
@Body('documentType') documentType?: DocumentType
) {
return this.documentService.uploadDocument(user.userId, itemId, file, documentType);
}
@Delete(':documentId')
async deleteDocument(
@CurrentUser() user: CurrentUserData,
@Param('itemId') itemId: string,
@Param('documentId') documentId: string
) {
return this.documentService.deleteDocument(user.userId, itemId, documentId);
}
@Get(':documentId/download')
async getDownloadUrl(
@CurrentUser() user: CurrentUserData,
@Param('itemId') itemId: string,
@Param('documentId') documentId: string
) {
return this.documentService.getDownloadUrl(user.userId, itemId, documentId);
}
}