2018-09-15 01:31:01 +00:00
|
|
|
const path = require("path");
|
|
|
|
const express = require("express");
|
|
|
|
const bodyParser = require("body-parser");
|
|
|
|
const app = express();
|
|
|
|
|
|
|
|
//Declare all Routes here
|
|
|
|
const infoRoutes = require("./routes/getInfo");
|
|
|
|
const channelsRoutes = require("./routes/channels");
|
|
|
|
const peersRoutes = require("./routes/peers");
|
|
|
|
const feesRoutes = require("./routes/fees");
|
|
|
|
const balanceRoutes = require("./routes/balance");
|
|
|
|
const walletRoutes = require("./routes/wallet");
|
2018-09-27 02:02:46 +00:00
|
|
|
const graphInfoRoutes = require("./routes/graphInfo");
|
|
|
|
const newAddressRoutes = require("./routes/newAddress");
|
|
|
|
const transactionsRoutes = require("./routes/transactions");
|
2018-09-15 01:31:01 +00:00
|
|
|
const UISettingsRoutes = require("./routes/UISettings");
|
2018-10-01 23:11:28 +00:00
|
|
|
const LNDSettingsRoutes = require("./routes/lndConfSettings");
|
2018-09-15 01:31:01 +00:00
|
|
|
|
|
|
|
app.use(bodyParser.json());
|
|
|
|
app.use(bodyParser.urlencoded({ extended: false }));
|
|
|
|
app.use("/", express.static(path.join(__dirname, "angular")));
|
|
|
|
|
|
|
|
// CORS fix, Only required for developement due to separate backend and frontend servers
|
|
|
|
app.use((req, res, next) => {
|
|
|
|
res.setHeader("Access-Control-Allow-Origin", "*");
|
|
|
|
res.setHeader(
|
|
|
|
"Access-Control-Allow-Headers",
|
2018-10-01 23:11:28 +00:00
|
|
|
"Origin, X-Requested-With, Content-Type, Accept, Authorization, filePath"
|
2018-09-15 01:31:01 +00:00
|
|
|
);
|
|
|
|
res.setHeader(
|
|
|
|
"Access-Control-Allow-Methods",
|
|
|
|
"GET, POST, PATCH, PUT, DELETE, OPTIONS"
|
|
|
|
);
|
|
|
|
next();
|
|
|
|
});
|
|
|
|
// CORS fix, Only required for developement due to separate backend and frontend servers
|
|
|
|
|
|
|
|
// Use declared routes here
|
|
|
|
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);
|
2018-09-27 02:02:46 +00:00
|
|
|
app.use("/api/network", graphInfoRoutes);
|
|
|
|
app.use("/api/newaddress", newAddressRoutes);
|
|
|
|
app.use("/api/transactions", transactionsRoutes);
|
2018-09-15 01:31:01 +00:00
|
|
|
app.use("/api/uisettings", UISettingsRoutes);
|
2018-10-01 23:11:28 +00:00
|
|
|
app.use("/api/lndconf", LNDSettingsRoutes);
|
2018-09-15 01:31:01 +00:00
|
|
|
|
|
|
|
// sending angular application when route doesn't match
|
|
|
|
app.use((req, res, next) => {
|
|
|
|
res.sendFile(path.join(__dirname, "angular", "index.html"));
|
|
|
|
});
|
|
|
|
|
|
|
|
module.exports = app;
|