Skip to content

Commit

Permalink
remember to fix useUpdate Schedule.js
Browse files Browse the repository at this point in the history
  • Loading branch information
phm-tuyenn committed Jan 1, 2024
1 parent efe9bea commit 8d1010c
Show file tree
Hide file tree
Showing 23 changed files with 1,030 additions and 119 deletions.
54 changes: 9 additions & 45 deletions api/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 1 addition & 3 deletions api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@
"express": "~4.16.1",
"http-errors": "~1.6.3",
"jade": "~1.11.0",
"morgan": "~1.9.1"
},
"devDependencies": {
"morgan": "~1.9.1",
"nodemon": "^3.0.2"
}
}
15 changes: 13 additions & 2 deletions api/routes/api.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,19 @@
var express = require("express");
var fs = require("fs")
var router = express.Router();

router.get("/", function(req, res, next) {
res.send("API is working properly");
router.get("/", function(req, res) {
res.send({apiStatus: "ok"});
});

router.post("/read", function(req, res) {
res.send(JSON.parse(fs.readFileSync(`../data/${req.body.file}.json`)));
});

router.put("/update", function(req, res) {
fs.writeFileSync(`../data/${req.body.file}.json`, JSON.stringify(req.body.data))
console.log("ok")
res.send({ status: "ok" })
});

module.exports = router;
Loading

0 comments on commit 8d1010c

Please sign in to comment.