-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
47 lines (42 loc) · 1.06 KB
/
server.js
File metadata and controls
47 lines (42 loc) · 1.06 KB
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
require('coffee-script/register')
const express = require('express')
const app = express()
const port = process.env.PORT || 8080
let {getJson} = require('art-rest-client')
app.get('/hello', (req, res) => res.send('Hello World!'))
app.get('/json_test', function (req, res) {
res.json({
postfix: "Cool Seconds",
color: "blue",
data: { value: `${(new Date).getSeconds()}` }
});
});
app.get('/iss', (req, res) => {
getJson("http://api.open-notify.org/iss-now.json")
.then (({iss_position}) => {
let {latitude, longitude} = iss_position;
res.json({
postfix: "coordinates", color: "green", data: [{value: latitude}, {value: longitude}]
})
})
});
app.get('/json_graph', function (req, res) {
res.json({
color: "green",
data: [
{
name: "Jean-Luc Picard",
value: 1450
},
{
name: "James T. Kirk",
value: 350
},
{
name: "Kathryn Janeway",
value: 1850
}
]
});
});
app.listen(port, () => console.log(`Example app listening at http://localhost:${port}`))