-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathEcosystemController.js
More file actions
39 lines (34 loc) · 1.21 KB
/
EcosystemController.js
File metadata and controls
39 lines (34 loc) · 1.21 KB
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
import express from "express";
import EcosystemUtils from "../utils/EcosystemUtils.js";
const router = express.Router();
// Fetch all libraries
router.get("/libraries", async (req, res) => {
try {
const libraries = await EcosystemUtils.fetchAllLibraries();
res.status(200).json({ success: true, data: libraries });
} catch (error) {
console.error("Error fetching libraries:", error.message);
res.status(500).json({ error: "Failed to fetch libraries" });
}
});
// Fetch all printers
router.get("/printers", async (req, res) => {
try {
const printers = await EcosystemUtils.fetchAllPrinters();
res.status(200).json({ success: true, data: printers });
} catch (error) {
console.error("Error fetching printers:", error.message);
res.status(500).json({ error: "Failed to fetch printers" });
}
});
// Fetch all restaurants
router.get("/restaurants", async (req, res) => {
try {
const restaurants = await EcosystemUtils.fetchAllRestaurants();
res.status(200).json({ success: true, data: restaurants });
} catch (error) {
console.error("Error fetching restaurants:", error.message);
res.status(500).json({ error: "Failed to fetch restaurants" });
}
});
export default router;