- sendcoins

- font
- catalogo
This commit is contained in:
Surya Paolo
2025-03-26 23:23:48 +01:00
parent 76bacf3f5a
commit 789dc1dcae
14 changed files with 118 additions and 27 deletions

View File

@@ -295,7 +295,7 @@ const getTableContent = async (options) => {
// Se c'è un solo record, visualizza una lista di chiavi e valori
const record = records[0];
output += `
<table border='1' style="border-collapse: collapse; width: 50%;" >
<table border='1' style="border-collapse: collapse;" >
<thead>
<tr>
<th style="padding: 8px; background-color: #f2f2f2;">Campo</th>
@@ -419,8 +419,11 @@ exports.viewTable = async (req, res) => {
if (options.outhtml) {
out = `
<h2>Tabella: ${options.nameTable}</h2>
${tableContent}
<h2 class="text-center">Tabella: ${options.nameTable}</h2>
<div class="text-h7 row justify-center text-blue">Query: ${options.where}<br></div>
<div class="row justify-center">
${tableContent}
</div>
`
} else {
out = tableContent;
@@ -445,6 +448,7 @@ exports.queryTable = async (req, res) => {
if (options.outhtml) {
out = `
<h2>Tabella: ${options.nameTable}</h2>
<div class="text-h7 row justify-center text-blue">Query: ${options.where}<br></div>
${tableContent}
`
} else {

View File

@@ -764,6 +764,10 @@ router.post('/import', authenticate, async (req, res) => {
}
}
if (!myarr && ripopola) {
return res.status(400).send(data.arrdata);
}
// Rileggi tutti i record di ImportaDescr
dataObjects = await ImportaDescr.find({ idapp }).lean();
@@ -819,6 +823,11 @@ router.post('/import', authenticate, async (req, res) => {
let recisbn = {};
const trovato = await ImportaIsbn.findOne({ isbn: product.code }).lean();
if (trovato) {
recisbn = trovato;
}
if (pagine && pagine !== '0') {
recisbn.Pagine = pagine;
}
@@ -827,6 +836,7 @@ router.post('/import', authenticate, async (req, res) => {
recisbn.descrizione_breve_macro = productInfo.descrizione_breve_macro;
recisbn.descrizione_completa_macro = productInfo.descrizione_completa_macro;
recisbn.sottotitolo = productInfo.sottotitolo;
// recisbn.idapp = idapp;
let risisbn = await ImportaIsbn.findOneAndUpdate({ isbn: product.code }, { $set: recisbn }, { new: true, upsert: true, strict: false });
@@ -859,7 +869,6 @@ router.post('/import', authenticate, async (req, res) => {
dataObjects = null;
}
if (dataObjects && dataObjects[0]) {
// Cancella la collection ImportaIsbn
await ImportaIsbn.deleteMany({ idapp });
@@ -883,6 +892,8 @@ router.post('/import', authenticate, async (req, res) => {
let queryprod = { idapp, sku: recmacro.sku };
// 13872
try {
let risrec = await ImportaIsbn.findOneAndUpdate(queryprod, { $set: recmacro }, { new: true, upsert: true, strict: false });
if (risrec) {
@@ -1112,6 +1123,8 @@ router.post('/import', authenticate, async (req, res) => {
let numprod = dataObjects.length;
let nontrovati = 0;
for (const product of dataObjects) {
let isnuovo = false
let setta = false
@@ -1127,6 +1140,19 @@ router.post('/import', authenticate, async (req, res) => {
// split versioneGM in array with separated ","
let arrversGM = versGM.split(",").map(x => x.trim());
// se non esiste l'ISBN, allora me lo cerco in base a sku !
if (!product.isbn) {
const rectrovare = await ImportaIsbn.findOne({ sku: product.sku }).lean();
if (rectrovare) {
product.isbn = rectrovare.isbn;
} else {
nontrovati++;
console.log(`${nontrovati} - ISBN non trovato [sku=${product.sku} title=${product.title}]`)
}
}
let productInfo = {
idapp: product.idapp,
code: product.isbn,

View File

@@ -2031,8 +2031,8 @@ async function load(req, res, version = '0') {
const { data, totalTime, slowCalls } = await measurePromises(promises);
// console.log('Risultati delle promise:', data);
console.log('Tempo totale di esecuzione:', totalTime, 'secondi');
console.log('Le 5 chiamate più lente:', slowCalls);
// console.log('Tempo totale di esecuzione:', totalTime, 'secondi');
// console.log('Le 5 chiamate più lente:', slowCalls);
// Aggiornamento delle informazioni dell'utente, se presente
let myuser = req.user;

View File

@@ -682,6 +682,8 @@ router.post('/newtok', async (req, res) => {
try {
const refreshToken = req.body.refreshToken;
// return res.status(403).send({ error: 'Refresh token non valido' });
if (!refreshToken) {
return res.status(400).send({ error: 'Refresh token mancante' });
}
@@ -689,7 +691,7 @@ router.post('/newtok', async (req, res) => {
const recFound = await User.findOne({ 'tokens.refreshToken': refreshToken });
if (!recFound) {
return res.status(404).send({ error: 'Refresh token non valido' });
return res.status(403).send({ error: 'Refresh token non valido' });
}
const { token, refreshToken: newRefreshToken } = await recFound.generateAuthToken(req);

View File

@@ -763,10 +763,13 @@ connectToDatabase(connectionUrl, options)
const isProduction = ['production', 'test'].includes(process.env.NODE_ENV);
let domains = [];
let domains_allowed = [];
try {
if (process.env.DOMAINS)
domains = JSON.parse(process.env.DOMAINS);
if (process.env.DOMAINS_ALLOWED)
domains_allowed = JSON.parse(process.env.DOMAINS_ALLOWED);
} catch (error) {
console.error("Errore durante la conversione della stringa DOMAINS:", error);
}
@@ -805,17 +808,23 @@ connectToDatabase(connectionUrl, options)
`https://api.${domain.hostname}`,
`https://test.${domain.hostname}`,
`https://testapi.${domain.hostname}`,
`https://comunitanuovomondo.app`,
`https://kolibrilab.it`,
`https://artenergetica.org`,
`https://freeplanet.app:3001`,
`http://${domain.hostname}`,
`http://api.${domain.hostname}`,
`http://test.${domain.hostname}`,
`http://testapi.${domain.hostname}`
]);
// Aggiungi i domini da DOMAINS_ALLOWED
allowedOrigins = allowedOrigins.concat(
domains_allowed.map(domain => [
`https://${domain}`,
`http://${domain}`
]).flat()
);
}
console.log('allowedOrigins', allowedOrigins)
let myorigin = '*';
@@ -823,6 +832,10 @@ connectToDatabase(connectionUrl, options)
myorigin = (origin, callback) => {
try {
// Validazione dell'input
if (origin === undefined) {
console.log('✅ Origin UNDEFINED... vado avanti lo stesso !');
return callback(null, true);
}
if (!origin || typeof origin !== 'string' || !/^https?:\/\/[^\s/$.?#].[^\s]*$/.test(origin)) {
console.error('❌ Origine non valida:', origin);
return callback(new Error('Origine non valida'), false);
@@ -830,7 +843,7 @@ connectToDatabase(connectionUrl, options)
// Controllo delle origini consentite
if (allowedOrigins.includes(origin)) {
console.log('✅ Origine consentita:', origin);
// console.log('✅ Origine consentita:', origin);
return callback(null, true);
}
@@ -939,10 +952,10 @@ connectToDatabase(connectionUrl, options)
const keyStream = path.resolve(`./${process.env.PATH_CERT_KEY}`);
const certificateStream = path.resolve(`./${process.env.PATH_SERVER_CRT}`);
const privateKey = fs.readFileSync(keyStream, "utf8");
const certificate = fs.readFileSync(certificateStream, "utf8");
mycredentials = {
key: privateKey,
cert: certificate,

View File

@@ -5831,7 +5831,7 @@ module.exports = {
}
if (mov.groupfrom) {
userfrom += mov.groupfrom.groupname
tipocontofrom = shared_consts.AccountType.COLLECTIVE_ACCOUNT
tipocontofrom = shared_consts.AccountType.CONTO_DI_GRUPPO
}
if (mov.userfrom) {
userfrom += mov.userfrom.username
@@ -5844,7 +5844,7 @@ module.exports = {
}
if (mov.groupto) {
userto += mov.groupto.groupname
tipocontoto = shared_consts.AccountType.COLLECTIVE_ACCOUNT
tipocontoto = shared_consts.AccountType.CONTO_DI_GRUPPO
}
if (mov.userto) {
userto += mov.userto.username

View File

@@ -824,7 +824,7 @@ module.exports = {
sector: 1,
recCatGrp: 1,
mycircuits: 1,
lastdate_reqRisGroup: 1,
lastdate_reqRisGroup: 1,
}
} else if (table === this.TABLES_CIRCUITS) {
proj = {
@@ -1165,7 +1165,7 @@ module.exports = {
AUDIOLIBRO: 22,
VIDEO: 23,
CARTE: 25,
// -----------
// -----------
NUOVO: 101,
USATO: 102,
DOWNLOAD: 103,
@@ -1180,7 +1180,7 @@ module.exports = {
AccountType: {
USER: 0,
COLLECTIVE_ACCOUNT: 1,
CONTO_DI_GRUPPO: 1,
COMMUNITY_ACCOUNT: 2,
},
@@ -1189,7 +1189,7 @@ module.exports = {
SET: 1,
},
SENDRIS_CODES: {
SENDRIS_CODES: {
EXCEED_FIDO: 10,
EXCEED_QTAMAX: 20,
},

View File

@@ -1 +1 @@
1.2.29
1.2.32