forked from LHerskind/TokenFlow
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
37 lines (31 loc) · 804 Bytes
/
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
const express = require("express");
var tools = require("./tools.js");
const cors = require("cors");
const app = express();
const { PORT = 3000 } = process.env;
app.use(cors());
app.set("view engine", "ejs");
app.set("views", __dirname + "/views");
app.use(express.static("./public"));
app.get("/", (req, res) => {
res.render("index");
});
app.get("/tx/:txhash", (req, res) => {
res.render("index");
});
app.get("/transfers/:txhash", (req, res) => {
let txhash = req.params.txhash;
tools
.getTransfers(txhash)
.then((transfers) => {
res.status(200).send(transfers);
})
.catch((err) => {
console.log(err);
let pokkers = {desc: "There was an error :(", err: err}
res.status(200).send(pokkers);
});
});
app.listen(PORT, () => {
console.log(`server started at ${PORT}`);
});