occupant name
This commit is contained in:
parent
d4697311e9
commit
b46ed73d15
8
dist/main.js
vendored
8
dist/main.js
vendored
@ -3,13 +3,19 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const express = require("express");
|
||||
const logger = require("./log");
|
||||
const bodyParser = require("body-parser");
|
||||
const config = require("./config");
|
||||
const app = express();
|
||||
app.use(bodyParser.urlencoded({ extended: false }));
|
||||
app.use(bodyParser.json());
|
||||
app.post('/', (req, res) => {
|
||||
const reqData = req.body;
|
||||
const deviceId = reqData.device;
|
||||
let occupantName = 'unknown';
|
||||
if (deviceId in config.dict.occupants) {
|
||||
occupantName = config.dict.occupants[deviceId];
|
||||
}
|
||||
const direction = (reqData.entry == '1') ? 'arrives' : 'leaves';
|
||||
logger.info(`${reqData.device} ${direction}`);
|
||||
logger.info(`${deviceId} (${occupantName}) ${direction}`);
|
||||
logger.info(JSON.stringify(reqData));
|
||||
res.send('OK');
|
||||
});
|
||||
|
@ -6,5 +6,8 @@
|
||||
"smtpHost": "localhost",
|
||||
"smtpPort": 25,
|
||||
"smtpSender": "geofences@hottis.de",
|
||||
"smtpReceiver": "woho@hottis.de"
|
||||
"smtpReceiver": "woho@hottis.de",
|
||||
"occupants": {
|
||||
"386D105B-80D0-4708-95AB-77B4D1E36D0E": "Wolfgang"
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ import * as http from 'http'
|
||||
import * as express from 'express'
|
||||
import * as logger from './log'
|
||||
import * as bodyParser from 'body-parser'
|
||||
import * as config from './config'
|
||||
|
||||
const app = express()
|
||||
app.use(bodyParser.urlencoded({ extended: false }));
|
||||
@ -10,8 +11,13 @@ app.use(bodyParser.json());
|
||||
|
||||
app.post('/', (req, res) => {
|
||||
const reqData = req.body
|
||||
const deviceId = reqData.device
|
||||
let occupantName : string = 'unknown'
|
||||
if (deviceId in config.dict.occupants) {
|
||||
occupantName = config.dict.occupants[deviceId]
|
||||
}
|
||||
const direction : string = (reqData.entry == '1') ? 'arrives' : 'leaves'
|
||||
logger.info(`${reqData.device} ${direction}`)
|
||||
logger.info(`${deviceId} (${occupantName}) ${direction}`)
|
||||
logger.info(JSON.stringify(reqData))
|
||||
res.send('OK')
|
||||
})
|
||||
|
Loading…
x
Reference in New Issue
Block a user