const express = require("express"); const fs = require("fs"); const app = express(); app.use(express.json()); let orders = JSON.parse(fs.readFileSync("orders.json", "utf-8")); // Get order status app.get("/api/status/:id", (req, res) => { const order = orders.find(o => o.id === req.params.id); if (!order) return res.status(404).send({ error: "Not found" }); res.send({ status: order.status }); }); // Update order status (admin) app.post("/api/update", (req, res) => { const { id, status } = req.body; const order = orders.find(o => o.id === id); if (!order) return res.status(404).send({ error: "Not found" }); order.status = status; fs.writeFileSync("orders.json", JSON.stringify(orders, null, 2)); res.send({ message: "Status updated" }); }); app.listen(3000, () => console.log("Server running on port 3000"));


Dream it

〰️

Dream it 〰️

Order Tracking

Track Your Order

0%