Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
.reduce((prev, k) => {
if (!data[k].__secure) {
prev[k] = monk(data[k].url)
return prev
}
let uri = data[k].url.split('mongodb-secure://')[1]
if (uri.indexOf('.') === 0) { // handle relative path
if (filePath) {
const directory = path.dirname(filePath)
uri = path.join(directory, uri)
}
}
const secret = JSON.parse(fs.readFileSync(uri, 'utf8'))
if (Array.isArray(secret)) {
prev[k] = monk(...secret)
} else {
prev[k] = monk(secret)
if (!data[k].__secure) {
prev[k] = monk(data[k].url)
return prev
}
let uri = data[k].url.split('mongodb-secure://')[1]
if (uri.indexOf('.') === 0) { // handle relative path
if (filePath) {
const directory = path.dirname(filePath)
uri = path.join(directory, uri)
}
}
const secret = JSON.parse(fs.readFileSync(uri, 'utf8'))
if (Array.isArray(secret)) {
prev[k] = monk(...secret)
} else {
prev[k] = monk(secret)
}
return prev
}, {})
return dbs
return prev
}
let uri = data[k].url.split('mongodb-secure://')[1]
if (uri.indexOf('.') === 0) { // handle relative path
if (filePath) {
const directory = path.dirname(filePath)
uri = path.join(directory, uri)
}
}
const secret = JSON.parse(fs.readFileSync(uri, 'utf8'))
if (Array.isArray(secret)) {
prev[k] = monk(...secret)
} else {
prev[k] = monk(secret)
}
return prev
}, {})
return dbs
Mongorito.connect = function connect() {
for (var _len = arguments.length, urls = Array(_len), _key = 0; _key < _len; _key++) {
urls[_key] = arguments[_key];
}
// convert mongo:// urls to monk-supported ones
urls = urls.map(function (url) {
return url.replace(/^mongo\:\/\//, "");
});
var db = monk.apply(null, urls);
// if there is already a connection
// don't overwrite it with a new one
if (!this.db) this.db = db;
return db;
};
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,