Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const getUserConnectionStatsHandler = function (request, reply) {
const promises = []
promises.push(RestHapi.getAll(User, request.params._id, Connection, 'connections', { isFollowed: true, $count: true }, Log))
promises.push(RestHapi.getAll(User, request.params._id, Connection, 'connections', { isFollowing: true, $count: true }, Log))
promises.push(RestHapi.getAll(User, request.params._id, Connection, 'connections', { isContact: true, $count: true }, Log))
return Q.all(promises)
.then(function (result) {
const connectionStats = {
followers: result[0],
following: result[1],
contacts: result[2]
}
return reply(connectionStats);
})
.catch(function (error) {
Log.error(error);
return reply(RestHapi.errorHelper.formatResponse(error));
});
const getUserConnectionStatsHandler = function (request, reply) {
const promises = []
promises.push(RestHapi.getAll(User, request.params._id, Connection, 'connections', { isFollowed: true, $count: true }, Log))
promises.push(RestHapi.getAll(User, request.params._id, Connection, 'connections', { isFollowing: true, $count: true }, Log))
promises.push(RestHapi.getAll(User, request.params._id, Connection, 'connections', { isContact: true, $count: true }, Log))
return Q.all(promises)
.then(function (result) {
const connectionStats = {
followers: result[0],
following: result[1],
contacts: result[2]
}
return reply(connectionStats);
})
.catch(function (error) {
Log.error(error);
return reply(RestHapi.errorHelper.formatResponse(error));
const getUserConnectionStatsHandler = async function(request, h) {
try {
const promises = []
promises.push(
RestHapi.getAll(
User,
request.params._id,
Connection,
'connections',
{ isFollowed: true, $count: true },
Log
)
)
promises.push(
RestHapi.getAll(
User,
request.params._id,
Connection,
'connections',
{ isFollowing: true, $count: true },
Log