Skip to content

Commit

Permalink
Fix item upload: wrong req. payload schema
Browse files Browse the repository at this point in the history
  • Loading branch information
rafasofizada committed Apr 28, 2022
1 parent dd10834 commit 9483d93
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions src/order/OrderController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
Patch,
Post,
Query,
Req,
UploadedFile,
UploadedFiles,
UseInterceptors,
Expand Down Expand Up @@ -83,6 +84,7 @@ import {
import { validate, validateOrReject } from 'class-validator';
import { plainToClass } from 'class-transformer';
import { throwCustomException } from '../common/error-handling';
import { request } from 'http';

@Controller('order')
export class OrderController {
Expand Down Expand Up @@ -211,15 +213,10 @@ export class OrderController {
// file control/validation is done by MulterModule registration
@UseInterceptors(FilesInterceptor('photos'))
async addItemPhotoHandler(
@Body() { payload: unidAddItemPhotoRequestJson }: { payload: string },
@Body() unidAddItemPhotoRequest: AddItemPhotoRequest,
@UploadedFiles() photos: FileUpload[],
@VerifiedHostIdentity() { id: hostId }: Host,
) {
const unidAddItemPhotoRequest: AddItemPhotoRequest = plainToClass(
AddItemPhotoRequest,
JSON.parse(unidAddItemPhotoRequestJson),
);

await validateOrReject(unidAddItemPhotoRequest).catch(
throwCustomException('Error adding item photos: '),
);
Expand Down

0 comments on commit 9483d93

Please sign in to comment.