Incluindo tabela carModels e rotas para pegar lista de carros

This commit is contained in:
Matheus Albino Brunhara
2022-05-28 15:40:09 -05:00
parent 4d2eac45d2
commit ee259bd6ff
8 changed files with 243 additions and 2 deletions

17
src/routes/cars.routes.ts Normal file
View File

@@ -0,0 +1,17 @@
import { Router } from 'express';
import ensureAuthenticated from '../middlewares/ensureAuthenticated';
import GetCarModelsService from '../services/GetCarModelsService';
const carsRouter = Router();
carsRouter.get('/list', ensureAuthenticated, async (request, response) => {
const getCarModelsService = new GetCarModelsService();
const carModels = await getCarModelsService.execute();
return response.json({ data: carModels });
});
export default carsRouter;

View File

@@ -2,10 +2,12 @@ import { Router } from 'express';
import sessionsRouter from './sessions.routes';
import usersRouter from './users.routes';
import carsRouter from './cars.routes';
const routes = Router();
routes.use('/users', usersRouter);
routes.use('/sessions', sessionsRouter);
routes.use('/cars', carsRouter);
export default routes;

View File

@@ -59,8 +59,6 @@ usersRouter.get('/:id', ensureAuthenticated, async (request, response) => {
const finalDate = `${date}/${month}/${year}`
console.log(finalDate)
const userWithoutPassword = {
id_user: user.id_user,
name: user.name,