diff --git a/.gitignore b/.gitignore index 382e666..530bc1e 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ files/* + # Logs logs *.log diff --git a/README.md b/README.md index f9a2a55..84814db 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,3 @@ # JSSTE_APP -The full Application from the [JSSTE](https://github.com/lucaspalomodevelop/JSSTE) project. \ No newline at end of file +The full application from the [JSSTE](https://github.com/lucaspalomodevelop/JSSTE) project. \ No newline at end of file diff --git a/src/helper/conf.js b/src/helper/conf.js index a40ee91..045e129 100644 --- a/src/helper/conf.js +++ b/src/helper/conf.js @@ -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; }; diff --git a/src/index.js b/src/index.js index 73eed93..c88d8b2 100644 --- a/src/index.js +++ b/src/index.js @@ -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( diff --git a/src/jsste/index.js b/src/jsste/index.js index aadd010..4b23055 100644 --- a/src/jsste/index.js +++ b/src/jsste/index.js @@ -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) {}; + + diff --git a/src/websrv/index.js b/src/websrv/index.js index a77a547..54e9695 100644 --- a/src/websrv/index.js +++ b/src/websrv/index.js @@ -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); diff --git a/src/websrv/routes/internalRouter.js b/src/websrv/routes/internalRouter.js new file mode 100644 index 0000000..90de360 --- /dev/null +++ b/src/websrv/routes/internalRouter.js @@ -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;