modif setup
This commit is contained in:
parent
029f942ecd
commit
70b1d5f5cb
@ -39,7 +39,7 @@ apxtri.main = async () => {
|
|||||||
.forEach(async (t) => {
|
.forEach(async (t) => {
|
||||||
const tribe = path.basename(t);
|
const tribe = path.basename(t);
|
||||||
//console.log(tribe);
|
//console.log(tribe);
|
||||||
if (![".",".."].includes(tribe) && !tribesdns[tribe]) {
|
if (![".", ".."].includes(tribe) && !tribesdns[tribe]) {
|
||||||
await apxtri.setuptribe(tribe, conf);
|
await apxtri.setuptribe(tribe, conf);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -101,6 +101,9 @@ apxtri.setuptribe = async (tribe, conf) => {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
console.log(`a new tribe called ${tribe} was detected`);
|
console.log(`a new tribe called ${tribe} was detected`);
|
||||||
|
const adminapiconf = fs.readJSONSync(
|
||||||
|
"../adminapi/objects/tribes/itm/adminapi.json"
|
||||||
|
);
|
||||||
inittribe = {
|
inittribe = {
|
||||||
tribeId: tribe,
|
tribeId: tribe,
|
||||||
townpath: __dirname.replace("/adminapi/apxtri", ""),
|
townpath: __dirname.replace("/adminapi/apxtri", ""),
|
||||||
@ -109,6 +112,8 @@ apxtri.setuptribe = async (tribe, conf) => {
|
|||||||
nationId: conf.nationId,
|
nationId: conf.nationId,
|
||||||
townId: conf.townId,
|
townId: conf.townId,
|
||||||
activelog: [],
|
activelog: [],
|
||||||
|
api: { port: adminapiconf.api.port },
|
||||||
|
socket: { port: adminapiconf.socket.port },
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
inittribe.sudoUser = process.env.USER;
|
inittribe.sudoUser = process.env.USER;
|
||||||
@ -186,10 +191,11 @@ apxtri.setuptribe = async (tribe, conf) => {
|
|||||||
// this command is ran by the setup.sh
|
// this command is ran by the setup.sh
|
||||||
// grep -q '^127.0.0.1 adminapx.adminapi' /etc/hosts || echo '127.0.0.1 adminapx.adminapi' | sudo tee -a /etc/hosts > /dev/null
|
// grep -q '^127.0.0.1 adminapx.adminapi' /etc/hosts || echo '127.0.0.1 adminapx.adminapi' | sudo tee -a /etc/hosts > /dev/null
|
||||||
const ips = await apxtri.getip();
|
const ips = await apxtri.getip();
|
||||||
const nginxrestart = (inittribe.nginx && inittribe.nginx.restart)
|
const nginxrestart =
|
||||||
? inittribe.nginx.restart
|
inittribe.nginx && inittribe.nginx.restart
|
||||||
: fs.readJSONSync("../adminapi/apxtri/setup/initadminapi.json").nginx
|
? inittribe.nginx.restart
|
||||||
.restart;
|
: fs.readJSONSync("../adminapi/apxtri/setup/initadminapi.json").nginx
|
||||||
|
.restart;
|
||||||
const { exec } = require("child_process");
|
const { exec } = require("child_process");
|
||||||
exec(nginxrestart, (error, stdout, stderr) => {
|
exec(nginxrestart, (error, stdout, stderr) => {
|
||||||
if (error) {
|
if (error) {
|
||||||
@ -229,7 +235,7 @@ apxtri.runexpress = async (tribesdns, conf) => {
|
|||||||
const context = {};
|
const context = {};
|
||||||
const pathtr = path.resolve(`../${t}`);
|
const pathtr = path.resolve(`../${t}`);
|
||||||
context.routes = [];
|
context.routes = [];
|
||||||
tribroutes = glob.sync(`${pathtr}/apxtri/routes/*.js`).map((f) => {
|
tribroutes = glob.sync(`${pathtr}/apxtri/routes/*.js`).map((f) => {
|
||||||
const rt = `/${t}/${path.basename(f, ".js")}`;
|
const rt = `/${t}/${path.basename(f, ".js")}`;
|
||||||
context.routes.push(rt);
|
context.routes.push(rt);
|
||||||
return { url: rt, route: f };
|
return { url: rt, route: f };
|
||||||
@ -257,10 +263,12 @@ apxtri.runexpress = async (tribesdns, conf) => {
|
|||||||
app.set(p, conf.api.appset[p]);
|
app.set(p, conf.api.appset[p]);
|
||||||
});
|
});
|
||||||
// To set depending of data form or get size to send
|
// To set depending of data form or get size to send
|
||||||
app.use(bodyParser.urlencoded(conf.api.bodyparse.urlencoded));
|
tribeIds.forEach((t) => {
|
||||||
app.use(bodyParser.json(conf.api.bodyparse.json));
|
app.use(`/${t}`, bodyParser.urlencoded(conf.api.bodyparse.urlencoded));
|
||||||
// To set depending of post put json data size to send
|
app.use(`/${t}`, bodyParser.json(conf.api.bodyparse.json));
|
||||||
app.use(express.json(conf.api.json));
|
// To set depending of post put json data size to send
|
||||||
|
app.use(`/${t}`, express.json(conf.api.json));
|
||||||
|
});
|
||||||
app.disable("x-powered-by"); // for security
|
app.disable("x-powered-by"); // for security
|
||||||
app.locals.tribeids = tribeIds;
|
app.locals.tribeids = tribeIds;
|
||||||
const currentmod = "apxtri";
|
const currentmod = "apxtri";
|
||||||
@ -279,11 +287,11 @@ apxtri.runexpress = async (tribesdns, conf) => {
|
|||||||
doms.forEach((d) => {
|
doms.forEach((d) => {
|
||||||
regtxt += `|${d.replace(/\./g, "\\.")}`;
|
regtxt += `|${d.replace(/\./g, "\\.")}`;
|
||||||
});
|
});
|
||||||
regtxt+=")$"
|
regtxt += ")$";
|
||||||
// let cor = false;whatwg-url
|
// let cor = false;whatwg-url
|
||||||
const regorigin = new RegExp(regtxt);
|
const regorigin = new RegExp(regtxt);
|
||||||
app.use((req, res, next) => {
|
app.use((req, res, next) => {
|
||||||
let cor=false
|
let cor = false;
|
||||||
//console.log(req.headers)
|
//console.log(req.headers)
|
||||||
if (req.headers.origin == undefined) {
|
if (req.headers.origin == undefined) {
|
||||||
//used for mobile access
|
//used for mobile access
|
||||||
@ -326,20 +334,22 @@ apxtri.runexpress = async (tribesdns, conf) => {
|
|||||||
const ips = await apxtri.getip();
|
const ips = await apxtri.getip();
|
||||||
app.listen(conf.api.port, () => {
|
app.listen(conf.api.port, () => {
|
||||||
let webaccess = `/api/ waits request on port:${conf.api.port} `;
|
let webaccess = `/api/ waits request on port:${conf.api.port} `;
|
||||||
let localnet = "/etc/hosts for your local network:\n"
|
let localnet = "/etc/hosts for your local network:\n";
|
||||||
let publicnet ="/etc/hosts for internet network:\n"
|
let publicnet = "/etc/hosts for internet network:\n";
|
||||||
conf.dns.forEach((u) => {
|
conf.dns.forEach((u) => {
|
||||||
//webaccess += `http://${u}/api/ `;
|
//webaccess += `http://${u}/api/ `;
|
||||||
Object.keys(ips).forEach(ik=>{
|
Object.keys(ips).forEach((ik) => {
|
||||||
if (ik=="WANIP"){
|
if (ik == "WANIP") {
|
||||||
publicnet+= `${ips.WANIP} ${u} \n`;
|
publicnet += `${ips.WANIP} ${u} \n`;
|
||||||
}else{
|
} else {
|
||||||
localnet+= `${ips[ik]} ${u} \n`
|
localnet += `${ips[ik]} ${u} \n`;
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
});
|
});
|
||||||
console.log(
|
console.log(
|
||||||
`\x1b[42m\x1b[37m${webaccess} \nOpen in your browser http(s):// ${conf.dns.join(" ")} to manage this apXtri town. \nCheck your network conf \n${localnet} ${publicnet}\nMore in README's project.\nTo get support ask \x1b[0m\x1b[32m in discord https://discord.gg/jF7cAkZn `
|
`\x1b[42m\x1b[37m${webaccess} \nOpen in your browser http(s):// ${conf.dns.join(
|
||||||
|
" "
|
||||||
|
)} to manage this apXtri town. \nCheck your network conf \n${localnet} ${publicnet}\nMore in README's project.\nTo get support ask \x1b[0m\x1b[32m in discord https://discord.gg/jF7cAkZn `
|
||||||
);
|
);
|
||||||
console.log(
|
console.log(
|
||||||
"\x1b[42m\x1b[37m \n",
|
"\x1b[42m\x1b[37m \n",
|
||||||
|
@ -56,7 +56,7 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"apidoc": "^1.2.0",
|
"apidoc": "^1.2.0",
|
||||||
"async": "^3.2.0",
|
"async": "^3.2.0",
|
||||||
"axios": "^1.7.7",
|
"axios": "^1.7.8",
|
||||||
"bcrypt": "^5.0.0",
|
"bcrypt": "^5.0.0",
|
||||||
"cors": "^2.8.4",
|
"cors": "^2.8.4",
|
||||||
"dayjs": "^1.11.13",
|
"dayjs": "^1.11.13",
|
||||||
@ -68,13 +68,13 @@
|
|||||||
"jszip": "^3.10.1",
|
"jszip": "^3.10.1",
|
||||||
"jwt-simple": "^0.5.6",
|
"jwt-simple": "^0.5.6",
|
||||||
"mustache": "^4.2.0",
|
"mustache": "^4.2.0",
|
||||||
|
"nodemailer": "^6.9.16",
|
||||||
"openpgp": "^5.10.1",
|
"openpgp": "^5.10.1",
|
||||||
"path": "^0.12.7",
|
"path": "^0.12.7",
|
||||||
"pm2": "^5.4.2",
|
"pm2": "^5.4.2",
|
||||||
"readline-sync": "^1.4.10",
|
"readline-sync": "^1.4.10",
|
||||||
"sharp": "^0.33.4",
|
"sharp": "^0.33.4",
|
||||||
"smtp-client": "^0.4.0",
|
"smtp-client": "^0.4.0",
|
||||||
"nodemailer": "^6.9.16",
|
|
||||||
"stripe": "^17.3.1",
|
"stripe": "^17.3.1",
|
||||||
"uuid": "^11.0.2"
|
"uuid": "^11.0.2"
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user