-
Notifications
You must be signed in to change notification settings - Fork 89
Open
Description
import { VeiculoController } from "../../controller/veiculos/veiculo.controller";
import { Elysia, t } from "elysia";
import type { IVeiculos } from "../../interface/veiculos";
const veiculos = new VeiculoController();
export const veiculosRoutes = (app: Elysia) => {
app.group("api/veiculos", (group) =>
group.post(
"/adicionar",
async ({ body }: { body: IVeiculos }) => {
const veiculo = body;
const adicionarVeiculos = await veiculos.adicionar(veiculo);
return adicionarVeiculos;
},
{
detail: {
summary: "Adiciona um veículo",
parameters: [],
description: "Endpoint para adicionar um novo veículo ao sistema.",
tags: ["Veiculos"],
responses: {
200: { description: "Veículo adicionado com sucesso" },
400: { description: "Dados inválidos" },
},
},
body: {
type: "object",
params: [],
static: [],
properties: {
marca: { type: "string", example: "Toyota" },
modelo: { type: "string", example: "Corolla" },
cor: { type: "string", example: "branco" },
ano: { type: "number", example: 2023 },
placa: { type: "string", example: "abc1234" },
tipo: { type: "number", example: 1 },
km: { type: "number", example: 10000 },
},
required: ["marca", "modelo", "ano", "cor", "placa", "tipo", "km"],
},
}
)
);
app.group("api/veiculos", (group) =>
group.get(
"/:id",
async () => {
const consultar = await veiculos.consultar();
return consultar;
},
{
detail: {
summary: "Consultar",
description: "Endpoint para adicionar um novo veículo ao sistema.",
tags: ["Veiculos"],
responses: {
200: { description: "Veículo adicionado com sucesso" },
400: { description: "Dados inválidos" },
},
},
}
)
);
app.group("api/veiculos", (group) =>
group.put("/alterar", async ({ body }: { body: IVeiculos }) => {
const veiculo = body;
const alterar = await veiculos.alterar(veiculo);
return alterar;
})
);
app.group("api/veiculos", (group) =>
group.put("/alterar/:id", async ({ params }: { params: { id: number } }) => {
const excluir = await veiculos.excluir(params.id);
return excluir;
})
);
};
'[Kind]' é declarado aqui.
Metadata
Metadata
Assignees
Labels
No labels