bug fix
This commit is contained in:
5
.gitignore
vendored
5
.gitignore
vendored
@@ -17,5 +17,6 @@ package-lock.json
|
|||||||
settings.json
|
settings.json
|
||||||
Procfile
|
Procfile
|
||||||
dump.rdb
|
dump.rdb
|
||||||
error.log
|
error.log
|
||||||
output.log
|
output.log
|
||||||
|
Dockerfile
|
||||||
31
controller/device.get.controller.js
Normal file
31
controller/device.get.controller.js
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
const configs = require("../configs");
|
||||||
|
const DeviceModel = require("../models/device.model");
|
||||||
|
|
||||||
|
const get = async (token, device_id) => {
|
||||||
|
if (token === configs.verifyToken) {
|
||||||
|
console.log(device_id);
|
||||||
|
try {
|
||||||
|
if (!device_id) {
|
||||||
|
// device_id verilmemişse bütün cihazalara ait bilgileri getir
|
||||||
|
const result = await DeviceModel.find({});
|
||||||
|
return result;
|
||||||
|
} else {
|
||||||
|
// device_id verilmişse sadece o cihaza ait bilgi getir
|
||||||
|
const result = await DeviceModel.findOne({
|
||||||
|
_id: device_id
|
||||||
|
});
|
||||||
|
if (result) {
|
||||||
|
return result;
|
||||||
|
} else {
|
||||||
|
throw new Error("Cihaz bulunamadı!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
throw new Error(error.message);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
throw new Error("Hatalı token (set.controller)");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = { get };
|
||||||
@@ -1,4 +1,3 @@
|
|||||||
const config = require("../configs");
|
|
||||||
const configs = require("../configs");
|
const configs = require("../configs");
|
||||||
const Library = require("../library");
|
const Library = require("../library");
|
||||||
const DeviceModel = require("../models/device.model");
|
const DeviceModel = require("../models/device.model");
|
||||||
|
|||||||
Reference in New Issue
Block a user