This repository has been archived by the owner on Mar 4, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ar.js
54 lines (45 loc) · 1.43 KB
/
ar.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
const express = require('express');
const app = express();
var request = require('sync-request');
app.get('/ar', (req, res) => res.send(twitAr()));
let time = () => {
var date = new Date();
return String(date.getHours()) + ':' + String(date.getMinutes())
}
function twitAr() {
getPost = (url) => {
let res;
res = request('POST', url);
return JSON.parse(res.getBody('utf8'));
}
getGet = (uuid) => {
let res;
res = request('get', 'http://143.107.45.126:30134/catalog/resources/' + uuid);
return JSON.parse(res.getBody('utf8'));
}
getGet2 = (url) => {
let res;
res = request('get', url);
return JSON.parse(res.getBody('utf8'));
}
let neighbors = ""
let a = getPost('http://143.107.45.126:30134/collector/resources/data?&capabilities[]=air_quality&start=3');
a.resources.map((s) => {
let len = s.capabilities.air_quality.length;
if(s.capabilities.air_quality[len - 1].air_quality === 'ruim' ||
s.capabilities.air_quality[len - 1].air_quality === 'muito ruim' ||
s.capabilities.air_quality[len - 1].air_quality === 'péssima' ) {
if(getGet(s.uuid).data.neighborhood != null) {
neighbors = neighbors + ", " + getGet(s.uuid).data.neighborhood;
}
}
})
let ret = time() +
" A qualidade do #ArEmSampa está boa."
if(neighbors != "") {
ret = ret + " Exceto nos bairro(s) " + neighbors + '.';
}
return ret;
}
app.listen(3002, () => console.log('Example app listening on port 3002!'))
// 9, 15, 21, 3