1
0
forked from apxtri/apxtri

modif archi apxtri

This commit is contained in:
philc 2024-03-15 08:49:23 +01:00
parent 17a1978dd4
commit b025800e26
36 changed files with 270 additions and 6433 deletions

View File

@ -15,7 +15,7 @@ To have a quick understanding and convention before doing deeply in source code
To share configuration : To share configuration :
process.env.dirtown is folder where town folder name /townId-nationId is accessible process.env.dirtown is folder where town folder name /townId-nationId is accessible
const conf = require(`../../conf/townconf.json`); const conf = require(`../../../../conf/townconf.json`);
app.locals.tribeids is defined later in apixtrib.js and allow express app to always have in memory a dynamic of tribeId available in req.app.locals.tribeids app.locals.tribeids is defined later in apixtrib.js and allow express app to always have in memory a dynamic of tribeId available in req.app.locals.tribeids
*/ */
/** /**
@ -54,7 +54,7 @@ argv.slice(2).forEach((arg) => {
param[kv[0]] = kv[1]; param[kv[0]] = kv[1];
} }
}); });
if (!fs.existsSync("../conf/townconf.json")) { if (!fs.existsSync("../../../../../conf/townconf.json")) {
// This is a first install // This is a first install
const nam = path.resolve("..").split("/").slice(-1)[0].split("-"); const nam = path.resolve("..").split("/").slice(-1)[0].split("-");
const town = nam[0]; const town = nam[0];
@ -112,7 +112,9 @@ if (
} }
} }
*/ */
const conf = require(path.resolve(`../conf/townconf.json`)); const conf = require(path.resolve(`../../../conf/townconf.json`));
let doms = conf.dns; // only dns of town during the init process
const currentmod = "apxtri"; const currentmod = "apxtri";
const log = conf.api.activelog.includes(currentmod); const log = conf.api.activelog.includes(currentmod);
@ -128,39 +130,40 @@ updateobjectsfromfreshesttown(conf.towns, {
// Run main express process for a /towId-nationId/tribes // Run main express process for a /towId-nationId/tribes
let tribelist = {}; let tribelist = {};
if (fs.existsSync(`../nationchains/tribes/idx/tribeId_all.json`)) { if (fs.existsSync(`../../idx/tribeId_all.json`)) {
tribelist = fs.readJsonSync(`../nationchains/tribes/idx/tribeId_all.json`); tribelist = fs.readJsonSync(`../../idx/tribeId_all.json`);
} }
let doms = conf.dns; // only dns of town during the init process let tribeIds = Object.keys(tribelist);
let tribeIds = []; // context is store in tribes/itm/tribename.json ={contexte:{routes:[],models:[{model:,tplstringslg:[]}]}
let routes = glob.sync(`./routes/*.js`).map((f) => {
return { url: `/${path.basename(f, ".js")}`, route: f };
});
glob.sync(`../nationchains/tribes/*/api/routes/*.js`).forEach((f) => {
const ids = f.indexOf(`../nationchains/tribes/`);
const trib = f.slice(
ids + `../nationchains/tribes/`.length,
f.lastIndexOf("/api/routes")
);
routes.push({ url: `/${trib}/${path.basename(f, ".js")}`, route: f });
});
//routes={url,route} check how to add plugin tribe route later //routes={url,route} check how to add plugin tribe route later
// keep only the 2 last part (.) of domain name to validate cors with it (generic domain) // keep only the 2 last part (.) of domain name to validate cors with it (generic domain)
Object.keys(tribelist).forEach((t) => { let routes=[]
tribeIds.forEach((t) => {
tribelist[t].dns.forEach((d) => { tribelist[t].dns.forEach((d) => {
const dm = d.split(".").slice(-2).join("."); const dm = d.split(".").slice(-2).join(".");
if (!doms.includes(dm)) doms.push(dm); if (!doms.includes(dm)) doms.push(dm);
}); });
tribeIds.push(t); const context={};
const pathtr=path.resolve(`../../${t}`);
context.routes=[]
tribroutes=glob.sync(`${pathtr}/ap*/routes/*.js`).map(f=>{
const rt=`/${t}/${path.basename(f, ".js")}`
context.routes.push(rt)
return { url: rt, route: f };
});
context.models=glob.sync(`${pathtr}/ap*/models/*.js`).map(f=>{
const modname=`${path.basename(f, ".js")}`
return {
model: modname,
tplstrings:glob.sync(`${pathtr}/objects/tplstrings/${modname}_*.json`).map(l=>path.basename(l,'.json').split("_")[1] )
}
})
const conft=`../../itm/${t}.json`
const ctx=fs.readJsonSync(conft)
ctx.context=context
fs.outputJSONSync(conft,ctx,{spaces:2});
routes=routes.concat(tribroutes);
}); });
if (log)
console.log(
currentmod,
" Allowed DOMs to access to this apxtri server:",
JSON.stringify(doms)
);
const app = express(); const app = express();
// load express parameter from conf // load express parameter from conf
Object.keys(conf.api.appset).forEach((p) => { Object.keys(conf.api.appset).forEach((p) => {
@ -173,8 +176,15 @@ app.use(express.json());
app.use(bodyParser.json(conf.api.bodyparse.json)); app.use(bodyParser.json(conf.api.bodyparse.json));
app.disable("x-powered-by"); // for security app.disable("x-powered-by"); // for security
app.locals.tribeids = tribeIds; app.locals.tribeids = tribeIds;
if (log) console.log(currentmod, " app.locals.tribeids", app.locals.tribeids); if (log){
// Cors management console.log(
currentmod,
" Allowed DOMs to access to this apxtri server:",
JSON.stringify(doms)
);
console.log(currentmod, " app.locals.tribeids", app.locals.tribeids);
}
// Cors management
let originlst = "test"; let originlst = "test";
doms.forEach((d) => { doms.forEach((d) => {
originlst += `|${d.replace(/\./g, "\\.")}`; originlst += `|${d.replace(/\./g, "\\.")}`;

View File

@ -1,4 +1,4 @@
const conf = require(`../../conf/townconf.json`); const conf = require(`../../../../conf/townconf.json`);
const currentmod='checkHeaders'; const currentmod='checkHeaders';
const log = conf.api.activelog.includes(currentmod) const log = conf.api.activelog.includes(currentmod)
/** /**

View File

@ -10,35 +10,39 @@ For api tribe's doc  accessible in [https://smatchit.io/cdn/apidoc](https://sma
`yarn apidoctribename` `yarn apidoctribename`
Objects manage in apxtri: pagans, notifications, nations, towns, tribes, wwws  A special tribe call adminapi is replicated in any towns (node), it works the same than all the other tribe except that all their data are synchronize with a blockchain 
All others objects are manage in town/tribe  Objects manage by adminapi are: pagans (numerique id =alias/public key / private key), notifications (cypher message betxeen alias) , nations (rules apply to all towns belonging to a nations), towns ( a server that host IT ressources disk space, ram, bandwith and rules aplly to all tribe belonging to a town), tribes (( a sharing space to store data as well as api with rules to any person that use it), wwws (web space, dns)
All others object are managed by spécifics tribe. 
```plaintext ```plaintext
/townName_nationName/ /townName_nationName/
/apxtri/ # core process /conf/nginx/tribename_appname.conf # nginx conf
/nationchains/conf.json # town settings contain all glabl parameter /conf/apidoc # apidoc conf
/conf/townconf.json # town settings contain all glabl parameter
/tribes/idx/triebid_all.json # A global file {tribename:{conf}
/itm/tribename.json # Config file of a tribe
/adminapi # Tribes synchronize with all town
/apxtri # git yarn/npm project package.json entry point apxtri.js
/routes/
/models/
/middlewares/
/logs/nginx # nginx log related to /conf/nginx/apxtri_adminapi.conf
/api
/objects/objectname/idx/ # list of index to search objectname items
/itms/ # 1 json per items name apxid.json where apxid is a unique key
/schema/conf.json # list of schema and version
/objectname.json # schema title and escription are in english
/lg/objectname_lg.json # title and description in lg
/www/appname # web space
/cdn # common file with cache system
/tribename/ # same than adminapi but wit /api instead of apxtri
``` ```
url: **/api/routeName** For core api apxtri in /apxtri : API Endpoint url: **/api/{tribename}/{routename}/xxx**
```plaintext Domaine name can be a adminapi donaim name aswell any tribe's domain  name. Check nginx conf in /conf/nginx 
/apxtri/middlewares/
/apxtri/routes/
/apxtri/models/
/apxtri/models/lg/ lauage accessible by https://wall-ants.ndda.fr/nationchains/models/Checkjson_fr.json
/apxtri/models/unitest/
```
url: **/api/smatchit/routeName** for tribe smatchit example api in /town\_nation/tribes/smatchit(tribeid) 
```plaintext
/nationchains/tribes/smatchit/api/routes/
/nationchains/tribes/smatchit/api/models/
/nationchains/tribes/smatchit/api/models/lg/ language customization accessible https://smatchit.io/smatchit/models/model_lg.json
```
**static files** are served by nginx, each tribe nginx conf are store and can be customize in /nationchains/tribes/{tribe}/www/nginx\_{xtribe}\_{xapp}.conf
## Object management (Odmdb) ## Object management (Odmdb)
@ -100,7 +104,7 @@ This contain a json {msg:"mustache template string to render with data"}  
## Accessrights: ## Accessrights:
An alias is just an identity, to access a tribe, a person must exist with an authenticated alias into /nationchains/tribes/{tribename}/persons/itm/{alias}.json An alias is just an identity, to access a tribe, a person must exist with an authenticated alias into /tribes/{tribename}/persons/itm/{alias}.json/tribes/tribename/api/routes/
A person has a property profils with a list of profilename, common profiles are : anonymous (no identity) / pagan (an identity)  / person (an identity with access right into a tribe) / druid (the administrator of a tribe) / major (administrator of a town/server) A person has a property profils with a list of profilename, common profiles are : anonymous (no identity) / pagan (an identity)  / person (an identity with access right into a tribe) / druid (the administrator of a tribe) / major (administrator of a town/server)
@ -111,17 +115,17 @@ Each object has an apxaccessrights that is a list of profil and CRUD access per
Accessible with https://dns/api/tribename/routes Accessible with https://dns/api/tribename/routes
```plaintext ```plaintext
/nationchains/tribes/tribename/api/routes /tribes/tribename/api/routes
/nationchains/tribes/tribename/api/middlewares /tribes/tribename/api/middlewares
/nationchains/tribes/tribename/api/models /tribes/tribename/api/models
/nationchains/tribes/tribename/schema /tribes/tribename/schema
/nationchains/tribes/tribename/schema/lg /tribes/tribename/schema/lg
``` ```
```plaintext ```plaintext
// Example of a route // Example of a route
const conf = require(`../../../../../conf/townconf.json`); const conf = require(`../../../../conf/townconf.json`);
const express = require(`../../../../../apxtri/node_modules/express`); const express = require(`../../../adminapi/apxtri/node_modules/express`);
const fs = require(`../../../../../apxtri/node_modules/fs-extra`); const fs = require(`../../../adminapi/apxtri/node_modules/fs-extra`);
const Nofications = require(`../../../../../apxtri/models/Notifications.js`); const Nofications = require(`../../../adminapi/apxtri/models/Notifications.js`);
``` ```

View File

@ -6,7 +6,7 @@ const glob = require("glob");
// const openpgp = require("/media/phil/usbfarm/apxtri/node_modules/openpgp/dist/node/openpgp.js"); // const openpgp = require("/media/phil/usbfarm/apxtri/node_modules/openpgp/dist/node/openpgp.js");
const openpgp = require("openpgp"); const openpgp = require("openpgp");
const conf = require(`../../conf/townconf.json`); const conf = require(`../../../../conf/townconf.json`);
const currentmod='isAuthenticated'; const currentmod='isAuthenticated';
const log = conf.api.activelog.includes(currentmod) const log = conf.api.activelog.includes(currentmod)
/** /**
@ -40,16 +40,16 @@ const isAuthenticated = async (req, res, next) => {
const currentday = dayjs().date(); const currentday = dayjs().date();
fs.ensureDirSync(`../tmp/tokens`); fs.ensureDirSync(`../tmp/tokens`);
let menagedone = fs.existsSync( let menagedone = fs.existsSync(
`../tmp/tokens/menagedone${currentday}` `../../../tmp/tokens/menagedone${currentday}`
); );
if (menagedone) console.log(Date.now(),`menagedone${currentday} was it done today?:${menagedone}`); if (menagedone) console.log(Date.now(),`menagedone${currentday} was it done today?:${menagedone}`);
if (!menagedone) { if (!menagedone) {
// clean oldest // clean oldest
const tsday = dayjs().valueOf(); // now in timestamp format const tsday = dayjs().valueOf(); // now in timestamp format
glob.sync(`../tmp/tokens/menagedone*`).forEach((f) => { glob.sync(`../../../tmp/tokens/menagedone*`).forEach((f) => {
fs.removeSync(f); fs.removeSync(f);
}); });
glob.sync(`../tmp/tokens/*.json`).forEach((f) => { glob.sync(`../../../tmp/tokens/*.json`).forEach((f) => {
const fsplit = f.split("_"); const fsplit = f.split("_");
const elapse = tsday - parseInt(fsplit[2]); const elapse = tsday - parseInt(fsplit[2]);
//24h 86400000 milliseconde 15mn 900000 //24h 86400000 milliseconde 15mn 900000
@ -58,11 +58,11 @@ const isAuthenticated = async (req, res, next) => {
} }
}); });
//clean tmp //clean tmp
glob.sync(`../tmp/*.txt`).forEach((f) => { glob.sync(`../../../tmp/*.txt`).forEach((f) => {
fs.remove(f); fs.remove(f);
}); });
fs.outputFile( fs.outputFile(
`../tmp/tokens/menagedone${currentday}`, `../../../tmp/tokens/menagedone${currentday}`,
"done by middleware/isAUthenticated" "done by middleware/isAUthenticated"
); );
} }
@ -86,7 +86,7 @@ const isAuthenticated = async (req, res, next) => {
return res.status(resnotauth.status).json(resnotauth); return res.status(resnotauth.status).json(resnotauth);
} }
let tmpfs = `../tmp/tokens/${req.session.header.xalias}_${req.session.header.xtribe}_${req.session.header.xdays}`; let tmpfs = `../../../tmp/tokens/${req.session.header.xalias}_${req.session.header.xtribe}_${req.session.header.xdays}`;
//max filename in ext4: 255 characters //max filename in ext4: 255 characters
tmpfs += `_${req.session.header.xhash.substring( tmpfs += `_${req.session.header.xhash.substring(
150, 150,
@ -97,7 +97,7 @@ const isAuthenticated = async (req, res, next) => {
const sleep = (ms) => { const sleep = (ms) => {
return new Promise((resolve) => setTimeout(resolve, ms)); return new Promise((resolve) => setTimeout(resolve, ms));
}; };
const failstamp = `../tmp/tokens/${alias}.json`; const failstamp = `../../../tmp/tokens/${alias}.json`;
if (action == "clean") { if (action == "clean") {
//to reinit bruteforce checker //to reinit bruteforce checker
if (log) console.log(currentmod, "try to clean penalty file ", failstamp); if (log) console.log(currentmod, "try to clean penalty file ", failstamp);
@ -119,7 +119,7 @@ const isAuthenticated = async (req, res, next) => {
if (!fs.existsSync(tmpfs)) { if (!fs.existsSync(tmpfs)) {
// need to check detached sign // need to check detached sign
let publickey = ""; let publickey = "";
const aliasinfo = `../nationchains/pagans/itm/${req.session.header.xalias}.json`; const aliasinfo = `../objects/pagans/itm/${req.session.header.xalias}.json`;
if (fs.existsSync(aliasinfo)) { if (fs.existsSync(aliasinfo)) {
publickey = fs.readJsonSync(aliasinfo).publickey; publickey = fs.readJsonSync(aliasinfo).publickey;
} else if (req.body.publickey) { } else if (req.body.publickey) {
@ -183,7 +183,7 @@ const isAuthenticated = async (req, res, next) => {
return res.status(resnotauth.status).send(resnotauth); return res.status(resnotauth.status).send(resnotauth);
} }
// authenticated then get person profils (person = pagan for a xtrib) // authenticated then get person profils (person = pagan for a xtrib)
const person = `../nationchains/tribes/${req.session.header.xtribe}/objects/persons/itm/${req.session.header.xalias}.json`; const person = `../../${req.session.header.xtribe}/objects/persons/itm/${req.session.header.xalias}.json`;
if (log) console.log(currentmod,"Profils tribe/app management"); if (log) console.log(currentmod,"Profils tribe/app management");
if (log) console.log(currentmod,"person", person); if (log) console.log(currentmod,"person", person);
if (fs.existsSync(person)) { if (fs.existsSync(person)) {

View File

@ -62,7 +62,7 @@ Checkjson.schema.properties.enum = (str, enumvalues) => {
//enumvalues is a reference of objectname.key //enumvalues is a reference of objectname.key
const { tribeId, obj, keyid } = enumvalues.split("."); const { tribeId, obj, keyid } = enumvalues.split(".");
return fs.existsSync( return fs.existsSync(
`../../nationchains/tribes/${tribeId}/schema/${obj}/itm/${keyid}.json` `../../../${tribeId}/schema/${obj}/itm/${keyid}.json`
); );
} else { } else {
return true; return true;

View File

@ -4,7 +4,7 @@ const glob = require("glob");
const jwt = require("jwt-simple"); const jwt = require("jwt-simple");
const axios = require("axios"); const axios = require("axios");
const path = require("path"); const path = require("path");
const conf = require(`../../conf/townconf.json`); const conf = require(`../../../../conf/townconf.json`);
const Odmdb = require("./Odmdb.js"); const Odmdb = require("./Odmdb.js");
// lowercase 1st letter is normal // lowercase 1st letter is normal
const towns = require("./Towns.js"); const towns = require("./Towns.js");
@ -35,20 +35,20 @@ Nations.updateobjectsfromfreshesttown = (dnstownlist, objectidx) => {
* if an item exist localy and does not from the town requested * if an item exist localy and does not from the town requested
* @Param {array} dnstownlist list of dns to get latest data * @Param {array} dnstownlist list of dns to get latest data
* @Param {object} objectidx objectnme:idxfile {agans:"alias_all.json",...} * @Param {object} objectidx objectnme:idxfile {agans:"alias_all.json",...}
* @return create/update nationchains/pagans town nation * @return create/update tribes/adminapi/opjects/pagans town nation
*/ */
const localversion = {}; const localversion = {};
const objlist = Object.keys(objectidx); const objlist = Object.keys(objectidx);
objlist.forEach((o) => { objlist.forEach((o) => {
let objconf = { let objconf = {
name: o, name: o,
schema: `../nationchains/tribes/adminapi/schema/${o}.jsons`, schema: `../../schema/${o}.jsons`,
lastupdate: -1, lastupdate: -1,
}; };
if (fs.existsSync(`../nationchains/${o}/conf.json`)) { if (fs.existsSync(`../../${o}/conf.json`)) {
objconf = fs.readJsonSync(`../nationchains/${o}/conf.json`); objconf = fs.readJsonSync(`../../${o}/conf.json`);
} else { } else {
fs.outputJsonSync(`../nationchains/${o}/conf.json`, objconf); fs.outputJsonSync(`../../${o}/conf.json`, objconf);
} }
localversion[o] = [conf.dns[0], objconf.lastupdate]; localversion[o] = [conf.dns[0], objconf.lastupdate];
}); });
@ -231,7 +231,7 @@ Nations.create = (conf) => {
res.info = `your nationId ${conf.nationId} does not exist you have to choose an existing one`; res.info = `your nationId ${conf.nationId} does not exist you have to choose an existing one`;
return res; return res;
} }
const towns = fs.readJsonSync("./nationchains/towns/idx/townId_all.json"); const towns = fs.readJsonSync("./tribes/adminapi/opjects/towns/idx/townId_all.json");
if (towns[conf.nationId].includes(conf.townId)) { if (towns[conf.nationId].includes(conf.townId)) {
res.status = 409; res.status = 409;
res.info = `This conf.townId already exist you have to find a unique town name`; res.info = `This conf.townId already exist you have to find a unique town name`;

View File

@ -6,7 +6,7 @@ const dayjs = require("dayjs");
const Checkjson = require(`./Checkjson.js`); const Checkjson = require(`./Checkjson.js`);
//const smtp = require("smtp-client"); //const smtp = require("smtp-client");
const nodemailer = require("nodemailer"); const nodemailer = require("nodemailer");
const conf = require(`../../conf/townconf.json`); const conf = require(`../../../../conf/townconf.json`);
const currentmod = "Notifications"; const currentmod = "Notifications";
const log = conf.api.activelog.includes(currentmod); const log = conf.api.activelog.includes(currentmod);
/** /**
@ -18,7 +18,7 @@ const log = conf.api.activelog.includes(currentmod);
const Notifications = {}; const Notifications = {};
Notifications.get = (alias, tribeId) => { Notifications.get = (alias, tribeId) => {
const notiffile = `../nationchains/tribes/${req.params.tribeId}/notifications/${req.params.alias}.json`; const notiffile = `../../../${req.params.tribeId}/notifications/${req.params.alias}.json`;
const msg = fs.existsSync(notiffile) ? fs.readJSONSync(notiffile) : {}; const msg = fs.existsSync(notiffile) ? fs.readJSONSync(notiffile) : {};
return { return {
status: 200, status: 200,
@ -43,7 +43,7 @@ Notifications.registertolist = (key, typekey, tribe, mlist, srckey, uuid) => {
data: { fielderr: typekey, format: typekey } data: { fielderr: typekey, format: typekey }
}; };
const destin = `../nationchains/tribes/${tribe}/objects/maillinglists/${typekey}_${mlist}.json`; const destin = `../../../${tribe}/objects/maillinglists/${typekey}_${mlist}.json`;
if (!fs.existsSync(destin)){ if (!fs.existsSync(destin)){
console.log(`######## Attention tentative d'ecriture non autorisé,le fichier n'existe pas ${destin} créer le à la main vide {}`) console.log(`######## Attention tentative d'ecriture non autorisé,le fichier n'existe pas ${destin} créer le à la main vide {}`)
return {status:406,ref:"Notifications",msg:"destinnotallow",data:{destin}} return {status:406,ref:"Notifications",msg:"destinnotallow",data:{destin}}
@ -69,8 +69,9 @@ Notifications.registertolist = (key, typekey, tribe, mlist, srckey, uuid) => {
/** /**
* Unsubscribe an eamil or phone from a mailinglist for a tribe * Unsubscribe an eamil or phone from a mailinglist for a tribe
*/ */
Notifications.unsubscribefromlist = (body, header) => { Notifications.unregisterfromlist = (key, typekey, tribe,mlist) => {
key = key.toLowerCase();
} }
/** /**
* Message to send to an alias from an anonymous or not * Message to send to an alias from an anonymous or not
@ -115,11 +116,11 @@ Notifications.sendsms = async (data, tribeId) => {
let confsms = conf.sms; let confsms = conf.sms;
if ( if (
fs.existsSync( fs.existsSync(
`../nationchains/tribes/itm/${req.session.header.xtribe}.json` `../../../itm/${req.session.header.xtribe}.json`
) )
) { ) {
const conftrib = fs.readJSONSync( const conftrib = fs.readJSONSync(
`../nationchains/tribes/itm/${req.session.header.xtribe}.json` `../../../itm/${req.session.header.xtribe}.json`
); );
if (conftrib.sms) confsms = conftrib.sms; if (conftrib.sms) confsms = conftrib.sms;
} }
@ -224,7 +225,7 @@ Notifications.sendmail = async (data, tribe) => {
}; };
} }
let confsmtp = conf.smtp; let confsmtp = conf.smtp;
const conftribfile = `../nationchains/tribes/itm/${tribe}.json`; const conftribfile = `../../../itm/${tribe}.json`;
if (fs.existsSync(conftribfile)) { if (fs.existsSync(conftribfile)) {
const conftrib = fs.readJSONSync(conftribfile); const conftrib = fs.readJSONSync(conftribfile);
confsmtp = conftrib.smtp; confsmtp = conftrib.smtp;

View File

@ -3,7 +3,7 @@ const path = require("path");
const fs = require("fs-extra"); const fs = require("fs-extra");
const dayjs = require("dayjs"); const dayjs = require("dayjs");
const axios = require("axios"); const axios = require("axios");
const conf = require(`../../conf/townconf.json`); const conf = require(`../../../../conf/townconf.json`);
const Checkjson = require(`./Checkjson.js`); const Checkjson = require(`./Checkjson.js`);
const { promiseHooks } = require("v8"); const { promiseHooks } = require("v8");
const currentmod = "Odmdb"; const currentmod = "Odmdb";
@ -48,7 +48,7 @@ const log = conf.api.activelog.includes(currentmod);
const Odmdb = {}; const Odmdb = {};
/** /**
*const Checkjson = require(`../../../../../apxtri/models/Checkjson`); *const Checkjson = require(`../../../adminapi/apxtri/models/Checkjson`);
@api syncObject @api syncObject
* @param {string} url to an existing object conf (/objectname/conf.json) * @param {string} url to an existing object conf (/objectname/conf.json)
* @param {timestamp} timestamp * @param {timestamp} timestamp
@ -180,7 +180,7 @@ Odmdb.Schema = (objectPathname, validschema, lg="en") => {
if (schemaPath.substring(0, 4) == "http") { if (schemaPath.substring(0, 4) == "http") {
// lance requete http pour recuperer le schema avec un await axios // lance requete http pour recuperer le schema avec un await axios
} else { } else {
schemaPath = `../nationchains/tribes/${schemaPath}`; schemaPath = `../../${schemaPath}`;
if (log) console.log(currentmod,"resolve path schemaPath:",path.resolve(schemaPath)) if (log) console.log(currentmod,"resolve path schemaPath:",path.resolve(schemaPath))
if (!fs.existsSync(schemaPath)) { if (!fs.existsSync(schemaPath)) {
return {}; return {};
@ -232,7 +232,7 @@ Odmdb.Schema = (objectPathname, validschema, lg="en") => {
res.data.schema.properties[p].type == "object" && res.data.schema.properties[p].type == "object" &&
res.data.schema.properties[p]["$ref"] res.data.schema.properties[p]["$ref"]
) { ) {
const subschema = path.resolve(`${objectPathname}/${res.data.schema.properties[p]["$ref"]}`); const subschema = path.resolve(`${objectPathname}/${res.data.schema.properties[p]["$ref"]}.json`);
if (Object.keys(res.data.schema).length == 0) { if (Object.keys(res.data.schema).length == 0) {
res.status = 404; res.status = 404;
res.msg = "missingref"; res.msg = "missingref";
@ -243,13 +243,14 @@ Odmdb.Schema = (objectPathname, validschema, lg="en") => {
res.data.schema.properties[p] = subschema; res.data.schema.properties[p] = subschema;
} }
} }
//`../../${req.session.header.xtribe}/objects/persons`
//looking for options:{"$ref":"../objects/options/xxx.json"} //looking for options:{"$ref":"../objects/options/xxx.json"}
//to add enum:[] = content of options available //to add enum:[] = content of options available in
if ( if (
res.data.schema.properties[p].options && res.data.schema.properties[p].options &&
res.data.schema.properties[p].options["$ref"] res.data.schema.properties[p].options["$ref"]
) { ) {
const optionsfile = path.resolve(`${objectPathname}/${res.data.schema.properties[p].options["$ref"]}`) const optionsfile = path.resolve(`${objectPathname}/${res.data.schema.properties[p].options["$ref"]}_${lg}.json`)
if (log) console.log(currentmod,"Lien vers options:", optionsfile) if (log) console.log(currentmod,"Lien vers options:", optionsfile)
if (!fs.existsSync(optionsfile)){ if (!fs.existsSync(optionsfile)){
res.status = 404; res.status = 404;
@ -260,7 +261,7 @@ Odmdb.Schema = (objectPathname, validschema, lg="en") => {
if (!res.data.schema.apxref) {res.data.schema.apxref=[]} if (!res.data.schema.apxref) {res.data.schema.apxref=[]}
if (!res.data.schema.apxref.includes(res.data.schema.properties[p].options["$ref"])) if (!res.data.schema.apxref.includes(res.data.schema.properties[p].options["$ref"]))
res.data.schema.apxref.push(res.data.schema.properties[p].options["$ref"]) res.data.schema.apxref.push(res.data.schema.properties[p].options["$ref"])
res.data.schema.properties[p].enum=fs.readJSONSync(optionsfile) res.data.schema.properties[p].enum=fs.readJSONSync(optionsfile).lst_idx
} }
} }
}); });
@ -278,6 +279,7 @@ Odmdb.Schema = (objectPathname, validschema, lg="en") => {
if (!res.data.schema.apxuniquekey.includes(res.data.schema.apxid)) { if (!res.data.schema.apxuniquekey.includes(res.data.schema.apxid)) {
res.data.schema.apxuniquekey.push(res.data.schema.apxid); res.data.schema.apxuniquekey.push(res.data.schema.apxid);
} }
//`../../${req.session.header.xtribe}/objects/persons`
res.data.schema.apxidx.forEach((idx) => { res.data.schema.apxidx.forEach((idx) => {
if ( if (
idx.objkey && idx.objkey &&
@ -726,15 +728,15 @@ Odmdb.runidx = (objectPathname, schema) => {
* @param {object} schema if empty it use schema from Odmdb.Schema().data.schema * @param {object} schema if empty it use schema from Odmdb.Schema().data.schema
* *
* example create alias 12 name fred: * example create alias 12 name fred:
* Odmdb.idxfromitm('.../tribes/ndda/persons',"C",{alias:'12',name:"fred"},{},[], {person schema}) * Odmdb.idxfromitm('../../../ndda/persons',"C",{alias:'12',name:"fred"},{},[], {person schema})
* example update alias 12 in name freddy: * example update alias 12 in name freddy:
* Odmdb.idxfromitm('.../tribes/ndda/persons',"U",{alias:'12',name:"freddy"},{alias:'12',name:"fred"},[], {person schema}) * Odmdb.idxfromitm('../../../ndda/persons',"U",{alias:'12',name:"freddy"},{alias:'12',name:"fred"},[], {person schema})
* example delete alias 12: * example delete alias 12:
* Odmdb.idxfromitm('.../tribes/ndda/persons',"D",{},{alias:'12',name:"fred"},[], {person schema}) * Odmdb.idxfromitm('../../../ndda/persons',"D",{},{alias:'12',name:"fred"},[], {person schema})
* example to rebuild all index from scratch * example to rebuild all index from scratch
* Odmdb.idxfromitm('.../tribes/ndda/persons',"I",{},{},[], {person schema}) * Odmdb.idxfromitm('../../../ndda/persons',"I",{},{},[], {person schema})
* example to rebuild only publickey_alias index from scratch * example to rebuild only publickey_alias index from scratch
* Odmdb.idxfromitm('.../tribes/ndda/pagans',"I",{},{},[{ name:"publickey_alias",keyval:"publickey",objkey:["alias"]}], {pagans schema}) * Odmdb.idxfromitm('../../../ndda/pagans',"I",{},{},[{ name:"publickey_alias",keyval:"publickey",objkey:["alias"]}], {pagans schema})
* *
*/ */
Odmdb.ASUPidxfromitm = ( Odmdb.ASUPidxfromitm = (

View File

@ -8,7 +8,7 @@ const openpgp = require("openpgp");
const Notifications = require("./Notifications.js"); const Notifications = require("./Notifications.js");
const Odmdb = require("./Odmdb.js"); const Odmdb = require("./Odmdb.js");
const conf = require(`../../conf/townconf.json`); const conf = require(`../../../../conf/townconf.json`);
const currentmod = "Pagans"; const currentmod = "Pagans";
const log = conf.api.activelog.includes(currentmod); const log = conf.api.activelog.includes(currentmod);
/** /**
@ -48,13 +48,14 @@ Pagans.logout = (alias, tribe, xdays, xhash) => {
**/ **/
Pagans.getalias = (alias) => { Pagans.getalias = (alias) => {
//bypass Odmdb cause all is public save ressources //bypass Odmdb cause all is public save ressources
if (fs.existsSync(`../nationchains/pagans/itm/${alias}.json`)) { console.log(path.resolve(`../objects/pagans/itm/${alias}.json`))
if (fs.existsSync(`../objects/pagans/itm/${alias}.json`)) {
return { return {
status: 200, status: 200,
ref: "Pagans", ref: "Pagans",
msg: "aliasexist", msg: "aliasexist",
data: fs.readJSONSync( data: fs.readJSONSync(
`../nationchains/pagans/itm/${alias}.json` `../objects/pagans/itm/${alias}.json`
), ),
}; };
} else { } else {
@ -102,7 +103,7 @@ Pagans.sendmailkey = (data) => {
const person = { alias:data.alias, privatekey:data.privatekey, tribe:data.tribe }; const person = { alias:data.alias, privatekey:data.privatekey, tribe:data.tribe };
if (!data.publickey || !data.email || !data.privatekey) { if (!data.publickey || !data.email || !data.privatekey) {
const personfile = `../../nationchains/tribes/${data.tribe}/objects/persons/itm/${data.alias}.json`; const personfile = `../../${data.tribe}/objects/persons/itm/${data.alias}.json`;
if (!fs.existsSync(personfile)) { if (!fs.existsSync(personfile)) {
return { return {
status: 404, status: 404,
@ -125,9 +126,9 @@ Pagans.sendmailkey = (data) => {
console.log("person:", person); console.log("person:", person);
let tplfile=`../../nationchains/tribes/${data.tribe}/template/createidentity_${data.lg}.js`; let tplfile=`../../../${data.tribe}/template/createidentity_${data.lg}.js`;
if (!fs.existsSync(tplfile)){ if (!fs.existsSync(tplfile)){
tplfile=`../../nationchains/tribes/adminapi/template/createidentity_${data.lg}.js`; tplfile=`../../../adminapi/template/createidentity_${data.lg}.js`;
if (!fs.existsSync(tplfile)){ if (!fs.existsSync(tplfile)){
return { return {
status:406, status:406,

View File

@ -4,7 +4,7 @@ const glob = require("glob");
const moment = require("moment"); const moment = require("moment");
const jwt = require("jwt-simple"); const jwt = require("jwt-simple");
const UUID = require("uuid"); const UUID = require("uuid");
const conf = require(`../../conf/townconf.json`); const conf = require(`../../../../conf/townconf.json`);
const Checkjson = require(`./Checkjson.js`); const Checkjson = require(`./Checkjson.js`);
const Odmdb = require("./Odmdb.js"); const Odmdb = require("./Odmdb.js");
@ -144,7 +144,7 @@ Towns.changeowner = async (newowner, requestby) => {
/** /**
* *
*/ */
if (!fs.existsSync(`./nationchains/pagans/itm/${newowner}.json`)) { if (!fs.existsSync(`./tribes/adminapi/opjects/pagans/itm/${newowner}.json`)) {
return { return {
status: 404, status: 404,
ref: "towns", ref: "towns",

View File

@ -3,7 +3,7 @@ const path = require("path");
const fs = require("fs-extra"); const fs = require("fs-extra");
const dayjs = require("dayjs"); const dayjs = require("dayjs");
const axios = require("axios"); const axios = require("axios");
const conf = require(`../../conf/townconf.json`); const conf = require(`../../../../conf/townconf.json`);
const Checkjson = require(`./Checkjson.js`); const Checkjson = require(`./Checkjson.js`);
const Trackings = {} const Trackings = {}

View File

@ -10,7 +10,7 @@ const jwt = require( 'jwt-simple' );
const moment = require( 'moment' ); const moment = require( 'moment' );
const UUID = require( 'uuid' ); const UUID = require( 'uuid' );
const Pagans = require( './Pagans.js' ); const Pagans = require( './Pagans.js' );
const conf = require(`../../conf/townconf.json`); const conf = require(`../../../../conf/townconf.json`);
const Checkjson = require( `./Checkjson.js`); const Checkjson = require( `./Checkjson.js`);
/* /*
tribeid manager tribeid manager

View File

@ -3,7 +3,7 @@ const path = require("path");
const dnsSync = require("dns-sync"); const dnsSync = require("dns-sync");
const mustache = require("mustache"); const mustache = require("mustache");
const readlineSync = require("readline-sync"); const readlineSync = require("readline-sync");
const conf = require(`../../conf/townconf.json`); const conf = require(`../../../../conf/townconf.json`);
const Wwws = {}; const Wwws = {};
/*Wwws.apxtriinstall = (paramconf) => { /*Wwws.apxtriinstall = (paramconf) => {
@ -39,7 +39,7 @@ const Wwws = {};
); );
if (!fs.existsSync(paramconf.nginx.logs)) fs.mkdirSync(paramconf.nginx.logs); if (!fs.existsSync(paramconf.nginx.logs)) fs.mkdirSync(paramconf.nginx.logs);
paramconf.nginx.firstinstall = true; paramconf.nginx.firstinstall = true;
fs.outputJsonSync("../nationchains/tribes/conf.json", paramconf, { fs.outputJsonSync("../tribes/conf.json", paramconf, {
space: 2, space: 2,
}); });

View File

@ -3,7 +3,7 @@ Unit testing
*/ */
const assert = require("assert"); const assert = require("assert");
const Checkjson = require("../Checkjson.js"); const Checkjson = require("../Checkjson.js");
const conf = require(`../../conf/townconf.json`); const conf = require(`../../../../conf/townconf.json`);
const ut = { name: "Checkjson" }; const ut = { name: "Checkjson" };

View File

@ -6,7 +6,7 @@ const fs = require("fs-extra");
const path = require("path"); const path = require("path");
const Odmdb = require("../Odmdb.js"); const Odmdb = require("../Odmdb.js");
const { generemdp } = require("../toolsbox.js"); const { generemdp } = require("../toolsbox.js");
const conf = require(`../../conf/townconf.json`); const conf = require(`../../../../conf/townconf.json`);
const ut = { name: "Odmdb" }; const ut = { name: "Odmdb" };
/* /*
@ -26,7 +26,7 @@ ut.crud = (objectPathname, itm, profils) => {
const testvar={alias:"tutu", passphrase:"",privatekey:"", publickey:""} const testvar={alias:"tutu", passphrase:"",privatekey:"", publickey:""}
const testitms=[ const testitms=[
{objectPathname:`../nationchains/pagans`, {objectPathname:`../../../../adminapi/opjects/pagans`,
itm:{alias:'toutou', publickey:}} itm:{alias:'toutou', publickey:}}
] ]

6240
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -2,7 +2,7 @@
"name": "apxtri", "name": "apxtri",
"version": "0.0.1", "version": "0.0.1",
"logo": { "logo": {
"file": "../nationchains/tribes/adminapi/www/cdn/share/logo/logocarredark.png" "file": "../www/cdn/share/logo/logocarredark.png"
}, },
"description": "apxtri Decentralized Autonomous Organization", "description": "apxtri Decentralized Autonomous Organization",
"main": "apxtri.js", "main": "apxtri.js",
@ -15,10 +15,10 @@
"restartapx": "pm2 restart apxtri.js --log-date-format 'DD-MM HH:mm:ss.SSS'", "restartapx": "pm2 restart apxtri.js --log-date-format 'DD-MM HH:mm:ss.SSS'",
"dev": "NODE_MODE=dev node apxtri.js", "dev": "NODE_MODE=dev node apxtri.js",
"unittest": "node unittest.js", "unittest": "node unittest.js",
"apidoc": "apidoc -c ../conf/apidoc/apidoc_$tribe.json -o ../nationchains/tribes/$tribe/www/cdn/apidoc/", "apidoc": "apidoc -c ../../../conf/apidoc/apidoc_$tribe.json -o ../../$tribe/www/cdn/apidoc/",
"publishtestwall": "scp -r /media/phil/usbfarm/apxtowns/dev-ants/nationchains/tribes/$space phil@wall-ants://home/phil/apxtowns/testwall-ants/nationchains/tribes/$space/..", "publishtestwall": "scp -r /media/phil/usbfarm/apxtowns/dev-ants/tribes/$space phil@wall-ants://home/phil/apxtowns/testwall-ants/tribes/$space/..",
"publishwall": "scp -r /media/phil/usbfarm/apxtowns/dev-ants/nationchains/tribes/$space phil@wall-ants://home/phil/apxtowns/wall-ants/nationchains/tribes/$space/..", "publishwall": "scp -r /media/phil/usbfarm/apxtowns/dev-ants/tribes/$space phil@wall-ants://home/phil/apxtowns/wall-ants/tribes/$space/..",
"publishhouse": "scp -r /media/phil/usbfarm/apxtowns/dev-ants/nationchains/tribes/$space phil@house-ants://home/phil/apxtowns/house-ants/nationchains/tribes/$space/.." "publishhouse": "scp -r /media/phil/usbfarm/apxtowns/dev-ants/tribes/$space phil@house-ants://home/phil/apxtowns/house-ants/tribes/$space/.."
}, },
"commentscript": "cf wiki apxtri doc for details: yarn startpm2 -n teswallants, yarn pm2 stop testwallants, yarn pm2 delete testwallants, yarn pm2 logs --lines 200 testwall, yarn pm2 monit -n testwallants, yarn pm2 save tribe=tribeid yarn apidoc to build apidoc // space=adminapi/www/cdn/apidoc yarn publishtestwall ", "commentscript": "cf wiki apxtri doc for details: yarn startpm2 -n teswallants, yarn pm2 stop testwallants, yarn pm2 delete testwallants, yarn pm2 logs --lines 200 testwall, yarn pm2 monit -n testwallants, yarn pm2 save tribe=tribeid yarn apidoc to build apidoc // space=adminapi/www/cdn/apidoc yarn publishtestwall ",
"maintainers": [ "maintainers": [

View File

@ -1,6 +1,6 @@
const express = require( 'express' ); const express = require( 'express' );
const fs=require('fs-extra'); const fs=require('fs-extra');
const conf = require(`../../conf/townconf.json`); const conf = require(`../../../../conf/townconf.json`);
// Classes // Classes
const Nations = require( '../models/Nations.js' ); const Nations = require( '../models/Nations.js' );
@ -17,7 +17,7 @@ Manage a new towns in a nation => update nation:[nationname:towns:[]} contracts/
/** /**
* @api {put} /nations/viewtown/:town - nationlist from a town major * @api {put} adminapi/nations/viewtown/:town - nationlist from a town major
* @apigroup Nation * @apigroup Nation
* @apiName nationlist * @apiName nationlist
* @apiDescription get list of nation from a town to help this instance to update network topology * @apiDescription get list of nation from a town to help this instance to update network topology

View File

@ -26,7 +26,7 @@ router.post("/backend", (req, res) => {
}) })
/** /**
* @api {get} /notifications/:alias/:tribeId * @api {get} adminapi/notifications/:alias/:tribeId
* @apiName notiflist * @apiName notiflist
* @apiDescription Get list of notifications for an alias and a tribe * @apiDescription Get list of notifications for an alias and a tribe
* @apiGroup Notifications * @apiGroup Notifications
@ -46,15 +46,15 @@ router.get("/:alias/:tribeId", (req, res) => {
/** /**
* @api {POST} /notifications/registeranonymous/:tribe/:mlist/:typekey/:data -Contact anonymous * @api {POST} adminapi/notifications/registeranonymous/:tribe/:mlist/:typekey/:data -Register email||phone to mlist
* @apiName register * @apiName register
* @apiGroup Notifications * @apiGroup Notifications
* @apiDescription Register an email into a mailinglist mlist * @apiDescription Register an email or phone into a mailinglist mlist
* @apiBody {string} tribe an existing tribe * @apiBody {string} tribe an existing tribe
* @apiBody {string} mlist a mailing list name * @apiBody {string} mlist a mailing list name
* @apiBody {string} key email or phone * @apiBody {string} key email or phone keyword
* @apiBod {string} srckey must exist in tribes/schema/lg/enumtrk_xx.json * @apiBod {string} srckey must exist in tribes/schema/lg/enumtrk_xx.json
* @apiParams {string} data the email or phone * @apiParams {string} data the email or phone value
* @apiSuccess {object} update mailinglist/{mlist}.json successfull * @apiSuccess {object} update mailinglist/{mlist}.json successfull
* @apiSuccessExample {json} successfullmessage * @apiSuccessExample {json} successfullmessage
* HTTP/1.1 200 OK * HTTP/1.1 200 OK
@ -77,8 +77,8 @@ router.post("/registeranonymous",checkHeaders,(req,res)=>{
res.status(result.status).json(result) res.status(result.status).json(result)
}) })
/** /**
* @api {GET} /notifications/unregister/:tribe/:mlist/:typekey/:data/:validation -Contact anonymous * @api {GET} adminapi/notifications/unregister/:tribe/:mlist/:typekey/:data/:validation -Unregister email o r phone from a mlist or all mlist
* @apiName contactanonymous * @apiName unregister
* @apiGroup Notifications * @apiGroup Notifications
* @apiDescription Register an email into a mailinglist mlist * @apiDescription Register an email into a mailinglist mlist
* @apiParams {string} tribe an existing tribe * @apiParams {string} tribe an existing tribe
@ -94,7 +94,7 @@ router.post("/registeranonymous",checkHeaders,(req,res)=>{
* *
*/ */
router.get("/unregisteranonymous/:tribe/:mlist/:typekey/:srckey/:data/:validation", checkHeaders, (req, res) => { router.get("/unregister/:tribe/:mlist/:typekey/:srckey/:data/:validation", checkHeaders, (req, res) => {
Notifications.registertolist = (typekey, tribe, mlist, srckey, uuid) Notifications.registertolist = (typekey, tribe, mlist, srckey, uuid)
result= Notifications.registertolist( result= Notifications.registertolist(
req.params.typekey, req.params.typekey,
@ -106,7 +106,7 @@ router.get("/unregisteranonymous/:tribe/:mlist/:typekey/:srckey/:data/:validatio
}) })
/** /**
* @api {POST} /notifications/contactanonymous/:tribe -Contact anonymous * @api {POST} adminapi/notifications/contactanonymous/:tribe -Contact anonymous
* @apiName contactanonymous * @apiName contactanonymous
* @apiGroup Notifications * @apiGroup Notifications
* @apiDescription Register a contact in tribe and send a mail to admin of tribe * @apiDescription Register a contact in tribe and send a mail to admin of tribe

View File

@ -2,7 +2,7 @@ const express = require("express");
const glob = require("glob"); const glob = require("glob");
const fs = require("fs-extra"); const fs = require("fs-extra");
const path = require("path"); const path = require("path");
const conf = require(`../../conf/townconf.json`); const conf = require(`../../../../conf/townconf.json`);
const Odmdb = require("../models/Odmdb.js"); const Odmdb = require("../models/Odmdb.js");
// Middlewares // Middlewares
const checkHeaders = require("../middlewares/checkHeaders.js"); const checkHeaders = require("../middlewares/checkHeaders.js");
@ -10,46 +10,71 @@ const isAuthenticated = require("../middlewares/isAuthenticated.js");
const router = express.Router(); const router = express.Router();
/** /**
* @api {get} /odmdb/objects - objects Get * @api {get} adminapi/odmdb/schemas - objects Get
* @apiGroup Odmdb * @apiGroup Odmdb
* @apiName getIndex * @apiName getIndex
* @apiDescription Get objects available for header.xtribe * @apiDescription Get objects available result is store in data.apx.conf for schema conf of adminapi schema (pagans,towns,... ) and data.apx.objectnames as array of schema name. Schema related to tribe are store in data.tribe.conf and data.tribe.objectnames where tribe come from header.xtribe
* *
* @apiSuccess {object} contain data.indexname * @apiSuccess {object} contain data.indexname
* @apiSuccessExample {json} Success-Response: * @apiSuccessExample {json} Success-Response:
* HTTP/1.1 200 OK * HTTP/1.1 200 OK
* {"status":200, "ref":"Odmdb", "msg":"objectslist", "data":{indexname,content:{index file}} * {"status":200, "ref":"Odmdb", "msg":"objectslist", "data":{apx:{conf,objectnames:[]},tribe:{conf,objectnames:[]}}}
*
*
*/ */
router.get("/objects", checkHeaders, isAuthenticated, (req, res) => { router.get("/schemas", checkHeaders, isAuthenticated, (req, res) => {
const data = { const data = {
tribe: req.session.header.xtribe, tribe: req.session.header.xtribe,
apx: { conf: {}, objectnames: [] }, apx: { conf: {}, objectnames: [] },
tribe: { conf: {}, objectnames: [] }, tribe: { conf: {}, objectnames: [] },
}; };
glob.sync(`../nationchains/tribes/adminapi/schema/*.json`).forEach((f) => { glob.sync(`../schema/*.json`).forEach((f) => {
const objectname = path.basename(f, ".json"); const objectname = path.basename(f, ".json");
if (objectname == "conf") { if (objectname == "conf") {
data.apx.conf = fs.readJSONSync(f); data.apx.conf = fs.readJSONSync(f);
} else { } else {
data.apx.objectnames.push(objectnames); data.apx.objectnames.push(objectname);
} }
}); });
glob glob
.sync(`../nationchains/tribes/${req.session.header.xtribe}/schema/*.json`) .sync(`../../${req.session.header.xtribe}/schema/*.json`)
.forEach((f) => { .forEach((f) => {
const objectname = path.basename(f, ".json"); const objectname = path.basename(f, ".json");
if (objectname == "conf") { if (objectname == "conf") {
data.apx.conf = fs.readJSONSync(f); data.tribe.conf = fs.readJSONSync(f);
} else { } else {
data.apx.objectnames.push(objectnames); data.tribe.objectnames.push(objectname);
} }
}); });
res.status(200).json({ status: 200, ref: "Odmdb", msg: "objectslist", data }); res.status(200).json({ status: 200, ref: "Odmdb", msg: "objectslist", data });
}); });
/** /**
* @api {get} /odmdb/idx/:tribe/:objectname/:indexname - index Get * @api {get} adminapi/odmdb/schema/:source/:objectname - Schema Get in the language header
* @apiGroup Odmdb
* @apiName getIndex
* @apiDescription Get schema in the requested language if login have accessright
*
* @apiParams {string} source (adminapi || tribe) looking for adminapi or in tribe (header.xtribe)
* @apiParams {string} objectname requested must exist in adminapi or tribe
* @apiSuccess {object} contain data.schema
* @apiSuccessExample {json} Success-Response:
* HTTP/1.1 200 OK
* {"status":200, "ref":"Odmdb", "msg":"schema", "data":{schema,objectname,lg}
*/
router.get("/schema/:source/:objectname", checkHeaders, isAuthenticated, (req, res) => {
if (!['adminapi','tribe'].includes(req.params.source)){
res(406).json({status:406,ref:"Odmdb",msg:"mustbetribeoradminapi",data:{source:req.params.source}})
}else{
let objectPathname=`../../adminapi/objects/${req.params.objectname}`
if (req.params.source=="tribe"){
objectPathname=`../../${req.headers.xtribe}/objects/${req.params.objectname}`
}
console.log(objectPathname)
const retschema = Odmdb.Schema(objectPathname, true, req.header.xlang)
res.status(retschema.status).json(retschema);
}
});
/**
* @api {get} adminapi/odmdb/idx/:tribe/:objectname/:indexname - index Get
* @apiGroup Odmdb * @apiGroup Odmdb
* @apiName getIndex * @apiName getIndex
* @apiDescription Get index file for an object * @apiDescription Get index file for an object
@ -104,7 +129,7 @@ router.get(
); );
/** /**
* @api {get} /odmdb/rebuildidx/:objectname - index refresh all * @api {get} adminapi/odmdb/rebuildidx/:objectname - index refresh all
* @apiGroup Odmdb * @apiGroup Odmdb
* @apiName refreshAllIndex * @apiName refreshAllIndex
* @apiDescription Rebuild all index for an object, this can be usefull in case crash or any data conflict. * @apiDescription Rebuild all index for an object, this can be usefull in case crash or any data conflict.
@ -174,7 +199,7 @@ router.get(
); );
/** /**
* @api {post} /odmdb/itm/:objectname - item Create * @api {post} adminapi/odmdb/itm/:objectname - item Create
* @apiGroup Odmdb * @apiGroup Odmdb
* @apiName postItm * @apiName postItm
* @apiPermission none * @apiPermission none
@ -233,12 +258,12 @@ router.get(
); );
/** /**
* @api {get} /odmdb/itm/:objectname/:primaryindex - item Get * @api {get} adminapi/odmdb/itm/:objectname/:primaryindex - item Get
* @apiGroup Odmdb * @apiGroup Odmdb
* @apiName getItemFromId * @apiName getItemFromId
* @apiDescription Get itm for a primaryid of an object * @apiDescription Get itm for a primaryid of an object
* *
* @apiParam {String} objectname name Mandatory if in conf.nationObjects then file is into nationchains/ else in /nationchains/tribes/xtribe/objectname * @apiParam {String} objectname name Mandatory if in conf.nationObjects then file is into nationchains/ else in /tribes/xtribe/objectname
* @apiParam {String} primaryindex the unique id where item is store * @apiParam {String} primaryindex the unique id where item is store
* *
* @apiError {json} objectNotfound the file item does not exist * @apiError {json} objectNotfound the file item does not exist
@ -281,11 +306,11 @@ router.get(
} }
); );
/** /**
* @api {get} https://wall-ants.ndda.fr/Checkjson.js - schema Checkjson.js * @api {get} https://wall-ants.ndda.fr/adminapi/Checkjson.js - schema Checkjson.js
* @apiGroup Odmdb * @apiGroup Odmdb
* @apiName checkjsonjs * @apiName checkjsonjs
* @apiDescription Public js lib to import in a browser by :<br> * @apiDescription Public js lib to import in a browser by :<br>
* ```<script src="wall-ants.ndda.fr/nationchains/contracts/Checkjson.js"></script>``` * ```<script src="https://wall-ants.ndda.fr/adminapi/Checkjson.js"></script>```
* to import in a node.js:<br> * to import in a node.js:<br>
* ```const Checkjson = require(`Checkjson.js`);``` * ```const Checkjson = require(`Checkjson.js`);```
* *
@ -299,12 +324,12 @@ router.get(
* - {status:417, multimsg:[{ref:"Checkjson",msg:"errorkey",data:{}}]}<br> * - {status:417, multimsg:[{ref:"Checkjson",msg:"errorkey",data:{}}]}<br>
* *
* To identify issues, get the language errorkey list with a get * To identify issues, get the language errorkey list with a get
* https://wall-ants.ndda.fr/nationchains/models/Checkjson_lg.json * MUST BE UPDATE with conf access https://wall-ants.ndda.fr/adminapi/objects/tplstring/Checkjson_lg.json
* *
*/ */
/** /**
* @api {get} https://wall-ants.ndda.fr/nationchains/schema/:objectname - schema Get public * @api {get} https://wall-ants.ndda.fr/adminapi/schema/:objectname - schema Get public
* @apiGroup Odmdb * @apiGroup Odmdb
* @apiName getPublicSchema * @apiName getPublicSchema
* @apiDescription Get a Schema model from public apxtri (nations, pagans,persons,towns, tribes,wwws) * @apiDescription Get a Schema model from public apxtri (nations, pagans,persons,towns, tribes,wwws)
@ -312,7 +337,7 @@ router.get(
* @apiSuccessExample {json} Fichier direct * @apiSuccessExample {json} Fichier direct
* HTTP/1.1 200 Success-response: * HTTP/1.1 200 Success-response:
{ {
"$id": "https://smatchit.io/schema/pagan", "$id": "https://wall-ants.ndda.fr/schema/pagan",
"$comment": "To create account bin apxtri", "$comment": "To create account bin apxtri",
"title": "Pagans identity", "title": "Pagans identity",
"description": "A numeric id in the nationchains world", "description": "A numeric id in the nationchains world",
@ -569,7 +594,7 @@ router.put(
); );
/** /**
* @api {get} https://wall-ants.ndda.fr/nationchains/models/:modelname_lg.json - translation notif Get public * @api {get} https://wall-ants.ndda.fr/adminapi/objects/tplstring/:modelname_lg.json - translation notif Get public
* @apiGroup Odmdb * @apiGroup Odmdb
* @apiName getPublicModelmessagekey * @apiName getPublicModelmessagekey
* @apiDescription Get a public json object for the ref: modelname in language lg, to get a template description with key msg * @apiDescription Get a public json object for the ref: modelname in language lg, to get a template description with key msg

View File

@ -9,7 +9,7 @@ const Odmdb = require("../models/Odmdb.js");
const checkHeaders = require("../middlewares/checkHeaders.js"); const checkHeaders = require("../middlewares/checkHeaders.js");
const isAuthenticated = require("../middlewares/isAuthenticated.js"); const isAuthenticated = require("../middlewares/isAuthenticated.js");
const conf = require(`../../conf/townconf.json`); const conf = require(`../../../../conf/townconf.json`);
const currentmod = "pagans"; const currentmod = "pagans";
const log = conf.api.activelog.includes(currentmod); const log = conf.api.activelog.includes(currentmod);
@ -21,7 +21,7 @@ const router = express.Router();
/** /**
* Alias exist then return public key or not * Alias exist then return public key or not
* @api {get} /pagans/alias/:alias - alias Get * @api {get} adminapi/pagans/alias/:alias - alias Get
* @apiName isalias * @apiName isalias
* @apiGroup Pagans * @apiGroup Pagans
* @apiDescription If alias exist return its publickey * @apiDescription If alias exist return its publickey
@ -44,7 +44,7 @@ router.get("/alias/:alias", (req, res) => {
res.status(getalias.status).send(getalias); res.status(getalias.status).send(getalias);
}); });
/** /**
* @api {get} /pagans/logout - pagan Logout * @api {get} adminapi/pagans/logout - pagan Logout
* @apiName Removetoken * @apiName Removetoken
* @apiGroup Pagans * @apiGroup Pagans
* @apiDescription Remove server's token only the owner of the token (no one else can delete a token ) * @apiDescription Remove server's token only the owner of the token (no one else can delete a token )
@ -66,7 +66,7 @@ router.get("/logout", checkHeaders, isAuthenticated, (req, res) => {
res.status(logout.status).json(logout); res.status(logout.status).json(logout);
}); });
/** /**
* @api {get} /pagans/isauth - pagan isAuthenticated? * @api {get} adminapi/pagans/isauth - pagan isAuthenticated?
* @apiName isAuth * @apiName isAuth
* @apiGroup Pagans * @apiGroup Pagans
* @apiDescription Check if pagan's token is still valid * @apiDescription Check if pagan's token is still valid
@ -94,7 +94,7 @@ router.get("/isauth", checkHeaders, isAuthenticated, (req, res) => {
}); });
/** /**
* @api {post} /pagans - pagan Post * @api {post} adminapi/pagans - pagan Post
* @apiName addpagan * @apiName addpagan
* @apiGroup Pagans * @apiGroup Pagans
* @apiDescription * @apiDescription
@ -137,7 +137,7 @@ router.post("/", checkHeaders, isAuthenticated, async (req, res) => {
return return
} }
const objpagan = { alias: req.body.alias, publickey: req.body.publickey }; const objpagan = { alias: req.body.alias, publickey: req.body.publickey };
const newpagan = Odmdb.cud(`../nationchains/pagans`, "C", objpagan, role); const newpagan = Odmdb.cud(`../../objects/pagans`, "C", objpagan, role);
const createprocess={status:200, ref:"Pagans", msg:"successfulcreate",data:{alias:req.body.alias}}; const createprocess={status:200, ref:"Pagans", msg:"successfulcreate",data:{alias:req.body.alias}};
if (newpagan.status == 200) { if (newpagan.status == 200) {
if (req.body.email) { if (req.body.email) {
@ -171,7 +171,7 @@ router.post("/", checkHeaders, isAuthenticated, async (req, res) => {
passphrase: req.body.passphrase, passphrase: req.body.passphrase,
}, },
}; };
const personup = Odmdb.cud(`../nationchains/tribes/${req.body.trustedtribe}/objects/persons`, "C", persondata, {xprofils:["pagan"],xalias:req.body.alias}); const personup = Odmdb.cud(`../../${req.body.trustedtribe}/objects/persons`, "C", persondata, {xprofils:["pagan"],xalias:req.body.alias});
if (log) console.log(currentmod,'person create',personup) if (log) console.log(currentmod,'person create',personup)
if (personup.status==200){ if (personup.status==200){
createprocess.data.createperson=true; createprocess.data.createperson=true;
@ -191,14 +191,14 @@ router.post("/", checkHeaders, isAuthenticated, async (req, res) => {
} }
}); });
/** /**
* @api {delete} /pagans/alias/:alias - pagan Delete * @api {delete} adminapi/pagans/alias/:alias - pagan Delete
* @apiName deletepagan * @apiName deletepagan
* @apiGroup Pagans * @apiGroup Pagans
* @apiDescription * @apiDescription
* Delete an alias and his publickey, this mean that publickey disapear as well as alias. We set dt_delete * Delete an alias and his publickey, this mean that publickey disapear as well as alias. We set dt_delete
* */ * */
router.delete("/alias/:alias", checkHeaders, isAuthenticated, (req, res) => { router.delete("/alias/:alias", checkHeaders, isAuthenticated, (req, res) => {
const personpath=`../nationchains/pagans`; const personpath=`../objects/pagans`;
const role = { const role = {
xalias: req.session.header.xalias, xalias: req.session.header.xalias,
xprofils: req.session.header.xprofils, xprofils: req.session.header.xprofils,
@ -209,12 +209,12 @@ router.delete("/alias/:alias", checkHeaders, isAuthenticated, (req, res) => {
if (log) console.log(delperson) if (log) console.log(delperson)
res.status(delperson.status).json(delperson); res.status(delperson.status).json(delperson);
if (log) console.log(`DELETE pagans nationchains/pagans/${req.params.alias}.json`); if (log) console.log(`DELETE pagans adminapi/objects/pagans/${req.params.alias}.json`);
const result = Pagans.delete(req.params.alias, req.session.header); const result = Pagans.delete(req.params.alias, req.session.header);
res.status(result.status).send(result); res.status(result.status).send(result);
}); });
/** /**
* @api {delete} /pagans/person/:tribe/:alias - person Delete * @api {delete} adminapi/pagans/person/:tribe/:alias - person Delete
* @apiName deleteperson * @apiName deleteperson
* @apiGroup Pagans * @apiGroup Pagans
* @apiDescription * @apiDescription
@ -225,7 +225,7 @@ router.delete("/alias/:alias", checkHeaders, isAuthenticated, (req, res) => {
* @apiParam {string} alias to delete as person * @apiParam {string} alias to delete as person
* */ * */
router.delete("/person/:tribe/:alias", checkHeaders, isAuthenticated, (req, res) => { router.delete("/person/:tribe/:alias", checkHeaders, isAuthenticated, (req, res) => {
const personpath=`../nationchains/tribes/${req.params.tribe}/objects/persons`; const personpath=`../../${req.params.tribe}/objects/persons`;
const role = { const role = {
xalias: req.session.header.xalias, xalias: req.session.header.xalias,
xprofils: req.session.header.xprofils, xprofils: req.session.header.xprofils,
@ -238,7 +238,7 @@ router.delete("/person/:tribe/:alias", checkHeaders, isAuthenticated, (req, res)
}); });
/** /**
* @api {get} /pagans/person/:alias - person Get * @api {get} adminapi/pagans/person/:alias - person Get
* @apiName getpersondata * @apiName getpersondata
* @apiDescription Get person information from his alias for a xtribe (data and profils per apps) * @apiDescription Get person information from his alias for a xtribe (data and profils per apps)
* @apiGroup Pagans * @apiGroup Pagans
@ -258,12 +258,13 @@ router.delete("/person/:tribe/:alias", checkHeaders, isAuthenticated, (req, res)
* else need accessright to on person set at R * else need accessright to on person set at R
* */ * */
router.get("/person/:alias", checkHeaders, isAuthenticated, (req, res) => { router.get("/person/:alias", checkHeaders, isAuthenticated, (req, res) => {
const getperson=Odmdb.r( `../nationchains/tribes/${req.session.header.xtribe}/objects/persons`,req.params.alias,{ xprofils: req.session.header.xprofils, xalias: req.session.header.xalias }) console.log(path.resolve(`../../${req.session.header.xtribe}/objects/persons`))
const getperson=Odmdb.r( `../../${req.session.header.xtribe}/objects/persons`,req.params.alias,{ xprofils: req.session.header.xprofils, xalias: req.session.header.xalias })
res.status(getperson.status).send(getperson); res.status(getperson.status).send(getperson);
}); });
/** /**
* @api {put} /pagans/person/:tribe - person Put * @api {put} adminapi/pagans/person/:tribe - person Put
* @apiName updateperson * @apiName updateperson
* @apiGroup Pagans * @apiGroup Pagans
* @apiDescription add or update a person = alias in tribe. xalias authenticated (in header) must have a profil with accessright into schema person to create a person. * @apiDescription add or update a person = alias in tribe. xalias authenticated (in header) must have a profil with accessright into schema person to create a person.
@ -275,7 +276,7 @@ router.get("/person/:alias", checkHeaders, isAuthenticated, (req, res) => {
*/ */
router.put("/person/:tribe", checkHeaders, isAuthenticated, (req, res) => { router.put("/person/:tribe", checkHeaders, isAuthenticated, (req, res) => {
//console.log(req.body); //console.log(req.body);
const pathobj=`../nationchains/tribes/${req.params.tribe}/objects/persons`; const pathobj=`../../${req.params.tribe}/objects/persons`;
const action = (fs.existsSync(`${pathobj}/itm/${req.body.alias}.json`))? "U":"C"; const action = (fs.existsSync(`${pathobj}/itm/${req.body.alias}.json`))? "U":"C";
//set req.body to be in line with schema //set req.body to be in line with schema
if (!req.body.profils){ if (!req.body.profils){
@ -287,7 +288,7 @@ router.put("/person/:tribe", checkHeaders, isAuthenticated, (req, res) => {
}); });
/** /**
* @api {get} /pagans/keyrecovery/:tribe/:email - recovery keys by email * @api {get} adminapi/pagans/keyrecovery/:tribe/:email - recovery keys by email
* @apiName recoveryKey * @apiName recoveryKey
* @apiGroup Pagans * @apiGroup Pagans
* @apiDescription Send mails with all registers identities (one per alias where recoveryauth.email is register) * @apiDescription Send mails with all registers identities (one per alias where recoveryauth.email is register)
@ -303,7 +304,7 @@ router.put("/person/:tribe", checkHeaders, isAuthenticated, (req, res) => {
* *
*/ */
router.get("/keyrecovery/:tribe/:email", checkHeaders, (req, res) => { router.get("/keyrecovery/:tribe/:email", checkHeaders, (req, res) => {
const idxreco=`../../nationchains/tribes/${req.params.tribe}/objects/persons/idx/emailrecovery_alias.json`; const idxreco=`../../${req.params.tribe}/objects/persons/idx/emailrecovery_alias.json`;
if (fs.existsSync(idxreco)){ if (fs.existsSync(idxreco)){
const emailreco = fs.readJSONSync(idxreco); const emailreco = fs.readJSONSync(idxreco);
if (emailreco[req.params.email]){ if (emailreco[req.params.email]){
@ -321,7 +322,7 @@ router.get("/keyrecovery/:tribe/:email", checkHeaders, (req, res) => {
} }
}); });
/** /**
* @api {get} /pagans/keyrecovery/:tribe/:alias - recovery keys by alias * @api {get} adminapi/pagans/keyrecovery/:tribe/:alias - recovery keys by alias
* @apiName recoveryKey * @apiName recoveryKey
* @apiGroup Pagans * @apiGroup Pagans
* @apiDescription Send to email recovery if exist key files * @apiDescription Send to email recovery if exist key files

View File

@ -2,7 +2,7 @@ const express = require("express");
const glob = require("glob"); const glob = require("glob");
const fs = require("fs-extra"); const fs = require("fs-extra");
const path = require("path"); const path = require("path");
const conf = require(`../../conf/townconf.json`); const conf = require(`../../../../conf/townconf.json`);
const Odmdb = require("../models/Odmdb.js"); const Odmdb = require("../models/Odmdb.js");
// Middlewares // Middlewares
const checkHeaders = require("../middlewares/checkHeaders"); const checkHeaders = require("../middlewares/checkHeaders");

View File

@ -2,7 +2,7 @@ const express = require( 'express' );
const fs = require( 'fs-extra' ); const fs = require( 'fs-extra' );
const path = require( 'path' ); const path = require( 'path' );
const glob = require('glob'); const glob = require('glob');
const conf = require(`../../conf/townconf.json`); const conf = require(`../../../../conf/townconf.json`);
// Classes // Classes
const Tribes = require( '../models/Tribes.js' ); const Tribes = require( '../models/Tribes.js' );
@ -11,8 +11,41 @@ const checkHeaders = require( '../middlewares/checkHeaders' );
const isAuthenticated = require( '../middlewares/isAuthenticated' ); const isAuthenticated = require( '../middlewares/isAuthenticated' );
const router = express.Router(); const router = express.Router();
/** /**
* @api {get} /tribes/www/:tribeId - tribe list * @api {get} adminapi/tribes/conf/:tribe - tribe list
* @apiName getconf
* @apiDescription Get list of route and model for a town server
* @apiGroup Tribes
*
* @apiSuccess (object) get tribes conf on this server
* @apiSuccessExample {json}
* HTTP/1.1 200 OK
* {status:200,ref:"Tribes",msg:"tribesconf",data:{routes:[],modele:[{model:,tplstrings:[lg,lg]}]}}
*/
router.get('/config/:tribe', checkHeaders,isAuthenticated,(req,res)=>{
/*console.log("passe la")
AJOUTER gestion accessright
req.session.header.accessrights.data[ req.params.tribe ] &&
req.session.header.accessrights.data[ req.params.tribe ].tribeid &&
req.session.header.accessrights.data[ req.params.tribe ].tribeid.includes( 'R' )
*/
if("authorize"=="authorize"){
const tribconf=`../../itm/${req.params.tribe}.json`
if (!fs.existsSync(tribconf)){
res.status(404).json({status:404,ref:"Tribes",msg:"tribedoesnotexist", data:{tribe:req.params.tribe}})
}else{
res.status(200).json({satatus:200,ref:"Tribes",msg:"tribconf",data:{conf:fs.readJsonSync(tribconf)}})
}
}else{
res.status( 403 )
.json( { msg: [ 'forbidenAccess' ], ref: 'Tribes' } )
.end();
}
})
/**
* @api {get} adminapi/tribes/www/:tribeId - tribe list
* @apiName getlisttrib * @apiName getlisttrib
* @apiDescription Get list of www object (space web) * @apiDescription Get list of www object (space web)
* @apiGroup Tribes * @apiGroup Tribes
@ -23,7 +56,7 @@ const router = express.Router();
* HTTP/1.1 200 OK * HTTP/1.1 200 OK
* {status:200,ref:"Tribes",msg:"listwww",data:{listwww}} * {status:200,ref:"Tribes",msg:"listwww",data:{listwww}}
*/ */
router.get('www', checkHeaders,isAuthenticated,(req,res)=>{ router.get('/www', checkHeaders,isAuthenticated,(req,res)=>{
let listwww=[] let listwww=[]
glob.sync(`${conf.dirtown}/tribes/${req.params.tribeId}/www/*`).forEach(d=>{ glob.sync(`${conf.dirtown}/tribes/${req.params.tribeId}/www/*`).forEach(d=>{
listwww.push(d.split("/").pop()) listwww.push(d.split("/").pop())
@ -127,7 +160,7 @@ router.get( '/plugins/:tribeid/:pluginname/:key/:filename', ( req, res ) => {
} ); } );
router.get( '/dirls', checkHeaders, isAuthenticated, ( req, res ) => { router.get( '/dirls', checkHeaders, isAuthenticated, ( req, res ) => {
// url /Tribes/dirls?rep=referentials/dataManagement // url adminapi/tribes/dirls?rep=referentials/dataManagement
// request information about a req.query.rep from header xworkon/ // request information about a req.query.rep from header xworkon/
// return // return
// {file:[{}],dir:[{}]} // {file:[{}],dir:[{}]}
@ -145,7 +178,7 @@ router.get( '/dirls', checkHeaders, isAuthenticated, ( req, res ) => {
} ) } )
router.delete( '/ls', checkHeaders, isAuthenticated, ( req, res ) => { router.delete( '/ls', checkHeaders, isAuthenticated, ( req, res ) => {
// check Accessright with D or O on each // check Accessright with D or O on each
// url /Tribes/ls // url adminapi/tribes/ls
// req.body.files=[listfiles file to delete ] // req.body.files=[listfiles file to delete ]
const authfiles = Tribes.checkaccessfiles( req.body, 'D', req.session.header.accessrights, req.session.header.apixpaganid ); const authfiles = Tribes.checkaccessfiles( req.body, 'D', req.session.header.accessrights, req.session.header.apixpaganid );
authfiles.ok.forEach( f => { fs.remove( `${config.tribes}/${f}` ); } ) authfiles.ok.forEach( f => { fs.remove( `${config.tribes}/${f}` ); } )
@ -202,7 +235,7 @@ router.post( '/downloadls', checkHeaders, isAuthenticated, ( req, res ) => {
} }
} ); } );
router.post( '/upfilepond', checkHeaders, isAuthenticated, ( req, res ) => { router.post( '/upfilepond', checkHeaders, isAuthenticated, ( req, res ) => {
console.log( 'post /Tribes/uploadfilepond' ); console.log( 'post adminapi/tribes/uploadfilepond' );
// Store file and return a unique id to save button // Store file and return a unique id to save button
// that provide folder where to store it // that provide folder where to store it
const formidable = require( 'formidable' ); const formidable = require( 'formidable' );
@ -278,7 +311,7 @@ router.post( '/uploadfile', checkHeaders, isAuthenticated, ( req, res ) => {
router.post( '/uploadzip', checkHeaders, ( req, res ) => { router.post( '/uploadzip', checkHeaders, ( req, res ) => {
console.log( 'uploadzip a file ' ) console.log( 'uploadzip a file ' )
/* no authentification to upload a zip filename into /tribes/${xworkon}/${clientconf.uploadzip[filename].dest} /* no authentification to upload a zip filename into adminapi/tribes/${xworkon}/${clientconf.uploadzip[filename].dest}
unzip it using the password ${clientconf.uploadzip[filename].psw unzip it using the password ${clientconf.uploadzip[filename].psw
if no error then run the callback ${clientconf.uploadzip[filename].callback if no error then run the callback ${clientconf.uploadzip[filename].callback
but a password to unzip but a password to unzip
@ -352,7 +385,7 @@ router.post( '/uploadzip', checkHeaders, ( req, res ) => {
router.post( '/upload', checkHeaders, isAuthenticated, ( req, res ) => { router.post( '/upload', checkHeaders, isAuthenticated, ( req, res ) => {
1 // ACHANGER VIA usage sendjson 1 // ACHANGER VIA usage sendjson
// url /Tribes/upload?save=tmp&rep=referentials/dataManagement // url adminapi/tribes/upload?save=tmp&rep=referentials/dataManagement
// if save=tmp then store in a tmp file // if save=tmp then store in a tmp file
// if save=ok then mv the tmp file to the folder // if save=ok then mv the tmp file to the folder
// midlleware hasAccessrighton.js is not apply here only to access/update/create information inside an object // midlleware hasAccessrighton.js is not apply here only to access/update/create information inside an object

View File

@ -1,12 +1,12 @@
server { server {
server_name {{#dns}} {{.}} {{/dns}}; server_name {{#dns}} {{.}} {{/dns}};
access_log {{foldertowns}}/{{townId}}-{{nationId}}/nationchains/tribes/log/nginx/{{tribeId}}_{{website}}.access.log main; access_log {{foldertowns}}/{{townId}}-{{nationId}}/tribes/log/nginx/{{tribeId}}_{{website}}.access.log main;
set $trackme 0; set $trackme 0;
if ( $uri ~ ^/trk/ ){ if ( $uri ~ ^/trk/ ){
set $trackme 1; set $trackme 1;
} }
access_log {{foldertowns}}/{{townId}}-{{nationId}}/nationchains/tribes/log/nginx/{{tribeId}}_{{website}}.trk.log tracker if=$trackme ; access_log {{foldertowns}}/{{townId}}-{{nationId}}/tribes/log/nginx/{{tribeId}}_{{website}}.trk.log tracker if=$trackme ;
location ~* /trk/ { location ~* /trk/ {
if ( $uri ~ ^/trk/redirect ){ if ( $uri ~ ^/trk/redirect ){
return 301 $arg_url; return 301 $arg_url;
@ -28,23 +28,23 @@ location ~* /nationchains/models/ {
location ~* /nationchains/schema/ { location ~* /nationchains/schema/ {
#outside of nationchains for git purpose #outside of nationchains for git purpose
rewrite /nationchains/schema/(.*$) /$1 break; rewrite /nationchains/schema/(.*$) /$1 break;
root {{{foldertowns}}/{{townId}}-{{nationId}}/nationchains/tribes/adminapi/schema/; root {{{foldertowns}}/{{townId}}-{{nationId}}/tribes/adminapi/schema/;
} }
location ~* /{{tribeId}}/schema/{ location ~* /{{tribeId}}/schema/{
rewrite /{{tribeId}}/schema/(.*$) /$1 break; rewrite /{{tribeId}}/schema/(.*$) /$1 break;
root {{foldertowns}}/{{townId}}-{{nationId}}/nationchains/tribes/{{tribeId}}/schema/; root {{foldertowns}}/{{townId}}-{{nationId}}/tribes/{{tribeId}}/schema/;
} }
location ~* /{{tribeId}}/models/{ location ~* /{{tribeId}}/models/{
rewrite /{{tribeId}}/models/(.*$) /$1 break; rewrite /{{tribeId}}/models/(.*$) /$1 break;
root {{foldertowns}}/{{townId}}-{{nationId}}/nationchains/tribes/{{tribeId}}/api/models/lg/; root {{foldertowns}}/{{townId}}-{{nationId}}/tribes/{{tribeId}}/api/models/lg/;
} }
location /cdn/ { location /cdn/ {
expires 1y; expires 1y;
add_header Cache-Control "public"; add_header Cache-Control "public";
rewrite /cdn/(.*$) /$1 break; rewrite /cdn/(.*$) /$1 break;
root {{foldertowns}}/{{townId}}-{{nationId}}/nationchains/tribes/{{tribeId}}/www//cdn/; root {{foldertowns}}/{{townId}}-{{nationId}}/tribes/{{tribeId}}/www//cdn/;
} }
location /api/ { location /api/ {
@ -66,9 +66,9 @@ option
location / { location / {
{{#private}} {{#private}}
auth_basic "Mot de passe {{privatelogin}}"; auth_basic "Mot de passe {{privatelogin}}";
auth_basic_user_file {{{foldertowns}}/{{townId}}-{{nationId}}/nationchains/tribes/{{tribeId}}/.htpasswd; auth_basic_user_file {{{foldertowns}}/{{townId}}-{{nationId}}/tribes/{{tribeId}}/.htpasswd;
{{/private}} {{/private}}
root {{foldertowns}}/{{townId}}-{{nationId}}/nationchains/tribes/{{tribeId}}/www/{{{website}}}; root {{foldertowns}}/{{townId}}-{{nationId}}/tribes/{{tribeId}}/www/{{{website}}};
index index.html {{{pageindex}}}; index index.html {{{pageindex}}};
} }
error_page 404 /404.html; error_page 404 /404.html;

View File

@ -1,6 +1,6 @@
const fs = require("fs-extra"); const fs = require("fs-extra");
const dayjs = require("dayjs"); const dayjs = require("dayjs");
const conf = require(`../../conf/townconf.json`); const conf = require(`../../../../conf/townconf.json`);
const l = {}; const l = {};
l.context=""; l.context="";
l.og = (...infos) => { l.og = (...infos) => {
@ -19,7 +19,7 @@ l.og = (...infos) => {
}; };
l.ogprod = (tribe,info) => { l.ogprod = (tribe,info) => {
const logf = `../../nationchains/tribes/${tribe}/logs/apxtri/apxtri_${tribe}.log`; const logf = `../../tribes/${tribe}/logs/apxtri/apxtri_${tribe}.log`;
const msg = `${days.js().toISOString()}###${l.context}###${tribe}###${info}`; const msg = `${days.js().toISOString()}###${l.context}###${tribe}###${info}`;
fs.appendFileSync(logf, msg); fs.appendFileSync(logf, msg);
console.log(msg) console.log(msg)