mirror of
https://github.com/lucaspalomodevelop/JSSTE_APP.git
synced 2026-03-13 08:09:38 +00:00
add internal route
This commit is contained in:
parent
58fd344ded
commit
1b9688ea57
1
.gitignore
vendored
1
.gitignore
vendored
@ -3,6 +3,7 @@
|
||||
|
||||
files/*
|
||||
|
||||
|
||||
# Logs
|
||||
logs
|
||||
*.log
|
||||
|
||||
@ -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.
|
||||
@ -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;
|
||||
};
|
||||
|
||||
|
||||
@ -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(
|
||||
|
||||
@ -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) {};
|
||||
|
||||
|
||||
|
||||
@ -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);
|
||||
|
||||
10
src/websrv/routes/internalRouter.js
Normal file
10
src/websrv/routes/internalRouter.js
Normal 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;
|
||||
Loading…
x
Reference in New Issue
Block a user