Commit d82589de authored by Jasper Verbeet's avatar Jasper Verbeet 🙇🏻

Update

parent ac1a2c37
......@@ -74,10 +74,10 @@ const setDbItem = (key, value, overwrite=true) => {
}
app.get('/api/notification', (req, res) => {
const newItem = getDbItem('new');
const newItem = getDbItem('opened');
if (newItem) {
setDbItem('new', false);
if (!newItem) {
setDbItem('opened', true);
const response = {
origin: getDbItem('origin'),
......@@ -95,7 +95,7 @@ app.get('/api/notification', (req, res) => {
});
app.get('/api/status', (req, res) => {
console.log(colors.yellow(`Polling from website`));
console.log(colors.yellow(`${new Date().toLocaleString()} Polling from website`));
res.json({result: getDbItem('status')});
});
......@@ -109,7 +109,7 @@ app.post('/api/shipment', (req, res) => {
}
setDbItem('status', 0);
setDbItem('new', true);
setDbItem('opened', false);
for (let val of expected) {
setDbItem(val, req.body[val]);
}
......@@ -119,7 +119,7 @@ app.post('/api/shipment', (req, res) => {
setTimeout(() => {
if (getDbItem('status') == 0) {
setDbItem('status', false);
setDbItem('new', false);
setDbItem('opened', true);
console.log(colors.red(`Timed out, declining...`));
}
}, 20000)
......@@ -147,7 +147,7 @@ app.post('/api/accept', (req, res) => {
});
app.post('/api/details', (req, res) => {
console.log(colors.yellow(`Polling from app`));
console.log(colors.yellow(`${new Date().toLocaleString()} Polling from app`));
const expected = ['total_weight', 'current_weight', 'long', 'lat',];
const exact = expected.filter((val) => !(val in req.body));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment