diff --git a/src/controllers/calendar.js b/src/controllers/calendar.js index 48f92fa..875c01b 100644 --- a/src/controllers/calendar.js +++ b/src/controllers/calendar.js @@ -1,47 +1,16 @@ const Adventure = require('../db/models').adventure; -// const { Adventure } = require('../db/sequelize') const Op = require('sequelize').Op; module.exports = { - location(req, res) { - return Adventure - .findAll({ - where: { [Op.not]: { locationName: null } } - }) - .then(adventure => res.status(200).send(adventure)) - .catch(error => res.status(400).send(error)) - }, - list(req, res) { return Adventure .findAll({ - attributes: ['id', 'title', 'subtext', 'dateStart', 'dateEnd', 'locationName'] + attributes: ['id', 'title', 'dateStart', 'dateEnd', 'locationName'] }) .then(adventure => res.status(200).send(adventure)) .catch(error => res.status(400).send(error)) }, - get(req, res) { - return Adventure - .findById(req.params.id) - .then(adventure => res.status(200).send(adventure)) - .catch(error => res.status(400).send(error)); - }, - - // get form elements - create(req, res) { - console.log('adventure', Adventure) - return Adventure - .create({ - title: req.body.title, - subtext: req.body.subtext, - dateStart: req.body.dateStart, - dateEnd: req.body.dateEnd, - locationName: req.body.locationName - }) - .then(adventure => res.status(201).send(adventure)) - .catch(error => res.status(400).send(error)) - } }; \ No newline at end of file diff --git a/src/controllers/index.js b/src/controllers/index.js index 52d0fd9..6afdff0 100644 --- a/src/controllers/index.js +++ b/src/controllers/index.js @@ -1,9 +1,11 @@ const Adventure = require('./adventure'); +const Calendar = require('./calendar'); const Location = require('./location'); const Image = require('./image'); module.exports = { Adventure, + Calendar, Location, Image } \ No newline at end of file diff --git a/src/routes/index.js b/src/routes/index.js index 7915e82..b304035 100644 --- a/src/routes/index.js +++ b/src/routes/index.js @@ -1,4 +1,5 @@ const adventureController = require('../controllers').Adventure; +const calendarController = require('../controllers').Calendar; const locationController = require('../controllers').Location; const imageController = require('../controllers').Image; @@ -14,6 +15,11 @@ module.exports = (app) => { app.get('/api/adventure/location', adventureController.location); app.get('/api/adventure/:id', adventureController.get); + app.post('/api/upload/', adventureController.uploadHandler); + + // Dates + app.get('/api/dates', calendarController.list) + // Location (map) app.get('/api/location', locationController.list)