var express = require('express');
var router = express.Router();

var forecastController = require('../controllers/forecast_controller');
var usersController = require('../controllers/users_controller');
var firebaseController = require('../controllers/firebase_controller');
var agendaController = require('../controllers/agenda_controller');
var dispositivosController = require('../controllers/dispositivos_controller');
var sportpagerController = require('../controllers/sportpager_controller');


router.use(function(req, res, next) {
  res.header("Access-Control-Allow-Origin", "*");
  res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
  next();
});

/* GET home page. */
router.get('/', function(req, res, next) {
  res.render('index', { title: 'Sport Pager' });
});

router.get('/forecasts/posicion', forecastController.posicion);
router.get('/forecasts/pronostico', forecastController.pronostico);
router.get('/usuarios/propiedades', usersController.propiedades);
//router.get('/usuarios/signin', usersController.signin);
router.post('/usuarios/signin', usersController.signin);
router.get('/firebase/notificacion', firebaseController.notificacion);
router.post('/agenda/signin', agendaController.signin);
//router.options('/agenda/signin', agendaController.signin);
router.post('/dispositivos/registro', dispositivosController.registro);
router.post('/dispositivos/crear', dispositivosController.crear);

router.post('/sportpager/crear', sportpagerController.crear);
router.post('/sportpager/eliminar', sportpagerController.eliminar); // en siguiente version, cambiar a delete
//router.delete('/sportpager/eliminar', sportpagerController.eliminar);
router.post('/sportpager/ack_firebase', sportpagerController.ack_firebase);

module.exports = router;
