From 3c51425db9df3cdb637b59a7f2d6fc5305a2b22b Mon Sep 17 00:00:00 2001 From: ujjwal123123 Date: Sun, 21 Jun 2020 02:41:53 +0530 Subject: [PATCH 1/2] Schema for landing page Gallery --- models/landingGallery.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 models/landingGallery.js 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); From dd87b569d906e8fa279f76f7a3d2cc5a498102a2 Mon Sep 17 00:00:00 2001 From: ujjwal123123 Date: Sun, 21 Jun 2020 02:58:17 +0530 Subject: [PATCH 2/2] Model for gallery API --- controllers/API.js | 2 ++ controllers/API/GET/gallery.js | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 controllers/API/GET/gallery.js 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;