Skip to content

Commit

Permalink
Merge pull request #62 from eiabea/update-packages
Browse files Browse the repository at this point in the history
Update packages
  • Loading branch information
eiabea authored Oct 18, 2020
2 parents a126389 + 29ba548 commit afc95db
Show file tree
Hide file tree
Showing 10 changed files with 2,612 additions and 3,824 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ jobs:
language: node_js
cache: npm
node_js:
- 10.16.1
- 12.18.3
after_success:
- npm run codecov
on:
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM balenalib/rpi-node:10.16.1-stretch
FROM balenalib/rpi-node:12.18.3-stretch
LABEL eiabea <[email protected]>

ENV NODE_PATH=/root/node_modules
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -531,15 +531,15 @@ $ cd tempea-api

7. Start tempea in development mode
```
$ docker-compose up
$ docker-compose -f docker-compose.yml -f docker-compose-dev.yml up
```

## Testing

1. Make sure you have at least [NodeJS](https://nodejs.org/en/) v10.14.0 installed
1. Make sure you have at least [NodeJS](https://nodejs.org/en/) v12.18.3 installed
```
$ node -v
v10.14.0
v12.18.3
```

2. Clone the project on your machine
Expand Down
37 changes: 18 additions & 19 deletions controller/slave.controller.js
Original file line number Diff line number Diff line change
@@ -1,32 +1,31 @@
const request = require('request');
const axios = require('axios');
const { assert } = require('chai');

module.exports = (log, cache) => {
const getData = async () => new Promise((resolve, reject) => {
const getData = async () => {

const {
SLAVE_HOST, SLAVE_PORT, SLAVE_ENDPOINT,
} = process.env;

log.trace({ SLAVE_HOST, SLAVE_PORT, SLAVE_ENDPOINT }, 'Getting data from slave');
request(`http://${SLAVE_HOST}:${SLAVE_PORT}${SLAVE_ENDPOINT}`, async (error, response, body) => {
if (error) {
log.error({ error }, `Error getting data from slave ${SLAVE_HOST}`);
return reject(error);
}
log.trace({ body }, 'Received data from slave');
try {
const jsonData = JSON.parse(body);
try {
const response = await axios.get(`http://${SLAVE_HOST}:${SLAVE_PORT}${SLAVE_ENDPOINT}`);

const { data } = response;

assert.isTrue(jsonData.success);
assert.isDefined(jsonData.data);
assert.isNumber(jsonData.data.temp);
assert.isTrue(data.success);
assert.isDefined(data.data);
assert.isNumber(data.data.temp);

await cache.updateSlaveData(jsonData.data);
return resolve(jsonData.data);
} catch (err) {
return reject(err);
}
});
});
await cache.updateSlaveData(data.data);
return data.data;
} catch (error) {
log.error({ error }, `Error getting data from slave ${SLAVE_HOST}`);
throw error;
}
}

return {
getData,
Expand Down
17 changes: 17 additions & 0 deletions docker-compose-dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
version: "3"

services:
tempea:
build: .
restart: unless-stopped
privileged: "true"
ports:
- "3000:3000"
volumes:
- "./:/src"
command: [
"wait-for-it.sh", "influx:8086","--timeout=60", "--",
"npm", "run", "start:dev:pretty"
]
env_file:
- tempea.env
8 changes: 4 additions & 4 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ volumes:

services:
grafana:
image: "grafana/grafana:5.4.3"
image: "grafana/grafana:7.2.1"
restart: unless-stopped
ports:
- "3001:3000"
volumes:
- "grafana:/var/lib/grafana"

mqtt:
image: "eclipse-mosquitto:1.6.7"
image: "eclipse-mosquitto:1.6.12"
restart: unless-stopped
ports:
- "1883:1883"
Expand All @@ -27,15 +27,15 @@ services:
- "mqtt:/mosquitto/data"

telegraf:
image: "telegraf:1.12.4"
image: "telegraf:1.15.2"
restart: unless-stopped
depends_on:
- "mqtt"
volumes:
- ./telegraf.conf:/etc/telegraf/telegraf.conf:ro

influx:
image: "arm32v7/influxdb:1.7.8"
image: "arm32v7/influxdb:1.8.2"
restart: unless-stopped
ports:
- "8086:8086"
Expand Down
Loading

0 comments on commit afc95db

Please sign in to comment.