samples/sample3/handlers/projects.js
function verifyProjectIdDoesNotExist(req, res, next) {
  var projectId = req.body.id;
  var dataStore = req.app.dataStore;

  // Check for an existing project REST resource - /projects/{projectId}
  var resource = new swagger.Resource('/projects', projectId, null);
  dataStore.get(resource, function(err, resource) {
    if (resource) {
      // The ID already exists, so send an HTTP 409 (Conflict)
      res.sendStatus(409);
    }
    else {
      next();
    }
  });
}
function verifyProjectIdDoesNotExist(req, res, next) {
  var projectId = req.body.id;
  var dataStore = req.app.dataStore;

  // Check for an existing project REST resource - /projects/{projectId}
  var resource = new swagger.Resource('/projects', projectId, null);
  dataStore.get(resource, function(err, resource) {
    if (resource) {
      // The ID already exists, so send an HTTP 409 (Conflict)
      res.sendStatus(409);
    }
    else {
      next();
    }
  });
}
function verifyProjectIdDoesNotExist ( req , res , next ) { var projectId = req . body . id ; var dataStore = req . app . dataStore ; // Check for an existing project REST resource - /projects/{projectId} var resource = new swagger . Resource ( '/projects' , projectId , null ) ; dataStore . get ( resource , function ( err , resource ) { if ( resource ) { // The ID already exists, so send an HTTP 409 (Conflict) res . sendStatus ( 409 ) ; } else { next ( ) ; } } ) ; }
Verifies that the new project's ID isn't the same as any existing ID.
Verifies that the new project s ID isn t the same as any existing ID .