updates to teamsnapCallback
This commit is contained in:
@@ -61,40 +61,25 @@ exports.initTeamsnap = (req, res, next) => {
|
||||
});
|
||||
};
|
||||
|
||||
exports.teamsnapLog = (method, types, id, req, message="") => {
|
||||
console.log(
|
||||
exports.teamsnapCallback = (err,result, d) => {
|
||||
if (Array.isArray(result)){
|
||||
types = new Set(result.map(i=>i.type))
|
||||
}
|
||||
else {
|
||||
types = [result?.type]
|
||||
}
|
||||
|
||||
if (d) {
|
||||
console.log(
|
||||
'\x1b[33mTeamSnap:\x1b[0m',
|
||||
`${method} for \x1b[33m\[${types}\]\x1b[0m on ${id}`,
|
||||
`on url ${req.url}`,
|
||||
`"${message}"`
|
||||
`${d.source} using ${d.method ? "teamsnap."+d.method : "?"} \x1b[33m\[${Array.from(types).join(", ")}\]\x1b[0m`
|
||||
)
|
||||
return;
|
||||
}
|
||||
|
||||
exports.tsPromise = (func_name, params) => {
|
||||
return new Promise(function(resolve, reject) {
|
||||
teamsnap.bulkLoad(
|
||||
params,
|
||||
(err, data) => {
|
||||
console.log();
|
||||
if (err !== null) {
|
||||
reject(err);
|
||||
}
|
||||
else {
|
||||
resolve(data);
|
||||
}
|
||||
}
|
||||
)
|
||||
;
|
||||
});
|
||||
}
|
||||
|
||||
exports.teamsnapCallback = (err,items) => {
|
||||
if (err) {
|
||||
}
|
||||
if (err) {
|
||||
console.log(err.message);
|
||||
throw new Error(err)
|
||||
}
|
||||
return items;
|
||||
return result;
|
||||
}
|
||||
|
||||
exports.teamsnapFailure = (err, next) => {
|
||||
|
||||
Reference in New Issue
Block a user