-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.js
62 lines (42 loc) · 1.45 KB
/
app.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
55
56
57
58
59
60
61
62
var express = require('express');
var request = require("request");
var app = express();
app.use((req, res, next) => {
res.header("Access-Control-Allow-Origin", "*");
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
res.header('Content-Type', 'application/json');
next();
});
//getrequest
app.get('/sondepremler', (req, res) => {
var options = { method: 'POST',
url: 'https://deprem.afad.gov.tr/latestCatalogsList',
headers:
{
'header-to-cache': 'm_0utc_0lastDay_1',
'content-type': 'multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW' },
formData: { m: '0', utc: '0', lastDay: '1', page: '0' } };
request(options, function (error, response, body) {
if (error) console.error(error)
body = JSON.parse(body);
let json = body.map(obj =>{
return{
"zaman":obj.time,
"enlem":obj.lat,
"boylam":obj.lon,
"derinlik":obj.depth,
"tip":obj.type,
"buyukluk":obj.m,
"ulke":obj.country,
"il":obj.city,
"ilce":obj.district,
"mahalle":obj.town,
"bilgi":obj.other
}
});
res.status(200).end(JSON.stringify(json));
});
});
//app start
app.listen(process.env.PORT || 5000,()=>console.log("server start"));
module.exports = app;