Cloud Defense Logo

Products

Solutions

Company

Book A Live Demo

Top 10 Examples of "mongojs in functional component" in JavaScript

Dive into secure and efficient coding practices with our curated list of the top 10 examples showcasing 'mongojs' in functional components in JavaScript. Our advanced machine learning engine meticulously scans each line of code, cross-referencing millions of open source libraries to ensure your implementation is not just functional, but also robust and secure. Elevate your React applications to new heights by mastering the art of handling side effects, API calls, and asynchronous operations with confidence and precision.

if(global.config.authentication === "local") {
		if(req.user && req.user.local && req.user.local.email && req.user.local.email) {
			var id = req.params.project;
			//  we are authenticating for project operation (add/remove node)
			if(id) {
				mongoquery.findOneById(id, "mp_projects", function(project) {
					if(project.owner.includes(req.user.local.email))
						cb(true);
					else
						cb(false);
				});
			// we are authenticating for node run (separate since there is no project id on node run URL)
			} else {
				var nodeid = mongojs.ObjectId(req.params.id);
				mongoquery.findOne({nodes:{$elemMatch:{_id:nodeid}}}, "mp_projects", function(err, project) {
					if(!err) {
						if(project && project.owner.includes(req.user.local.email) )
							cb(true);
						else
							cb(false);
					} else {
						cb(false);
					}
				})
			}
		} else {
			cb(false); // we do not have user
		}
	} else if (global.config.authentication === "shibboleth") {
		console.log(req.headers[global.config.shibbolethHeaderId])
// first check if route should be open
	var pass = false;
	global.config.IP_passes.some(function(IP_pass) {
		if(req.path.includes(IP_pass.path) && req.method === IP_pass.method && (req.ip === IP_pass.ip || IP_pass.ip === "*")) {
			pass = true;
			console.log("INFO: " + req.method + " allowed by IP_pass: " + IP_pass.label)
		}
	})
	if(pass)
		return next();

	var user = getUser(req)
	var node_uuid = req.params.id;
	
	try {
		node_uuid = mongojs.ObjectId(req.params.id);
	} catch(e) {
		res.status(404).json({error:"Node not found!"});
	}

	mongoquery.findOne({nodes:{$elemMatch:{_id:node_uuid}}}, "mp_projects", function(err, project) {
		if(!err) {
			if(project && user && project.owner.includes(user) )
				next()
			else
				res.status(401).json({error:"Node run not authenticated!"});
		} else {
			res.status(401).json({error:"Node run not authenticated!"});
		}
	})
}
function prepareMessage(message) {
    message.user = mongojs.ObjectId(''+ app_tests.testuser._id);
    message.folder = message.folder || '\\Inbox';
    message.flags = message.flags || [];

    message.uid = message.uid || app_tests.uidnext;
    app_tests.uidnext = message.uid + 1;

    message.internaldate = message.internaldate || new Date();
    return message;
}
app.delete('/contactlist/:id', function (req, res) {
  var id = req.params.id;
  console.log(id);
  db.contactlist.remove({_id: mongojs.ObjectId(id)}, function (err, doc) {
    res.json(doc);
  });
});
export const find = (id, callback) => {
  const query = ObjectId.isValid(id) ? { _id: ObjectId(id) } : { slugs: id }
  db.articles.findOne(query, callback)
}
static findById(id, cb) {
		mongoquery.findOne({"_id":mongojs.ObjectId(id)}, "mp_users", function (err, result) {
			if (err) {
				cb(err)
			} else if(result) {
				var user = new User(result.local.email);
				user.id = result._id; 
				cb(null, user);
			} else {
				cb(null, null);
			}
		}); 
	}
exports.access = function (uid, oid, callback) {
  var criteria = {'uid': uid};
  if (typeof oid === 'function') {
    callback = oid;
  } else if (oid) {
    criteria['_id'] = require('mongojs').ObjectId(oid);
  }
  callback = (typeof callback === 'function') ? callback : function () {};
  exports.update(criteria, {
    '$set': {
      'auth.seen': new Date(),
      'auth.status': 'online'
    }
  }, function (user) {
    if (user) {
      callback(user);
    } else {
      exports.guest(callback);
    }
  });
};
http.get('/game/:room_id', authorize, function (req, res, next) {
  var query = {_id: require('mongojs').ObjectId(req.param('room_id'))}
    , js = ['vendor/uuid', 'tile', 'client', 'mouse', 'confirm'];

  db.rooms.findOne(query, function (error, room) {
    if (error) return next(error);

    var options = { room: room
                  , user: req.user
                  , css: asereje.css()
                  , js: asereje.js(js)
                  };

    if (room) {
      res.render('room', options);
    } else {
      res.render('inexistant_room', options);
    }
var dbUrl = "library";
var collections = ["books"];

var db = require("mongojs").connect(dbUrl, collections);
module.exports = db;
var setDb = function (options) {
	var url = options.url ? options.url : config.connection,
		list = options.collections ? options.collections : collections;

	return mongo.connect(url, list);
};

Is your System Free of Underlying Vulnerabilities?
Find Out Now