diff --git a/src/modules/gates/infrastructure/gate.controller.ts b/src/modules/gates/infrastructure/gate.controller.ts index 7cc7a71..cbeb27f 100644 --- a/src/modules/gates/infrastructure/gate.controller.ts +++ b/src/modules/gates/infrastructure/gate.controller.ts @@ -1,4 +1,13 @@ -import { Body, Controller, Get, Param, Post, Res } from '@nestjs/common'; +import { + Body, + Controller, + ForbiddenException, + Get, + Param, + Post, + Res, + UnprocessableEntityException, +} from '@nestjs/common'; import { Response } from 'express'; import { ApiTags } from '@nestjs/swagger'; import { Public } from 'src/core/guards'; @@ -59,13 +68,12 @@ export class GateController { res.status(200); return gateResponses[0]; } + if (failedGates.includes(data.uuid)) { - res.status(403); - return gateResponses[2]; + throw new ForbiddenException(gateResponses[2]); } - const response = Math.floor(Math.random() * 3); - const responseValue = gateResponses[response]; + const responseValue = gateResponses[0]; res.status(responseValue.statusCode); return responseValue; diff --git a/src/modules/queue/infrastructure/controllers/queue.controller.ts b/src/modules/queue/infrastructure/controllers/queue.controller.ts index df33fee..949dc5a 100644 --- a/src/modules/queue/infrastructure/controllers/queue.controller.ts +++ b/src/modules/queue/infrastructure/controllers/queue.controller.ts @@ -29,6 +29,7 @@ import { Response } from 'express'; import { QueueTimeFormula } from '../../domain/usecases/formula/queue-time.formula'; import * as moment from 'moment'; +import { validate as isValidUUID } from 'uuid'; @ApiTags(`Queue`) @Controller(`v1/${MODULE_NAME.QUEUE}`) @@ -69,7 +70,8 @@ export class QueueController { @Post('print-ticket/:id') async printTicket(@Param('id') id: string): Promise { - if (!id) throw new UnprocessableEntityException('Order id is required'); + if (!isValidUUID(id)) + throw new UnprocessableEntityException('Order id must be ticket uuid'); return await this.orchestrator.printTicket(id); }