Initialize the Stormpath client.

@method
@private

@param {Object} app - The express application.
@param {object} opts - A JSON hash of user supplied options.

@return {Function} A function which accepts a callback.
763786
function initClient(app, opts) {
  opts.userAgent = userAgent;

  var logger = opts.logger;

  if (!logger) {
    logger = new winston.Logger({
      transports: [
        new winston.transports.Console({
          colorize: true,
          level: opts.debug || 'error'
        })
      ]
    });
  }

  app.set('stormpathLogger', logger);

  var client = require('./client')(opts);

  client.on('error', function (err) {
    logger.error(err);
    app.emit('stormpath.error', err);
  });

  client.on('ready', function () {
    app.set('stormpathClient', client);
    app.set('stormpathConfig', client.config);
  });

  return client;
}
1324167
def init_app(self, app):
        
        # Save this so we can use it later in the extension
        if not hasattr(app, 'extensions'):   # pragma: no cover
            app.extensions = {}
        app.extensions['flask-jwt-extended'] = self

        # Set all the default configurations for this extension
        self._set_default_configuration_options(app)
        self._set_error_handler_callbacks(app)
438550
def init_app(self, app):
        

        self.app = app

        self.dynamic_url = self.app.config.get('APIDOC_DYNAMIC_URL', self.dynamic_url)
        self.allow_absolute_url = self.app.config.get('APIDOC_ALLOW_ABSOLUTE_URL', self.allow_absolute_url)

        url = self.url_path

        if not self.url_path.endswith('/'):
            url += '/'

        app.add_url_rule(url, 'docs', self.__send_static_file, strict_slashes=True)
        app.add_url_rule(url + '<path:path>', 'docs', self.__send_static_file, strict_slashes=True)
804203
function(opts) {
  if(!opts) opts = {};
  var libpath = opts['path'];
  var key = opts['key'];

  this._library = this._createLibrary(libpath);
  this._initKey(key);
  this._initHandle(this._key);
}
28327
function (app) {
    this.options = this.options || {}
    this.options.babel = this.options.babel || {}
    this.options.babel.optional = this.options.babel.optional || []

    if (this.options.babel.optional.indexOf('es7.decorators') === -1) {
      this.options.babel.optional.push('es7.decorators')
    }

    /* eslint-disable no-unused-expressions */
    this._super.init && this._super.init.apply(this, arguments)
    /* eslint-enable no-unused-expressions */
  }
150605
function bindRoutes (app, opts) {

    // Main test page
    app.get('/', function (req, res) {
        renderTmpl(__dirname + '/../view/index.html', opts, function (err, content) {
            res.send(content);
        });
    });

}
804872
function Client(app) {
  if (!(this instanceof Client)) return new Client(app);
  this._base = '';
  this._url = '';
  this.serialize = serializers.raw;
  this.parse = parsers.raw;
  this.middlewares = [];
  this.expectations = [];
  this.options = {
    followRedirect: false,
    method: 'GET',
    headers: {}
  };

  if (app) this.app(app);
}
206315
function start(app) {
    /**
     * Create HTTP server.
     */

    const config = require('./config')();
    port = normalizePort(config.get('port'));
    server = http.createServer(app);

    /**
     * Listen on provided port, on all network interfaces.
     */

    app.set('port', port);
    server.listen(port);
    server.on('error', onError);
    server.on('listening', onListening);

    return server;
}
169654
function Client (opts) {
  var self = this

  typeforce({
    url: 'String',
    otrKey: 'DSA',
    // byRootHash: 'Function',
    instanceTag: '?String',
    autoconnect: '?Boolean' // defaults to true
  }, opts)

  EventEmitter.call(this)
  this.setMaxListeners(0)

  this._url = parseURL(opts.url)
  this._autoconnect = opts.autoconnect !== false
  this._onmessage = this._onmessage.bind(this)
  this._sessions = {}
  this._otrKey = opts.otrKey
  this._fingerprint = opts.otrKey.fingerprint()
  this._connected = false
  this._instanceTag = opts.instanceTag
  this._backoff = backoff.exponential({ initialDelay: 100 })
  if (this._autoconnect) this.connect()
}
122181
function initApp (config) {
    // init each module in the order loaded
    _.each(config.moduleNames, moduleName => {
        var module = config.modules[moduleName]
        // load modules and controllers for module, setup routes
        initModule(config, module)
        // merge module routes to global routes
        _.merge(config.routes, module.routes)
    })
    // initialize merged routes from all modules
    var router = initRoutes(config, config.routes)
    // bind router to app base
    config.express.use('/', router)
}
1145753
def app_create(self, data, **kwargs):
        ""
        api_path = "/api/v2/apps.json"
        return self.call(api_path, method="POST", data=data, **kwargs)
445071
function resolveApps (opts) {
    const handler = strategies[opts.strategy];
    if (!handler) {
      throw Error('invalid suggestion strategy');
    }
    return handler(opts);
  }
151627
function Dispatcher (opts) {
    // provide some default value
    this.opts=
        { debug      : opts.debug    || 3              // default no debug
        , dumpfile   : opts.dumpfile || null           // filename for log file or NMEA generated commands
        , hostname   : opts.hostname || 'localhost'    // default localhost for client connect host
        , srvmod     : opts.srvmod   || false          // default is client mode
        , port       : opts.port     || 1234           // no default for port
        , cltmod     : opts.cltmod   || true           // default mode is client connect
        , timeout    : opts.timeout*1000  || 180000    // reconnect timeout default 180s
    };

    // verbose flag is global
    if (opts.verbose) Verbose = true;

    // if needed check dumpfile can be create
    if (this.opts.dumpfile !== null) {
        try { // dump fd is global
            DumpFD= fs.openSync (this.opts.dumpfile, "w+");
        } catch (err) {
            console.log ("hoops file to open [%s] err=[%s]",this.opts.dumpfile, err);
        }
    }

    // if needed start a Tcp server
    if (this.opts.srvmod) {
        this.opts.cltmod=false;    // when server cannot be a client
        this.TcpServer (); // start a server waiting on --port/localhost
    }

    // in client mode we connect onto a remote server
    if (this.opts.cltmod) {
        this.TcpClient();  // when connected will enter ClientListener() event handler
    }

    // validate Queue where position will be posted
     QJhandle  = async.queue  (QJpost, 1);
}
684148
function App() {
    require('colors');

    /**
     * All of the developer defined middlewares.
     *
     * @var {Array}
     * @protected
     */
    this.__middlewares = [];

    /**
     * The filter instance
     * @var {Object}
     */
    this.filter;

    /**
     * The list of loaded service providers.
     *
     * @var {Object}
     * @protected
     */
    this.__loadedProviders = {};

    /**
     * Indicates if the application has "booted".
     *
     * @var {Boolean}
     * @protected
     */
    this.__booted = false;

    /**
     * The array of booting callbacks.
     *
     * @var {Array}
     * @protected
     */
    this.__bootingCallbacks = [];

    /**
     * The array of booted callbacks.
     *
     * @var {Array}
     * @protected
     */
    this.__bootedCallbacks = [];

    /**
     * Node HTTP server reference.
     *
     * @var {Object}
     * @protected
     */
    this.__server;

    /**
     * The application locals object.
     *
     * @var {Object}
     */
    this.locals = {};

    /**
     * Aliases for internal Positron module
     *
     * @type {Object}
     * @protected
     */
    this.__aliases = {};

    var self = this;

    /**
     * Run the application and send the response.
     *
     * @param  request
     * @param  response
     * @return {void}
     */
    this.run = function (request, response) {
        var reqDomain = domain.create();

        reqDomain
            .on('error', self.handleError.bind(self, request, response))
            .run(function () {
                self.__getStackedClient().handle(request, response);
            });
    };

}
164680
function SettingsFile(app, options) {
  if (!app) {
    throw new TypeError('SettingsFile must accept an app name');
  }
  else if (typeof app !== 'string') {
    throw new TypeError('SettingsFile app name must be a string');
  }

  debug('initialize new settings file for app: %s', app);
  this._app = app;
  this._path = nachosHome('data', app + '.json');
  debug('resolved path is %s', this._path);
  this._options = defaults(options, {
    globalDefaults: {},
    instanceDefaults: {}
  });
}
740682
function (opts) {
  if (!(this instanceof Worker)) {
    return new Worker(opts);
  }

  this.opts = opts;
  this.port = this.opts.port || 8888;
  this.apps = opts.apps;

  if (typeof (this.apps) !== 'object') {
    this.apps = JSON.parse(this.apps);
  }

  this.server = http.createServer(this._handleHttp.bind(this));
  return this;
}
1185247
function init(client, opts) {
	client.servers = {};
	client.channels = {};
	client.users = {};
	client.directMessages = {};
	client.internals = {
		oauth: {},
		version: CURRENT_VERSION,
		settings: {}
	};
	client._connecting = true;

	setupPing(client.internals);
	return getToken(client, opts);
}