-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
49 lines (45 loc) · 1.04 KB
/
server.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
const express = require('express')
var price = 69000.0
setInterval( () => {
price = price / 2.0
if (price < 0.001) {
price = 69000.0
}
}, 10000)
const mockResponse = (symbol, response) => {
if (symbol && symbol.length > 1) {
response.send({
'symbol': symbol,
'priceChange': 0.0,
'priceChangePercent': 0.0,
'weightedAvgPrice': 0.0,
'openPrice': 0.0,
'highPrice': 0.0,
'lowPrice': 0.0,
'lastPrice': price,
'volume': 0.0,
'quoteVolume': 0.0,
'openTime': 0,
'closeTime': 0,
'firstId': 0,
'lastId': 0,
'count': 0
})
} else {
response.status(500).send({
'code': -1121,
'msg': 'Invalid symbol.'
})
}
}
express()
.use(express.json())
.get("/api/v3/ticker", (request, response) => {
console.log('Got GET', request)
mockResponse(request.query.symbol, response)
})
.post("/api/v3/ticker", (request, response) => {
console.log('Got POST', request)
mockResponse(request.body.symbol, response)
})
.listen(80)