text: const express = require("express");
  const router = express.router();
  const mongoClient = require("mongodb").MongoClient;
  const objectID = require("mongodb").objectID;
  
  //now we have to connect to db
  // Connect
  const connection = (closure) => {
      return MongoClient.connect('mongodb://localhost:27017/mean', (err, db) => {
          if (err) return console.log(err);
  
          closure(db);
      });
  };
  
  // Error handling
  const sendError = (err, res) => {
      response.status = 501;
      response.message = typeof err == 'object' ? err.message : err;
      res.status(501).json(response);
  };
  
  // Get users
  router.get('/users', (req, res) => {
      connection((db) => {
          db.collection('users')
              .find()
              .toArray()
              .then((users) => {
                  response.data = users;
                  res.json(response);
              })
              .catch((err) => {
                  sendError(err, res);
              });
      });
  });
  module.exports = router;