samples/sample3/handlers/employees.js
function verifyUsernameDoesNotExist(req, res, next) {
  var username = req.body.username;
  var dataStore = req.app.dataStore;

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

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