Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
router.get('/api/:id', function(req, res) {
var db = req.db;
var collection = db.get('lessons');
var objID = monk.id(req.params.id);
collection.findOne({_id: objID})
.then(function(doc) {
res.send(doc);
})
.catch(function(err) {
res.send(err);
});
});
agenda.define(jobName, (job, done) => {
const { topic, comment, reply, url } = job.attrs.data
comments.distinct('replies.author', {
_id: monk.id(comment.id)
}).then((usersToNotify) => {
usersToNotify.push(monk.id(comment.author.id))
return users.find({
$and: [
{
_id: { $in: usersToNotify },
'notifications.replies': true
},
{ _id: { $ne: monk.id(reply.author.id) } }
]
}).each((user, { pause, resume }) => {
pause()
agenda.now(jobNameForSingleUser, {
topicTitle: topic.mediaTitle,
}).then((usersToNotify) => {
usersToNotify.push(monk.id(comment.author.id))
return users.find({
$and: [
{
_id: { $in: usersToNotify },
'notifications.replies': true
},
{ _id: { $ne: monk.id(reply.author.id) } }
]
}).each((user, { pause, resume }) => {
pause()
agenda.now(jobNameForSingleUser, {
topicTitle: topic.mediaTitle,
comment,
reply,