chore: add flyer import module and configuration
Test Suite / backend-pr-quick (push) Has been skipped
Test Suite / quick-import-pr-quick (push) Has been skipped
Test Suite / backend-full (push) Successful in 3m57s
Test Suite / flutter-quality (push) Failing after 1m19s

- Added FlyerImportModule to AppModule imports
- Created new flyer-import module directory
- Added .kilo/ configuration directory
This commit is contained in:
Nils-Johan Gynther
2026-05-18 18:40:25 +02:00
parent e6961fc593
commit f42132ed5b
6 changed files with 521 additions and 1 deletions
@@ -0,0 +1,59 @@
import {
BadRequestException,
Controller,
HttpCode,
Post,
Request,
UploadedFile,
UseInterceptors,
} from '@nestjs/common';
import { Throttle } from '@nestjs/throttler';
import { FileInterceptor } from '@nestjs/platform-express';
import { memoryStorage } from 'multer';
import { FlyerImportResponse } from './dto/flyer-import.response';
import { FlyerImportService } from './flyer-import.service';
const ALLOWED_MIMES = [
'application/pdf',
'application/octet-stream',
'text/plain',
];
@Controller('flyer-import')
export class FlyerImportController {
constructor(private readonly flyerImportService: FlyerImportService) {}
@Post('parse')
@HttpCode(200)
@Throttle({ default: { ttl: 60_000, limit: 10 } })
@UseInterceptors(
FileInterceptor('file', {
storage: memoryStorage(),
limits: { fileSize: 15 * 1024 * 1024 },
}),
)
async parseFlyer(
@UploadedFile() file?: Express.Multer.File,
@Request() req?: any,
): Promise<FlyerImportResponse> {
if (!file?.buffer) {
throw new BadRequestException('Ingen fil skickades med.');
}
if (!ALLOWED_MIMES.includes(file.mimetype)) {
throw new BadRequestException('Otillåten filtyp. Använd PDF eller textfil.');
}
const userId =
typeof req?.user?.id === 'number'
? req.user.id
: typeof req?.user?.userId === 'number'
? req.user.userId
: undefined;
if (!userId) {
throw new BadRequestException('Kunde inte identifiera användaren.');
}
return this.flyerImportService.parseAndMatch(file, userId);
}
}