add internal route

This commit is contained in:
lucaspalomodevelop 2022-02-18 21:58:09 +01:00
parent 58fd344ded
commit 1b9688ea57
7 changed files with 34 additions and 12 deletions

1
.gitignore vendored
View File

@ -3,6 +3,7 @@
files/*
# Logs
logs
*.log

View File

@ -1,3 +1,3 @@
# JSSTE_APP
The full Application from the [JSSTE](https://github.com/lucaspalomodevelop/JSSTE) project.
The full application from the [JSSTE](https://github.com/lucaspalomodevelop/JSSTE) project.

View File

@ -2,16 +2,21 @@ const { get } = require("express/lib/request");
let fs = require("fs");
let path = require("path");
let process = require("process");
let instance = null;
module.exports = function (optPath) {
if (instance !== null) {
return instance;
}
let cname = ".jssteconfig";
let cpath = path.join(__dirname, "..", "..");
let conf = getCurrentConfig(cpath)
let conf = getCurrentConfig(cpath);
if (conf.jsste.paths.files) {
conf.jsste.paths.files = path.join(cpath, conf.jsste.paths.files);
}
conf.workingdir = process.cwd();
instance = conf;
return conf;
};

View File

@ -1,8 +1,8 @@
let conf = require("./helper/conf")();
// let jsste = require("./jsste")(conf.jsste);
// let jsste = require("./jsste")(conf);
let websrv = require("./websrv")(conf);
console.log("jssteconfig", conf);
// console.log("jssteconfig", conf);
websrv.slisten(() => {
console.log(

View File

@ -3,3 +3,6 @@ app.instance = {};
app.static = function (constante, cb, instance = app.instance) {};
app.specialvars = function (variable_regex, valor, instance = app.instance) {};
app.render = function (pagecode, templatecode) {};

View File

@ -6,16 +6,19 @@ module.exports = function (conf) {
const cookieParser = require("cookie-parser");
const fs = require("fs");
const internalRouter = require("./routes/internalRouter");
app.use(bodyParser.json());
app.use(cookieParser());
app.get("/", (req, res) => {
let files = [];
fs.readdirSync(conf.jsste.paths.files).forEach((file) => {
files.push(file);
});
res.json(files);
});
app.use("/internal", internalRouter);
// app.get("/config", (req, res) => {
// // let files = [];
// // fs.readdirSync(conf.jsste.paths.files).forEach((file) => {
// // files.push(file);
// // });
// res.json(conf);
// });
app.slisten = function (cb) {
app.listen(websrvConfig.port, websrvConfig.host, cb);

View File

@ -0,0 +1,10 @@
const conf = require("../../helper/conf")();
const express = require("express");
const router = express.Router();
router.get("/conf", (req, res) => {
console.log(conf);
res.json(conf);
});
module.exports = router;