Modif Odmdb

This commit is contained in:
philc 2024-11-14 18:47:35 +01:00
parent 5a6d49d072
commit 21effdf5be
4 changed files with 23 additions and 22 deletions

View File

@ -114,8 +114,8 @@ apxtri.setuptribe = async (tribe, conf) => {
inittribe.sudoUser = process.env.USER;
//check nation exist and town does not exist
if (
!fs.existsSync("../adminapi/objects/nations/idx/lst_nations.json") ||
!fs.existsSync("../adminapi/objects/towns/idx/lst_towns.json")
!fs.existsSync("../adminapi/objects/nations/idx/lst_nationId.json") ||
!fs.existsSync("../adminapi/objects/towns/idx/lst_townId.json")
) {
console.log(
`Sorry, check setup.sh process that was not able to init your adminapi/objects `
@ -229,7 +229,7 @@ apxtri.runexpress = async (tribesdns, conf) => {
const context = {};
const pathtr = path.resolve(`../${t}`);
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")}`;
context.routes.push(rt);
return { url: rt, route: f };
@ -275,22 +275,23 @@ apxtri.runexpress = async (tribesdns, conf) => {
console.log(currentmod, " app.locals.tribeids", app.locals.tribeids);
// Cors management
let originlst = "test";
let regtxt = "(test";
doms.forEach((d) => {
originlst += `|${d.replace(/\./g, "\\.")}`;
regtxt += `|${d.replace(/\./g, "\\.")}`;
});
const regtxt = `^http.?:\/\/(${originlst})`;
let cor = false;
regtxt+=")$"
// let cor = false;
const regorigin = new RegExp(regtxt);
app.use((req, res, next) => {
if (req.headers.origin == undefined) {
/*if (req.headers.origin == undefined) {
cor = true;
} else {
cor = regorigin.test(req.headers.origin);
}
}*/
const cor=regorigin.test(req.headers.origin);
if (!cor)
console.log(
`The domain name ${req.headers.origin} is not allow to access for CORS settings, add it in itm/tribename.json in dns`
`The domain name ${req.headers.origin} is not allow to access for CORS settings, add it in itm/tribename.json in dns current origin allow are filter by ${regtxt}`
);
cors({
origin: cor,

View File

@ -649,7 +649,7 @@ Odmdb.cud = (objectPathname, crud, itm, role, runindex = true) => {
if (crud == "U" && accessright.U.length > 0) {
itmtostore = itmold;
const keynotallow = Object.keys(itm).filter(
(el) => !accessright.U.includes(el)
(el) => !(el==getschema.data.schema.apxid || accessright.U.includes(el))
);
if (keynotallow.length > 0) {
feedbackinfo.keynotallow = keynotallow;

View File

@ -87,14 +87,14 @@ router.post(
);
/**
* @api {POST} adminapi/notifications/registeranonymous/:tribe/:mlist/:typekey/:data -Register email||phone to mlist
* @api {POST} adminapi/notifications/registeranonymous -Register email||phone to mlist
* @apiName register
* @apiGroup Notifications
* @apiDescription Register an email or phone into a mailinglist mlist
* @apiBody {string} tribe an existing tribe
* @apiBody {string} mlist a mailing list name
* @apiBody {string} key email or phone keyword
* @apiBod {string} srckey must exist in tribes/schema/lg/enumtrk_xx.json
* @apiBody {string} srckey must exist in tribes/schema/lg/enumtrk_xx.json
* @apiParams {string} data the email or phone value
* @apiSuccess {object} update mailinglist/{mlist}.json successfull
* @apiSuccessExample {json} successfullmessage

View File

@ -4,16 +4,16 @@ add_header 'Access-Control-Allow-Origin' '*' always;
add_header 'Access-Control-Allow-Credentials' 'true' always;
add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, OPTIONS' always;
add_header 'Access-Control-Allow-Headers' '*' always;
# usefull to debug nginx conf 3 next line:
access_log {{{townpath}}}/{{{tribeId}}}/logs/nginx/{{{tribeId}}}_{{{website}}}.access.log main;
error_log {{{townpath}}}/{{{tribeId}}}/logs/nginx/{{{tribeId}}}_{{{website}}}.error.log debug;
add_header xdebug "testmsg debug: $uri - $request - liste args: $args - url:$arg_url - alias:$arg_alias " always;
access_log {{{townpath}}}/{{{tribeId}}}/logs/nginx/{{{website}}}.{{{tribeId}}}.{{{townId}}}.{{{nationId}}}.access.log main;
error_log {{{townpath}}}/{{{tribeId}}}/logs/nginx/{{{website}}}.{{{tribeId}}}.{{{townId}}}.{{{nationId}}}.error.log debug;
# usefull to debug nginx:
#add_header xdebug "testmsg debug: $uri - $request - liste args: $args - url:$arg_url - alias:$arg_alias " always;
set $trackme 0;
if ( $uri ~ ^/trk/ ){
set $trackme 1;
}
access_log {{{townpath}}}/{{{tribeId}}}/logs/nginx/{{{tribeId}}}_{{{website}}}.trk.log tracker if=$trackme ;
access_log {{{townpath}}}/{{{tribeId}}}/logs/nginx/{{{website}}}.{{{tribeId}}}.{{{townId}}}.{{{nationId}}}.trk.log tracker if=$trackme ;
location ~* /trk/ {
if ( $uri ~ ^/trk/redirect ){
return 301 $arg_url;
@ -42,12 +42,12 @@ location /cdn/ {
}
location /api/ {
rewrite /api/(.*$) /$1 break;
proxy_pass http://localhost:3020;
proxy_pass http://localhost:{{{apiport}}};
proxy_redirect off;
include proxy_params;
}
location /socket/ {
proxy_pass http://127.0.0.1:3030;
proxy_pass http://127.0.0.1:{{socketport}};
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
@ -55,7 +55,7 @@ location /socket/ {
proxy_cache_bypass $http_upgrade;
}
location /apidoc/ {
root {{{townpath}}}/{{{tribeId}}}/objects/wwws/apidoc/;
root {{{townpath}}}/{{{tribeId}}}/objects/wwws/apidoc;
index index.html;
}
location /src/ {
@ -64,7 +64,7 @@ location /src/ {
index index.html index_fr.html index_en.html;
}
location / {
root {{{townpath}}}/{{{tribeId}}}/objects/wwws/{{{website}}}/dist/;
root {{{townpath}}}/{{{tribeId}}}/objects/wwws/{{{website}}}/dist;
index index.html index_fr.html index_en.html;
}
error_page 404 /404.html;