-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 29847d3
Showing
11 changed files
with
3,880 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Core WebGlasses Services | ||
|
||
This project adds basic core functions to the WebGlasses project. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import Core from "wg-core"; | ||
declare const _default: Core.Service[]; | ||
export default _default; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var apphandler_1 = __importDefault(require("./src/apphandler")); | ||
var services = []; | ||
exports.default = services.concat(apphandler_1.default); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import Core from "wg-core"; | ||
declare const _default: Core.Service[]; | ||
export default _default; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
"use strict"; | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; | ||
result["default"] = mod; | ||
return result; | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var fs = __importStar(require("fs")); | ||
var wg_core_1 = __importDefault(require("wg-core")); | ||
var body_parser = require("body-parser"); | ||
wg_core_1.default.Driver.register({ | ||
method: "get", | ||
path: "/", | ||
handler: function (req, res) { | ||
var app = wg_core_1.default.Verification.getAppBySubdomain(req); | ||
if (app.id === false) { | ||
res.send("Could not find app!"); | ||
return; | ||
} | ||
var file_entry = app.entry || "index.html"; | ||
res.redirect("/" + file_entry); | ||
} | ||
}); | ||
wg_core_1.default.Driver.register({ | ||
method: "get", | ||
path: "/*", | ||
handler: function (req, res) { | ||
var app = wg_core_1.default.Verification.getAppBySubdomain(req); | ||
if (app.id === false) { | ||
res.send("Could not find app!"); | ||
return; | ||
} | ||
var filepath = req.params[0] || "index.html"; | ||
var app_fullpath = wg_core_1.default.Workfolder.app_path + "/" + app.package_name + "/" + app.entry + "/" + filepath; | ||
if (fs.existsSync(app_fullpath)) { | ||
var realpath_app_fullpath = fs.realpathSync(app_fullpath); | ||
res.sendFile(realpath_app_fullpath); | ||
} | ||
else { | ||
res.send("Could not find file!"); | ||
} | ||
} | ||
}); | ||
wg_core_1.default.Driver.register({ | ||
method: "post", | ||
path: "/api/install_app", | ||
parser: body_parser.json, | ||
handler: function (req, res) { | ||
var app = wg_core_1.default.Verification.getAppBySubdomain(req); | ||
if (app.id === false) { | ||
res.send("Could not find app!"); | ||
return; | ||
} | ||
if (wg_core_1.default.Permission.hasSpecificPermission(app.id, "apps_control")) { | ||
var request_body = req.body; | ||
if (typeof request_body === 'object') { | ||
var path = request_body === null || request_body === void 0 ? void 0 : request_body.path; | ||
if (path) { | ||
wg_core_1.default.Apps.installApp(path).then(function () { | ||
res.json({ error: 0, message: "App installed." }); | ||
}).catch(function (err) { | ||
res.json({ error: 1, message: err }); | ||
}); | ||
} | ||
else { | ||
res.json({ error: 1, message: "Invalid filepath." }); | ||
} | ||
} | ||
else { | ||
res.json({ error: 1, message: "Invalid body." }); | ||
} | ||
} | ||
else { | ||
res.json({ error: 1, message: "No permissions." }); | ||
} | ||
} | ||
}); | ||
wg_core_1.default.Driver.register({ | ||
method: "post", | ||
path: "/api/uninstall_app", | ||
parser: body_parser.json, | ||
handler: function (req, res) { | ||
var app = wg_core_1.default.Verification.getAppBySubdomain(req); | ||
if (app.id === false) { | ||
res.send("Could not find app!"); | ||
return; | ||
} | ||
if (wg_core_1.default.Permission.hasSpecificPermission(app.id, "apps_control")) { | ||
var request_body = req.body; | ||
if (typeof request_body === 'object') { | ||
var app_name = request_body === null || request_body === void 0 ? void 0 : request_body.app_name; | ||
if (app_name) { | ||
if (wg_core_1.default.Apps.uninstallApp(app_name)) { | ||
res.json({ error: 0, message: "App uninstalled." }); | ||
} | ||
else { | ||
res.json({ error: 1, message: "App could not be uninstalled." }); | ||
} | ||
} | ||
else { | ||
res.json({ error: 1, message: "Invalid filepath." }); | ||
} | ||
} | ||
else { | ||
res.json({ error: 1, message: "Invalid body." }); | ||
} | ||
} | ||
else { | ||
res.json({ error: 1, message: "No permissions." }); | ||
} | ||
} | ||
}); | ||
exports.default = wg_core_1.default.Driver.export(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import Core from "wg-core"; | ||
import AppHandler from "./src/apphandler"; | ||
const services: Array<Core.Service> = []; | ||
|
||
export default services.concat(AppHandler); |
Oops, something went wrong.