-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.js
69 lines (62 loc) · 1.99 KB
/
index.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
require('dotenv').config()
const express = require('express')
const ip = require('ip')
const app = express()
const cors = require("cors")
const config = {
"query": {
"v": 3,
"q": { "find": {} }
},
"host": process.env.slpstream_host ? process.env.slpstream_host : "http://127.0.0.1",
"port": Number.parseInt(process.env.slpstream_port ? process.env.slpstream_port : 3001)
};
config.url = config.host + ":" + config.port + "/s/";
var db
app.set('view engine', 'ejs')
app.use(express.static('public'))
app.use(cors())
app.enable("trust proxy")
app.get(/^\/channel\/(.+)/, function(req, res) {
let encoded = req.params[0]
let decoded = Buffer.from(encoded, 'base64').toString()
res.render('channel', {
bitserve_url: config.url,
code: decoded
})
});
app.get('/channel', function (req, res) {
res.render('channel', {
bitserve_url: config.url,
code: JSON.stringify(config.query, null, 2)
})
});
app.get('/', function(req, res) {
res.redirect('/channel')
});
app.listen(config.port, () => {
console.log("######################################################################################");
console.log("#")
console.log("# SLPStream: SLPsocket upgraded with gs++")
console.log("# Serving Transactions through HTTP...")
console.log("#")
console.log(`# Channel: ${ip.address()}:${config.port}/channel`);
console.log("#")
console.log("# Learn more at https://docs.fountainhead.cash")
console.log("#")
console.log("######################################################################################");
}
)
const bit = require("./bit")
const socket = require("./socket")
const connections = { pool: {} };
bit.init({
host: process.env.zmq_outgoing_host ? process.env.zmq_outgoing_host : '0.0.0.0',
port: Number.parseInt(process.env.zmq_outgoing_port ? process.env.zmq_outgoing_port : 28339),
connections: connections,
});
socket.init({
port: process.env.slpstream_port ? process.env.slpstream_port : 3000,
app: app,
connections: connections,
});