-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
106 lines (90 loc) · 2.83 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
const express = require('express');
const bodyParser = require('body-parser');
const app = express();
const fetch = require('node-fetch');
app.use(bodyParser.json());
const distDir = __dirname + '/www/';
app.use(express.static(distDir));
app.get('/', function(req, res) {
res.sendFile(distDir + 'index.html');
});
app.get('/home', function(req, res) {
res.sendFile(distDir + 'index.html');
});
app.get('/tx/*', function(req, res) {
res.sendFile(distDir + 'index.html');
});
app.get('/block/*', function(req, res) {
res.sendFile(distDir + 'index.html');
});
app.get('/address/*', function(req, res) {
res.sendFile(distDir + 'index.html');
});
app.get('/ext/getmoneysupply', function(req, res) {
res.setHeader('Content-Type', 'application/json');
fetch('https://sapi.smartcash.cc/v1/blockchain/supply')
.then(res => res.json())
.then(json => {
res.send(json.CurrentSupply.toString());
});
});
// THOSE BLOCKS must use the right function from SAPI
// THEY MUST USE THE GET_RANDOM_SAPI function as well
app.get('/api/blocks', function(req, res) {
res.setHeader('Content-Type', 'application/json');
fetch('https://sapi.smartcash.cc/v1/')
.then(res => res.json())
.then(json => {
res.send(json);
});
});
app.get('/api/block/{hash}', function(req, res) {
res.setHeader('Content-Type', 'application/json');
fetch('https://sapi.smartcash.cc/v1/')
.then(res => res.json())
.then(json => {
res.send(json);
});
});
app.get('/api/transactions', function(req, res) {
res.setHeader('Content-Type', 'application/json');
fetch('https://sapi.smartcash.cc/v1/')
.then(res => res.json())
.then(json => {
res.send(json);
});
});
app.get('/api/transaction/{txid}', function(req, res) {
res.setHeader('Content-Type', 'application/json');
fetch('https://sapi.smartcash.cc/v1/')
.then(res => res.json())
.then(json => {
res.send(json);
});
});
app.get('/api/address/{address}', function(req, res) {
res.setHeader('Content-Type', 'application/json');
fetch('https://sapi.smartcash.cc/v1/')
.then(res => res.json())
.then(json => {
res.send(json);
});
});
//Melhor exemplo!
app.get('/api/smartrewards/roi', function(req, res) {
res.setHeader('Content-Type', 'application/json');
fetch('https://sapi.smartcash.cc/v1/smartrewards/roi')
.then(res => res.json())
.then(json => {
res.send(json);
});
});
app.get('/api/smartnode/roi', function(req, res) {
res.setHeader('Content-Type', 'application/json');
fetch('https://sapi.smartcash.cc/v1/smartnode/roi')
.then(res => res.json())
.then(json => {
res.send(json);
});
});
module.exports = app;