Ver 0.2.8

Added msg Server error in every pages
Nuovo Gruppo non funziona.
Corretto altre funzioni del Gruppo
Errore del server" Network Error", fare pagina test con altri host per vedere se da lo stesso msg, con IP
This commit is contained in:
paoloar77
2022-02-22 15:24:32 +01:00
parent ee950c02e9
commit 1214bcfbfc
5 changed files with 47 additions and 12 deletions

View File

@@ -50,7 +50,7 @@ const authenticate = (req, res, next) => {
// tools.mylog('userid', user._id);
}).catch((e) => {
tools.mylog("ERR =", e);
tools.mylog("ERR authenticate invalid Token =", e);
res.status(server_constants.RIS_CODE_HTTP_INVALID_TOKEN).send();
});
};

View File

@@ -5,6 +5,7 @@ const tools = require('../tools/general');
const shared_consts = require('../tools/shared_nodejs');
mongoose.Promise = global.Promise;
mongoose.level = 'F';
@@ -14,6 +15,9 @@ mongoose.plugin(schema => {
});
const MyGroupSchema = new Schema({
_id: {
type: Number,
},
idapp: {
type: String,
},
@@ -105,6 +109,8 @@ MyGroupSchema.statics.getFieldsForSearch = function() {
MyGroupSchema.statics.executeQueryTable = function(idapp, params) {
params.fieldsearch = this.getFieldsForSearch();
const { User } = require('./user');
if (params.options) {
if (tools.isBitActive(params.options, shared_consts.OPTIONS_SEARCH_USER_ONLY_FULL_WORDS)) {
params.fieldsearch = User.getFieldsForSearchUserFriend();
@@ -116,6 +122,27 @@ MyGroupSchema.statics.executeQueryTable = function(idapp, params) {
return tools.executeQueryTable(this, idapp, params);
};
MyGroupSchema.pre('save', async function(next) {
if (this.isNew) {
const myrec = await MyGroup.findOne().limit(1).sort({_id: -1});
if (!!myrec) {
if (myrec._doc._id === 0)
this._id = 1;
else
this._id = myrec._doc._id + 1;
} else {
this._id = 1;
}
this.date_created = new Date();
}
next();
});
MyGroupSchema.statics.findAllIdApp = async function(idapp) {
const myfind = {idapp};

View File

@@ -2,6 +2,5 @@ module.exports = {
list: [
{_id: 1, descr: 'Offro'},
{_id: 2, descr: 'Cerco'},
{_id: 3, descr: 'Evento'},
],
};

View File

@@ -144,7 +144,7 @@ router.post(process.env.LINKVERIF_REG, (req, res) => {
}
}
}).catch((e) => {
console.log(e.message);
console.log(process.env.LINKVERIF_REG, e.message);
res.status(400).send();
});
@@ -177,7 +177,7 @@ router.post(process.env.LINK_REQUEST_NEWPASSWORD, (req, res) => {
});
}
}).catch((e) => {
console.log(e.message);
console.log(process.env.LINK_REQUEST_NEWPASSWORD, e.message);
res.status(400).send();
res.send({code: server_constants.RIS_CODE_ERR, msg: e});
});
@@ -218,7 +218,7 @@ router.post(process.env.LINK_UPDATE_PWD, (req, res) => {
});
}
}).catch((e) => {
console.log(e.message);
console.log(process.env.LINK_UPDATE_PWD, e.message);
res.status(400).send();
});
@@ -232,6 +232,7 @@ router.post('/testServer', (req, res) => {
return res.send(ris);
} catch (e) {
console.error('testServer', e.message);
return res.status(400).send(e);
}
@@ -339,6 +340,7 @@ router.post('/settable', authenticate, (req, res) => {
// tools.mylog('rec', rec);
}).catch((e) => {
console.error('settable', e.message);
if (e.code === 11000) {
const id = mytablerec._id;
delete mytablerec._doc['_id'];
@@ -360,6 +362,7 @@ router.post('/settable', authenticate, (req, res) => {
});
} catch (e) {
console.error('settable', e.message);
return res.status(400).send(e);
}
@@ -423,13 +426,19 @@ router.post('/gettable', authenticate, (req, res) => {
return res.status(400).send({});
}
try {
return mytable.executeQueryTable(req.user.idapp, params).then(ris => {
return res.send(ris);
}).catch((e) => {
console.log('gettable: ' + e.message);
console.error('gettable: ' + e.message);
res.status(400).send(e);
});
}catch (e) {
console.error(`ERROR gettable ${params.table}: `, e.message, 'params', params);
res.status(500).send(e);
}
});

View File

@@ -113,7 +113,7 @@ module.exports = {
'mybachecas',
'mygoods',
'mygroups'],
TABLES_USER_ID: ['myskills', 'mybachecas', 'mygoods'],
TABLES_USER_ID: ['mygroups', 'myskills', 'mybachecas', 'mygoods'],
TABLES_UPDATE_LASTMODIFIED: ['myskills', 'mybachecas', 'mygoods', 'mybots'],
TABLES_FINDER: ['myskills', 'mybachecas', 'mygoods', 'mygroups'],
TABLES_VISU_CMYSRECCARD: ['myskills', 'mybachecas', 'mygoods'],