feat: enhance JWT authentication and quick import functionality with logging for better traceability

Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
Nils-Johan Gynther
2026-04-30 12:19:21 +02:00
parent 5231ca42a7
commit 87372f0d15
4 changed files with 37 additions and 6 deletions
@@ -15,6 +15,19 @@ export class QuickImportController {
FileInterceptor('file', {
storage: memoryStorage(),
limits: { fileSize: 10 * 1024 * 1024 },
fileFilter: (req, file, callback) => {
if (
file.mimetype === 'application/pdf' ||
file.mimetype === 'application/octet-stream' ||
file.mimetype === 'image/jpeg' ||
file.mimetype === 'image/png' ||
file.mimetype === 'image/webp'
) {
callback(null, true);
} else {
callback(new Error('Otillåten filtyp. Använd JPEG, PNG, WebP eller PDF.'), false);
}
},
}),
)
async importFromInput(
@@ -76,6 +76,8 @@ export class QuickImportService {
* Importerar från en uppladdad fil
*/
async importFromUpload(file: Express.Multer.File): Promise<QuickImportResult | ReceiptImportResult> {
this.logger.log('MIME-typ:', file.mimetype);
this.logger.log('Token:', file.originalname);
const kind = file.mimetype.startsWith('image/') ? 'image' : 'pdf';
return this.importFromBuffer(file.buffer, kind);
}