-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsearch.js
62 lines (59 loc) · 1.4 KB
/
search.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
//Author: Samarth Jariwala (B008899380)
//Email: [email protected]
const express = require("express");
const Facilities = require("../models/facilities");
const Blogs = require("../models/Blogging/allBlogs");
const Merchandise = require("../models/merchandise");
const router = express.Router();
/**
* This API gets all the facilities available for reservation.
*/
router.get("/facility", async (req, res) => {
try {
const allFacilities = await Facilities.find();
return res.status(200).json({
data: allFacilities,
success: true,
});
} catch (err) {
return res.status(500).json({
message: "Internal server error",
success: false,
});
}
});
/**
* This API gets all the Blogs
*/
router.get("/blogs", async (req, res) => {
try {
const allBlogs = await Blogs.find();
return res.status(200).json({
data: allBlogs,
success: true,
});
} catch (err) {
return res.status(500).json({
message: "Internal server error",
success: false,
});
}
});
/**
* This API gets all the merchandise products
*/
router.get("/merchandise", async (req, res) => {
try {
const allStore = await Merchandise.find();
return res.status(200).json({
data: allStore,
success: true,
});
} catch (err) {
return res.status(500).json({
message: "Internal server error",
success: false,
});
}
});
module.exports = router;