proteje rotas com JwtAuthGuard e documenta endpoints com Swagger

This commit is contained in:
unknown
2025-03-28 19:46:44 -03:00
parent 36aea127c1
commit 5e4ef04b4a
20 changed files with 372 additions and 66 deletions

View File

@@ -0,0 +1,79 @@
"use strict";
/* eslint-disable prettier/prettier */
/* eslint-disable @typescript-eslint/no-unused-vars */
/*
https://docs.nestjs.com/controllers#controllers
*/
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 __param = (this && this.__param) || function (paramIndex, decorator) {
return function (target, key) { decorator(target, key, paramIndex); }
};
exports.__esModule = true;
exports.LogisticController = void 0;
var common_1 = require("@nestjs/common");
var jwt_auth_guard_1 = require("src/auth/guards/jwt-auth.guard"); // ajuste o caminho se necessário
var swagger_1 = require("@nestjs/swagger");
var LogisticController = /** @class */ (function () {
function LogisticController(logisticService) {
this.logisticService = logisticService;
}
LogisticController.prototype.getExpedicao = function () {
return this.logisticService.getExpedicao();
};
LogisticController.prototype.getEmployee = function () {
return this.logisticService.getEmployee();
};
LogisticController.prototype.getDelivery = function (placa) {
return this.logisticService.getDeliveries(placa);
};
LogisticController.prototype.getStatusCar = function (placa) {
return this.logisticService.getStatusCar(placa);
};
LogisticController.prototype.createOutCar = function (data) {
return this.logisticService.createCarOut(data);
};
LogisticController.prototype.createinCar = function (data) {
return this.logisticService.createCarIn(data);
};
__decorate([
common_1.Get('expedicao'),
swagger_1.ApiOperation({ summary: 'Retorna informações de expedição' })
], LogisticController.prototype, "getExpedicao");
__decorate([
common_1.Get('employee'),
swagger_1.ApiOperation({ summary: 'Retorna lista de funcionários' })
], LogisticController.prototype, "getEmployee");
__decorate([
common_1.Get('deliveries/:placa'),
swagger_1.ApiOperation({ summary: 'Retorna entregas por placa' }),
__param(0, common_1.Param('placa'))
], LogisticController.prototype, "getDelivery");
__decorate([
common_1.Get('status-car/:placa'),
swagger_1.ApiOperation({ summary: 'Retorna status do veículo por placa' }),
__param(0, common_1.Param('placa'))
], LogisticController.prototype, "getStatusCar");
__decorate([
common_1.Post('create'),
swagger_1.ApiOperation({ summary: 'Registra saída de veículo' }),
__param(0, common_1.Body())
], LogisticController.prototype, "createOutCar");
__decorate([
common_1.Post('return-car'),
swagger_1.ApiOperation({ summary: 'Registra retorno de veículo' }),
__param(0, common_1.Body())
], LogisticController.prototype, "createinCar");
LogisticController = __decorate([
swagger_1.ApiTags('Logística'),
swagger_1.ApiBearerAuth(),
common_1.UseGuards(jwt_auth_guard_1.JwtAuthGuard),
common_1.Controller('api/v1/logistic')
], LogisticController);
return LogisticController;
}());
exports.LogisticController = LogisticController;

View File

@@ -4,48 +4,62 @@
https://docs.nestjs.com/controllers#controllers
*/
import { Body, Controller, Get, Param, Post } from '@nestjs/common';
import { LogisticService } from './logistic.service';
import { CarOutDelivery } from '../core/models/car-out-delivery.model';
import { CarInDelivery } from '../core/models/car-in-delivery.model';
import {
Body,
Controller,
Get,
Param,
Post,
UseGuards
} from '@nestjs/common';
import { JwtAuthGuard } from 'src/auth/guards/jwt-auth.guard'; // ajuste o caminho se necessário
import { ApiBearerAuth, ApiTags, ApiOperation } from '@nestjs/swagger';
@Controller('api/v1/logistic')
export class LogisticController {
constructor( private readonly logisticService: LogisticService) {}
@ApiTags('Logística')
@ApiBearerAuth()
@UseGuards(JwtAuthGuard)
@Controller('api/v1/logistic')
export class LogisticController {
constructor(private readonly logisticService: LogisticService) {}
@Get('expedicao')
@ApiOperation({ summary: 'Retorna informações de expedição' })
getExpedicao() {
try {
return this.logisticService.getExpedicao();
} catch (err) {
console.log(err);
}
return this.logisticService.getExpedicao();
}
@Get('employee')
@ApiOperation({ summary: 'Retorna lista de funcionários' })
getEmployee() {
return this.logisticService.getEmployee();
return this.logisticService.getEmployee();
}
@Get('deliveries/:placa')
@ApiOperation({ summary: 'Retorna entregas por placa' })
getDelivery(@Param('placa') placa: string) {
return this.logisticService.getDeliveries(placa);
return this.logisticService.getDeliveries(placa);
}
@Get('status-car/:placa')
@ApiOperation({ summary: 'Retorna status do veículo por placa' })
getStatusCar(@Param('placa') placa: string) {
return this.logisticService.getStatusCar(placa);
return this.logisticService.getStatusCar(placa);
}
@Post('create')
@ApiOperation({ summary: 'Registra saída de veículo' })
createOutCar(@Body() data: CarOutDelivery) {
return this.logisticService.createCarOut(data);
return this.logisticService.createCarOut(data);
}
@Post('return-car')
@ApiOperation({ summary: 'Registra retorno de veículo' })
createinCar(@Body() data: CarInDelivery) {
return this.logisticService.createCarIn(data);
return this.logisticService.createCarIn(data);
}
}
}