lbry.tech/server.js

46 lines
1 KiB
JavaScript
Raw Normal View History

2018-03-28 16:26:59 +02:00
// server.js
2018-03-29 08:24:59 +02:00
var sslRedirect = require('heroku-ssl-redirect');
2018-03-28 16:26:59 +02:00
var express = require('express');
var path = require('path');
var serveStatic = require('serve-static');
2018-04-10 11:08:46 +02:00
var request = require('request');
var cors = require('cors');
2018-03-28 16:26:59 +02:00
app = express();
2018-04-20 15:17:16 +02:00
app.use(serveStatic(__dirname + "/.vuepress/dist"));
2018-03-28 16:26:59 +02:00
2018-04-10 11:08:46 +02:00
app.use(cors());
2018-03-29 08:24:59 +02:00
// enable ssl redirect
2018-03-29 08:28:54 +02:00
app.use(sslRedirect(['other','development', 'staging', 'production']));
2018-03-29 08:24:59 +02:00
2018-04-10 11:08:46 +02:00
app.get('/forward', function(req, res) {
if(typeof req.query.method != "undefined") {
// We should whitelist the query parameters here
2018-04-16 15:39:11 +02:00
// Hardcode the wallet_send amount to be 0.01 always
if(req.query.method == "wallet_send") {
req.query.amount = 0.01;
}
2018-04-10 11:08:46 +02:00
request({
url: "http://daemon.lbry.tech",
qs: req.query
}, function(error, response, body) {
// Should we parse the body before forwarding?
res.setHeader('Content-Type', 'application/json');
res.send(body);
})
}
});
2018-03-29 08:24:59 +02:00
var port = process.env.PORT || 8080;
2018-03-28 16:26:59 +02:00
app.listen(port);
console.log('server started '+ port);