const routes = require('express').Router();

const { cacheSuccesses } = require('../../middlewares/cache');
const { isOptionalUser, isLoggedUser } = require('../../middlewares/accessValidator');

//const PaginateMiddleware = require('../../middlewares/paginate');
//const FieldMiddleware = require('../../middlewares/fields');
const SortMiddleware = require('../../middlewares/sort');
const locationController = require('./location.controller');

routes.get('/locations', 
    isOptionalUser,
    cacheSuccesses('24 hours'),
    SortMiddleware.middleware({ default: "city" }), 
    locationController.find({
        scopes: ['includeMultimedias'],
    })
);

routes.get('/locations/:id',
    isOptionalUser,
    cacheSuccesses('24 hours'),
    //SortMiddleware.middleware({ default: "city" }), 
    locationController.findOne({
        scopes: ['includeMultimedias']
    })
);

/********************************************************************************************************
 *  ADMINISTRACIÓN
 *********************************************************************************************************
 */

module.exports = routes;