Version erhöht, Log beim Anmelden an der Mongo entfernt
This commit is contained in:
@@ -16,7 +16,7 @@ export const getOneProperty = async (params) => {
|
|||||||
}
|
}
|
||||||
// read 'chip'-data (special for noise sensors)
|
// read 'chip'-data (special for noise sensors)
|
||||||
const chipdata = await readChipData(opts.sensorid)
|
const chipdata = await readChipData(opts.sensorid)
|
||||||
if (chipdata.err == undefined) {
|
if (chipdata.err === null) {
|
||||||
properties.chip = chipdata
|
properties.chip = chipdata
|
||||||
}
|
}
|
||||||
let sensorEntries = [];
|
let sensorEntries = [];
|
||||||
|
|||||||
@@ -84,7 +84,6 @@ function onError(error) {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
function onListening() {
|
function onListening() {
|
||||||
console.log('DEBUG:', process.env.DEBUG, process.env.INFLUXHOST)
|
|
||||||
const addr = server.address();
|
const addr = server.address();
|
||||||
const bind = typeof addr === 'string'
|
const bind = typeof addr === 'string'
|
||||||
? 'pipe ' + addr
|
? 'pipe ' + addr
|
||||||
|
|||||||
+1
-1
@@ -163,4 +163,4 @@ peak = data
|
|||||||
${small}
|
${small}
|
||||||
`
|
`
|
||||||
return await fetchFromInflux(ret, queryAVG)
|
return await fetchFromInflux(ret, queryAVG)
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-3
@@ -28,9 +28,9 @@ export const properties_collection = 'properties'
|
|||||||
|
|
||||||
export const connectMongo = async () => {
|
export const connectMongo = async () => {
|
||||||
try {
|
try {
|
||||||
logit(`Try to connect to ${MONGO_URL}`)
|
// logit(`Try to connect to ${MONGO_URL}`)
|
||||||
let client = await MongoClient.connect(MONGO_URL)
|
let client = await MongoClient.connect(MONGO_URL)
|
||||||
logit(`Mongodbase connected to ${MONGO_URL}`)
|
// logit(`Mongodbase connected to ${MONGO_URL}`)
|
||||||
return client
|
return client
|
||||||
}
|
}
|
||||||
catch(error){
|
catch(error){
|
||||||
@@ -55,7 +55,7 @@ export const readProperties = async (query, limit = 0) => {
|
|||||||
let client = await connectMongo()
|
let client = await connectMongo()
|
||||||
try {
|
try {
|
||||||
if ("sid" in query) { // if sid is given, read property for sid
|
if ("sid" in query) { // if sid is given, read property for sid
|
||||||
ret.properties = await client.db(MONGOBASE).collection('properties_collection').findOne({_id: query.sid})
|
ret.properties = await client.db(MONGOBASE).collection(properties_collection).findOne({_id: query.sid})
|
||||||
} else { // otherwise read props corresponding to query
|
} else { // otherwise read props corresponding to query
|
||||||
ret.properties = await client.db(MONGOBASE).collection(properties_collection).find(query).limit(limit).toArray()
|
ret.properties = await client.db(MONGOBASE).collection(properties_collection).find(query).limit(limit).toArray()
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-1
@@ -1,10 +1,11 @@
|
|||||||
{
|
{
|
||||||
"name": "sensorapi",
|
"name": "sensorapi",
|
||||||
"version": "1.4.1",
|
"version": "1.4.2",
|
||||||
"date": "2023-11-29 16:00 UTC",
|
"date": "2023-11-29 16:00 UTC",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "node ./bin/www.js >>/var/log/sensorapi.log 2>&1",
|
"start": "node ./bin/www.js >>/var/log/sensorapi.log 2>&1",
|
||||||
|
"dev": "node ./bin/www.js",
|
||||||
"test": "mocha ./test/test.js"
|
"test": "mocha ./test/test.js"
|
||||||
},
|
},
|
||||||
"type": "module",
|
"type": "module",
|
||||||
|
|||||||
Reference in New Issue
Block a user