Refactor code structure for improved readability and maintainability
Test Suite / test (24.15.0) (push) Has been cancelled
Test Suite / test (24.15.0) (push) Has been cancelled
This commit is contained in:
@@ -0,0 +1,64 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
||||
};
|
||||
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
||||
return function (target, key) { decorator(target, key, paramIndex); }
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.QuickImportController = void 0;
|
||||
const common_1 = require("@nestjs/common");
|
||||
const throttler_1 = require("@nestjs/throttler");
|
||||
const platform_express_1 = require("@nestjs/platform-express");
|
||||
const multer_1 = require("multer");
|
||||
const quick_import_dto_1 = require("./dto/quick-import.dto");
|
||||
const quick_import_service_1 = require("./quick-import.service");
|
||||
let QuickImportController = class QuickImportController {
|
||||
constructor(quickImportService) {
|
||||
this.quickImportService = quickImportService;
|
||||
}
|
||||
async importFromInput(body, file) {
|
||||
if (file) {
|
||||
return this.quickImportService.importFromUpload(file);
|
||||
}
|
||||
return this.quickImportService.importFromInput(body?.input ?? '');
|
||||
}
|
||||
};
|
||||
exports.QuickImportController = QuickImportController;
|
||||
__decorate([
|
||||
(0, common_1.Post)(),
|
||||
(0, common_1.HttpCode)(200),
|
||||
(0, throttler_1.Throttle)({ default: { ttl: 60_000, limit: 20 } }),
|
||||
(0, common_1.UseInterceptors)((0, platform_express_1.FileInterceptor)('file', {
|
||||
storage: (0, multer_1.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);
|
||||
}
|
||||
},
|
||||
})),
|
||||
__param(0, (0, common_1.Body)()),
|
||||
__param(1, (0, common_1.UploadedFile)()),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [quick_import_dto_1.QuickImportDto, Object]),
|
||||
__metadata("design:returntype", Promise)
|
||||
], QuickImportController.prototype, "importFromInput", null);
|
||||
exports.QuickImportController = QuickImportController = __decorate([
|
||||
(0, common_1.Controller)('quick-import'),
|
||||
__metadata("design:paramtypes", [quick_import_service_1.QuickImportService])
|
||||
], QuickImportController);
|
||||
//# sourceMappingURL=quick-import.controller.js.map
|
||||
Reference in New Issue
Block a user