Adding relative path to api

pull/60/head
ShahanaFarooqui 5 years ago
parent 4f11b3f154
commit 2f262cf647

@ -8,5 +8,5 @@
<link rel="stylesheet" href="styles.7e944f30e4357f41ed14.css"></head>
<body>
<rtl-app></rtl-app>
<script type="text/javascript" src="runtime.ec2944dd8b20ec099bf3.js"></script><script type="text/javascript" src="polyfills.418928a701f2040ada02.js"></script><script type="text/javascript" src="main.42dcb4b10e822b3edf67.js"></script></body>
<script type="text/javascript" src="runtime.ec2944dd8b20ec099bf3.js"></script><script type="text/javascript" src="polyfills.418928a701f2040ada02.js"></script><script type="text/javascript" src="main.6ae72405689159511d30.js"></script></body>
</html>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -20,10 +20,12 @@ const paymentsRoutes = require("./routes/payments");
const RTLConfRoutes = require("./routes/RTLConf");
const invoiceRoutes = require("./routes/invoices");
const switchRoutes = require("./routes/switch");
const baseHref = '/rtl/';
const apiRoot = baseHref + 'api/';
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(common.ng_api_root, express.static(path.join(__dirname, "angular")));
app.use(baseHref, express.static(path.join(__dirname, "angular")));
// CORS fix, Only required for developement due to separate backend and frontend servers
app.use((req, res, next) => {
@ -41,24 +43,27 @@ app.use((req, res, next) => {
// CORS fix, Only required for developement due to separate backend and frontend servers
// Use declared routes here
app.use("/api/authenticate", authenticateRoutes);
app.use("/api/getinfo", infoRoutes);
app.use("/api/channels", channelsRoutes);
app.use("/api/peers", peersRoutes);
app.use("/api/fees", feesRoutes);
app.use("/api/balance", balanceRoutes);
app.use("/api/wallet", walletRoutes);
app.use("/api/network", graphRoutes);
app.use("/api/newaddress", newAddressRoutes);
app.use("/api/transactions", transactionsRoutes);
app.use("/api/payreq", payReqRoutes);
app.use("/api/payments", paymentsRoutes);
app.use("/api/conf", RTLConfRoutes);
app.use("/api/invoices", invoiceRoutes);
app.use("/api/switch", switchRoutes);
app.use(apiRoot + "authenticate", authenticateRoutes);
app.use(apiRoot + "getinfo", infoRoutes);
app.use(apiRoot + "channels", channelsRoutes);
app.use(apiRoot + "peers", peersRoutes);
app.use(apiRoot + "fees", feesRoutes);
app.use(apiRoot + "balance", balanceRoutes);
app.use(apiRoot + "wallet", walletRoutes);
app.use(apiRoot + "network", graphRoutes);
app.use(apiRoot + "newaddress", newAddressRoutes);
app.use(apiRoot + "transactions", transactionsRoutes);
app.use(apiRoot + "payreq", payReqRoutes);
app.use(apiRoot + "payments", paymentsRoutes);
app.use(apiRoot + "conf", RTLConfRoutes);
app.use(apiRoot + "invoices", invoiceRoutes);
app.use(apiRoot + "switch", switchRoutes);
// sending angular application when route doesn't match
app.use((req, res, next) => {
console.log(apiRoot);
console.log(req.url);
res.sendFile(path.join(__dirname, "angular", "index.html"));
});

@ -138,10 +138,12 @@ exports.postTransactions = (req, res, next) => {
};
exports.closeChannel = (req, res, next) => {
req.setTimeout(60000 * 10); // timeout 10 mins
let channelpoint = req.params.channelPoint.replace(':', '/');
options.url = common.lnd_server_url + '/channels/' + channelpoint + '?force=' + req.query.force;
logger.info('\r\nChannels: 144: ' + JSON.stringify(Date.now()) + ': INFO: Closing Channel: ' + options.url);
request.delete(options).then((body) => {
logger.info('\r\nChannels: 134: ' + JSON.stringify(Date.now()) + ': INFO: Close Channel Response: ' + JSON.stringify(body));
logger.info('\r\nChannels: 146: ' + JSON.stringify(Date.now()) + ': INFO: Close Channel Response: ' + JSON.stringify(body));
if(undefined === body || body.error) {
res.status(500).json({
message: 'Close Channel Failed!',
@ -152,7 +154,7 @@ exports.closeChannel = (req, res, next) => {
}
})
.catch(function (err) {
logger.info('\r\nChannels: 146: ' + JSON.stringify(Date.now()) + ': ERROR: Close Channel: ' + JSON.stringify(err));
logger.info('\r\nChannels: 157: ' + JSON.stringify(Date.now()) + ': ERROR: Close Channel: ' + JSON.stringify(err));
return res.status(500).json({
message: 'Close Channel Failed!',
error: err.error
@ -180,9 +182,9 @@ exports.postChanPolicy = (req, res, next) => {
chan_point: {funding_txid_str: txid_str, output_index: parseInt(output_idx)}
});
}
logger.info('\r\nChannels: 161: ' + JSON.stringify(Date.now()) + ': INFO: Update Channel Policy Options: ' + JSON.stringify(options));
logger.info('\r\nChannels: 185: ' + JSON.stringify(Date.now()) + ': INFO: Update Channel Policy Options: ' + JSON.stringify(options));
request.post(options).then((body) => {
logger.info('\r\nChannels: 163: ' + JSON.stringify(Date.now()) + ': INFO: Update Channel Policy: ' + JSON.stringify(body));
logger.info('\r\nChannels: 187: ' + JSON.stringify(Date.now()) + ': INFO: Update Channel Policy: ' + JSON.stringify(body));
if(undefined === body || body.error) {
res.status(500).json({
message: 'Update Channel Failed!',
@ -193,7 +195,7 @@ exports.postChanPolicy = (req, res, next) => {
}
})
.catch(function (err) {
logger.info('\r\nChannels: 177: ' + JSON.stringify(Date.now()) + ': ERROR: Update Channel Policy: ' + JSON.stringify(err));
logger.info('\r\nChannels: 198: ' + JSON.stringify(Date.now()) + ': ERROR: Update Channel Policy: ' + JSON.stringify(err));
return res.status(500).json({
message: 'Update Channel Failed!',
error: err.error

2
package-lock.json generated

@ -1,6 +1,6 @@
{
"name": "rtl",
"version": "0.2.6-beta",
"version": "0.2.7-beta",
"lockfileVersion": 1,
"requires": true,
"dependencies": {

@ -1,6 +1,6 @@
{
"name": "rtl",
"version": "0.2.6-beta",
"version": "0.2.7-beta",
"license": "MIT",
"scripts": {
"ng": "ng",

Loading…
Cancel
Save