lib/create-server.js
function defineRoute(method, route, handler) {
    server[method](route, function (req, res) {
      var store = stores.get(req.params.resource);
      delete req.params.resource;
      handler(req, store, function (error, docs) {
        if (error) {
          res.status(500);
          res.end(error);
        } else if (!docs) {
          res.status(404);
          res.end("Not found");
        } else {
          res.json(docs);
        }
      });
    });
  }
function defineRoute(method, route, handler) {
    server[method](route, function (req, res) {
      var store = stores.get(req.params.resource);
      delete req.params.resource;
      handler(req, store, function (error, docs) {
        if (error) {
          res.status(500);
          res.end(error);
        } else if (!docs) {
          res.status(404);
          res.end("Not found");
        } else {
          res.json(docs);
        }
      });
    });
  }
convenience method to define a restify route