mirror of
https://github.com/lucaspalomodevelop/JSSTE_APP.git
synced 2026-03-13 00:07:22 +00:00
add dashboard enable check + functionality
This commit is contained in:
parent
8694ced81d
commit
60dd9404b4
@ -13,7 +13,9 @@ let os = require("os");
|
||||
*/
|
||||
websrv.slisten((host, port) => {
|
||||
console.log("Server started on http://" + host + ":" + port);
|
||||
open("http://" + host + ":" + port + "/dashboard");
|
||||
websrv.dashboardExist(()=>{
|
||||
open("http://" + host + ":" + port + "/dashboard");
|
||||
})
|
||||
});
|
||||
|
||||
/**
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
const res = require("express/lib/response");
|
||||
|
||||
module.exports = function (conf) {
|
||||
const websrvConfig = conf.webserver;
|
||||
const express = require("express");
|
||||
@ -11,6 +13,14 @@ module.exports = function (conf) {
|
||||
|
||||
const internalRouter = require("./routes/internalRouter");
|
||||
|
||||
app.dashboardExist = (cb) => {
|
||||
let result = fs.existsSync(path.join(__dirname, "../../dashboard/"));
|
||||
if (result) {
|
||||
cb();
|
||||
}
|
||||
return result;
|
||||
};
|
||||
|
||||
app.use((req, res, next) => {
|
||||
var start = process.hrtime();
|
||||
res.on("finish", () => {
|
||||
@ -26,10 +36,22 @@ module.exports = function (conf) {
|
||||
app.use(bodyParser.json());
|
||||
app.use(cookieParser());
|
||||
app.use("/api", internalRouter);
|
||||
app.use("/dashboard", express.static(__dirname + "/../../dashboard/build"));
|
||||
app.get("/dashboard/*", (req, res) => {
|
||||
let indexPath = path.join(__dirname + "/../../dashboard/build/index.html");
|
||||
res.sendFile(indexPath);
|
||||
|
||||
app.dashboardExist(() => {
|
||||
app.use("/dashboard", express.static(__dirname + "/../../dashboard/build"));
|
||||
app.get("/dashboard/*", (req, res) => {
|
||||
let indexPath = path.join(
|
||||
__dirname + "/../../dashboard/build/index.html"
|
||||
);
|
||||
res.sendFile(indexPath);
|
||||
});
|
||||
console.log(
|
||||
"Dashboard is enabled on http://" +
|
||||
websrvConfig.host +
|
||||
":" +
|
||||
websrvConfig.port +
|
||||
"/dashboard"
|
||||
);
|
||||
});
|
||||
|
||||
app.slisten = function (cb) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user