multy-stub/server/routers/kfu-m-24-1/eng-it-lean/dictionaries/index.js

22 lines
457 B
JavaScript

const router = require("express").Router();
module.exports = router;
const data = require("./data/dictionaries.json");
const wordsData = require("./data/dictionaryWords.json");
router.get("/", (req, res) => {
res.send(data);
});
router.get("/:id", (req, res) => {
const id = parseInt(req.params.id);
const words = wordsData.find((word) => word.id === id);
if (!words) {
return res.status(404).send("Not found");
}
res.send(words);
});