<commit_before>/**
 * 
 * Wechaty Io Server Class
 * 
 * IoAuth
 * 
 * https://github.com/zixia/wechaty
 * 
 */

import * as http  from 'http'
import * as log   from 'npmlog'

import { IoAuth }     from './io-auth'
import { IoManager }  from './io-manager'
import { IoSocket }   from './io-socket'

class IoServer {
  ioManager = new IoManager()
  ioAuth = new IoAuth()

  ioSocket: IoSocket

  constructor(private server: http.Server) {
    this.ioSocket = new IoSocket(
      server
      , this.ioAuth.auth.bind(this.ioAuth)
      , this.ioManager.register.bind(this.ioManager)
    )
  }

  init() {
    this.ioSocket.init()
    return Promise.resolve(this)
  }
}

export { IoServer }<commit_msg>use WECHATY_LOG env to enable npmlog<commit_after>/**
 * 
 * Wechaty Io Server Class
 * 
 * IoAuth
 * 
 * https://github.com/zixia/wechaty
 * 
 */

import * as http  from 'http'

import log = require('npmlog')
if (process.env.WECHATY_LOG) {
  log.level = String(process.env.WECHATY_LOG).toLowerCase()
  log.verbose('IoServer', 'Npmlog set log.level =', log.level, 'from env.WECHATY_LOG')
}

import { IoAuth }     from './io-auth'
import { IoManager }  from './io-manager'
import { IoSocket }   from './io-socket'

class IoServer {
  ioManager = new IoManager()
  ioAuth = new IoAuth()

  ioSocket: IoSocket

  constructor(private server: http.Server) {
    this.ioSocket = new IoSocket(
      server
      , this.ioAuth.auth.bind(this.ioAuth)
      , this.ioManager.register.bind(this.ioManager)
    )
  }

  init() {
    this.ioSocket.init()
    return Promise.resolve(this)
  }
}

export { IoServer }
{'fraction_non_alphanumeric': 0.13803872579637727, 'fraction_numerical': 0.0, 'mean_word_length': 2.9073170731707316, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6092330', 'n_tokens_mistral': 580, 'n_tokens_neox': 568, 'n_words': 122}