wip
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
import { Router } from 'express';
|
import { Router } from 'express';
|
||||||
import { getRepository } from 'typeorm';
|
import { getRepository } from 'typeorm';
|
||||||
|
import ensureAuthenticated from '../middlewares/ensureAuthenticated';
|
||||||
import UserSearching from '../models/UsersSearching';
|
import UserSearching from '../models/UsersSearching';
|
||||||
import CalculateDistanceBetweenCoords from '../services/CalculateDistanceBetweenCoords';
|
import CalculateDistanceBetweenCoords from '../services/CalculateDistanceBetweenCoords';
|
||||||
import CreateUserSearchingService from '../services/CreateUserSearchingService';
|
import CreateUserSearchingService from '../services/CreateUserSearchingService';
|
||||||
@@ -33,8 +34,8 @@ searchRoutes.get('/list', async (request, response) => {
|
|||||||
return response.json({ data: searches });
|
return response.json({ data: searches });
|
||||||
});
|
});
|
||||||
|
|
||||||
searchRoutes.post('/', async (request, response) => {
|
searchRoutes.post('/', ensureAuthenticated, async (request, response) => {
|
||||||
const { id_user, latitude_from, longitude_from, address_to } = request.body;
|
const { latitude_from, longitude_from, address_to } = request.body;
|
||||||
|
|
||||||
const getCoordinates = new GetCoordinatesByAddress();
|
const getCoordinates = new GetCoordinatesByAddress();
|
||||||
|
|
||||||
@@ -46,7 +47,7 @@ searchRoutes.post('/', async (request, response) => {
|
|||||||
const createUserSearching = new CreateUserSearchingService();
|
const createUserSearching = new CreateUserSearchingService();
|
||||||
|
|
||||||
const search = await createUserSearching.execute({
|
const search = await createUserSearching.execute({
|
||||||
id_user,
|
id_user:request.user.id_user,
|
||||||
latitude_from,
|
latitude_from,
|
||||||
longitude_from,
|
longitude_from,
|
||||||
latitude_to,
|
latitude_to,
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ app.use((err: Error, request: Request, response: Response, _: NextFunction) => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
const port = 10002
|
const port = 3333
|
||||||
|
|
||||||
app.listen(port, () => {
|
app.listen(port, () => {
|
||||||
console.log(`🚀 Server started on port ${port}!`);
|
console.log(`🚀 Server started on port ${port}!`);
|
||||||
|
|||||||
Reference in New Issue
Block a user