Incluindo tabela carModels e rotas para pegar lista de carros
This commit is contained in:
17
src/routes/cars.routes.ts
Normal file
17
src/routes/cars.routes.ts
Normal 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;
|
||||
@@ -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;
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user