diff --git a/controllers/API.js b/controllers/API.js index 6e78b7b..1115b9b 100644 --- a/controllers/API.js +++ b/controllers/API.js @@ -23,4 +23,6 @@ router.use(require('./API/POST/xclubGalleryPage.js')); router.use(require('./API/GET/xclubGalleryPage.js')); router.use(require('./API/DELETE/xclubGalleryPage.js')); +router.use(require('./API/GET/gallery.js')); + module.exports = router; diff --git a/controllers/API/GET/gallery.js b/controllers/API/GET/gallery.js new file mode 100644 index 0000000..f13d452 --- /dev/null +++ b/controllers/API/GET/gallery.js @@ -0,0 +1,18 @@ +const express = require('express'); +const landingGallery = require('../../../models/landingGallery.js'); + +const router = express.Router(); + +router.get('/api/techboard/gallery', (req, res) => { + landingGallery + .find({}, (err, gallery) => { + if (err) { + res.statusCode = 500; + res.json({ error: err.message }); + } else { + res.json(gallery[0].images); + } + }); +}); + +module.exports = router; diff --git a/models/landingGallery.js b/models/landingGallery.js new file mode 100644 index 0000000..2afa256 --- /dev/null +++ b/models/landingGallery.js @@ -0,0 +1,16 @@ +const mongoose = require('mongoose'); + +const landingGallerySchema = new mongoose.Schema({ + images: [ + { + title: String, + description: String, + url: String, + }, + { + timestamps: true, + } + ], +}); + +module.exports = new mongoose.model('landingGallery', landingGallerySchema);