 class Cio
 
   constructor: (@_options) ->
+
+    # TODO:
+    #   check for error results from all of these.
+    #   set it on _error for the builder function to find and return
 
     @_clientChain = buildChain()
     @_serverChain = buildChain()


    if @_options?.noRelisten then @_serverChain.disable 'cio/relistener'

  client: (options) -> @_run @_clientChain, options
  server: (options) -> @_run @_serverChain, options

  _run: (chain, options) ->
    # # build options for chain.run(), choose the options which exists

module.exports = (options) ->

  # if the certs are provided then try to read them now
  if options?
    result = readCerts options
    if result?.error? then return result

  new Cio options
