blah
This commit is contained in:
@ -2,7 +2,7 @@ const { sequelize } = require("../Database/mySql.js");
|
||||
const { api_log_Model } = require("../Database/model/apiLogModel.js");
|
||||
const { sensorDataModel } = require("../Database/model/sensorDataModel.js");
|
||||
const { apikeyModel } = require("../Database/model/apiKeyModel.js");
|
||||
const { compareAPIKey } = require("../functions/bcrypt.js");
|
||||
const { compareAPIKey } = require("./bcrypt.js");
|
||||
|
||||
async function insertLogData(log) {
|
||||
try {
|
||||
|
77
webserver/routes/apiLog.js
Normal file
77
webserver/routes/apiLog.js
Normal file
@ -0,0 +1,77 @@
|
||||
const {
|
||||
|
||||
} = require("../functions/apiDatabase.js");
|
||||
|
||||
const express = require("express");
|
||||
const router = express.Router();
|
||||
|
||||
|
||||
|
||||
module.exports = router;
|
||||
|
||||
/*
|
||||
|
||||
//get location
|
||||
router.get("/", async (req, res, next) => {
|
||||
try {
|
||||
const location = await getLocation();
|
||||
//res send json and status code
|
||||
res.status(200).json(location);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
next(error);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
//add location
|
||||
router.post("/new", async (req, res, next) => {
|
||||
try {
|
||||
const { name, added_by, description } = req.body;
|
||||
await addLocation(name, added_by, description);
|
||||
res.sendStatus(200)
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
next(error);
|
||||
}
|
||||
});
|
||||
|
||||
//update location
|
||||
router.put("/update", async (req, res, next) => {
|
||||
try {
|
||||
const { id, name, added_by, description } = req.body;
|
||||
await updateLocation(id, name, added_by, description);
|
||||
res.status(200).json({ message: "Location " + id + " updated" });
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
next(error);
|
||||
}
|
||||
});
|
||||
|
||||
//delete location
|
||||
router.delete("/delete", async (req, res, next) => {
|
||||
try {
|
||||
const { id } = req.body;
|
||||
await deleteLocation(id);
|
||||
res.status(200).json({ message: "Location " + id + " deleted" });
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
next(error);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
//get location by id
|
||||
router.get("/:id", async (req, res, next) => {
|
||||
try {
|
||||
//get params
|
||||
const { id } = req.params;
|
||||
const location = await getLocationById(id);
|
||||
res.status(200).json(location);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
next(error);
|
||||
}
|
||||
});
|
||||
*/
|
@ -26,6 +26,9 @@ router.use('/sensor', require('./sensor'))
|
||||
//sensor data route
|
||||
router.use('/sensor-data', require('./sensorData'));
|
||||
|
||||
//log route
|
||||
//router.use('/log', require('./logLog'));
|
||||
|
||||
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user