Browse Source

updated

master
arnaucode 7 years ago
parent
commit
7a2d12a22c
2 changed files with 6 additions and 5 deletions
  1. +1
    -0
      controllers/travelController.js
  2. +5
    -5
      server.js

+ 1
- 0
controllers/travelController.js

@ -20,6 +20,7 @@ exports.getAllTravels = function(req, res) {
exports.getTravelById = function (req, res) { exports.getTravelById = function (req, res) {
travelModel.findOne({_id: req.params.travelid}) travelModel.findOne({_id: req.params.travelid})
.lean() .lean()
.populate('user', 'username avatar')
.populate('joins', 'username avatar') .populate('joins', 'username avatar')
.populate('comments', 'comment user') .populate('comments', 'comment user')
.exec(function (err, travel) { .exec(function (err, travel) {

+ 5
- 5
server.js

@ -61,11 +61,11 @@ apiRoutes.route('/signup')
.post(userCtrl.signup); .post(userCtrl.signup);
apiRoutes.route('/users') apiRoutes.route('/users')
.get(userCtrl.getAllUsers); .get(userCtrl.getAllUsers);
apiRoutes.route('/users/getByUserId/:userid')
apiRoutes.route('/users/id/:userid')
.get(userCtrl.getUserById); .get(userCtrl.getUserById);
apiRoutes.route('/travels') apiRoutes.route('/travels')
.get(travelCtrl.getAllTravels); .get(travelCtrl.getAllTravels);
apiRoutes.route('/travels/getByTravelId/:travelid')
apiRoutes.route('/travels/id/:travelid')
.get(travelCtrl.getTravelById); .get(travelCtrl.getTravelById);
@ -107,21 +107,21 @@ apiRoutes.use(function(req, res, next) {
}); //fi verificació de token }); //fi verificació de token
apiRoutes.route('/users/getByToken')
apiRoutes.route('/users/token')
.get(userCtrl.getUserByToken); .get(userCtrl.getUserByToken);
apiRoutes.route('/users')//agafa l'user a partir del token apiRoutes.route('/users')//agafa l'user a partir del token
.put(userCtrl.updateUser)//no comprovat .put(userCtrl.updateUser)//no comprovat
.delete(userCtrl.deleteUser); .delete(userCtrl.deleteUser);
apiRoutes.route('/travels') apiRoutes.route('/travels')
.post(travelCtrl.addTravel); .post(travelCtrl.addTravel);
apiRoutes.route('/travels/modifyById/:travelid')
apiRoutes.route('/travels/id/modify/:travelid')
.put(travelCtrl.updateTravel)//no comprovat .put(travelCtrl.updateTravel)//no comprovat
.delete(travelCtrl.deleteTravel); .delete(travelCtrl.deleteTravel);
apiRoutes.route('/travels/join/:travelid') apiRoutes.route('/travels/join/:travelid')
.get(travelCtrl.addJoinPetition); .get(travelCtrl.addJoinPetition);
apiRoutes.route('/travels/unjoin/:travelid') apiRoutes.route('/travels/unjoin/:travelid')
.get(travelCtrl.unJoin); .get(travelCtrl.unJoin);
apiRoutes.route('/travels/getByUserId/:userid')
apiRoutes.route('/travels/byuser/id/:userid')
.get(travelCtrl.getTravelsByUserId); .get(travelCtrl.getTravelsByUserId);
//FINS AQUÏ COMPROVAT //FINS AQUÏ COMPROVAT

Loading…
Cancel
Save