lib/api.js
function Api(spec, options) {
  if (!(this instanceof Api)) {
    return new Api(spec, options);
  }

  if (typeof spec !== 'object') {
    throw new Error('api spec must be an object');
  }

  options = options || {};

  // path alias for both resourcePath and doc path
  if (spec.path) {
    if (!spec.resourcePath) spec.resourcePath = spec.path;
    if (!options.path) options.path = spec.path;
    delete spec.path;
  }

  // allow user to pass description in spec
  if (spec.description) {
    if (!options.description) options.description = spec.description;
    delete spec.description;
  }

  // user resourcePath for doc path if not set
  if (!options.path && spec.resourcePath) {
    options.path = spec.resourcePath;
  }

  debug('create api %s', spec.resourcePath, spec);

  this.env = new Environment();

  this.spec = spec;
  this.list = [];
  this.options = options;

  this.middleware = {};
  this.models = {};
  this.nicknames = {};
  this.resources = {};
}
function Api(spec, options) {
  if (!(this instanceof Api)) {
    return new Api(spec, options);
  }

  if (typeof spec !== 'object') {
    throw new Error('api spec must be an object');
  }

  options = options || {};

  // path alias for both resourcePath and doc path
  if (spec.path) {
    if (!spec.resourcePath) spec.resourcePath = spec.path;
    if (!options.path) options.path = spec.path;
    delete spec.path;
  }

  // allow user to pass description in spec
  if (spec.description) {
    if (!options.description) options.description = spec.description;
    delete spec.description;
  }

  // user resourcePath for doc path if not set
  if (!options.path && spec.resourcePath) {
    options.path = spec.resourcePath;
  }

  debug('create api %s', spec.resourcePath, spec);

  this.env = new Environment();

  this.spec = spec;
  this.list = [];
  this.options = options;

  this.middleware = {};
  this.models = {};
  this.nicknames = {};
  this.resources = {};
}
function Api ( spec , options ) { if ( ! ( this instanceof Api ) ) { return new Api ( spec , options ) ; } if ( typeof spec !== 'object' ) { throw new Error ( 'api spec must be an object' ) ; } options = options || { } ; // path alias for both resourcePath and doc path if ( spec . path ) { if ( ! spec . resourcePath ) spec . resourcePath = spec . path ; if ( ! options . path ) options . path = spec . path ; delete spec . path ; } // allow user to pass description in spec if ( spec . description ) { if ( ! options . description ) options . description = spec . description ; delete spec . description ; } // user resourcePath for doc path if not set if ( ! options . path && spec . resourcePath ) { options . path = spec . resourcePath ; } debug ( 'create api %s' , spec . resourcePath , spec ) ; this . env = new Environment ( ) ; this . spec = spec ; this . list = [ ] ; this . options = options ; this . middleware = { } ; this . models = { } ; this . nicknames = { } ; this . resources = { } ; }
Initialize a new `Api`.

@param {Object} spec
@param {Object} options
@api public
Initialize a new Api .