<commit_before>express = require 'express'
morgan = require 'morgan'
bodyParser = require 'body-parser'
errorHandler = require 'errorhandler'
cookieParser = require 'cookie-parser'
session = require 'express-session'
passport = require 'passport'
Router = require './app/routes'
Config = require './app/config'
meshblu = require 'meshblu'
debug = require('debug')('meshblu-google-authenticator:server')

port = process.env.MESHBLU_GOOGLE_AUTHENTICATOR_PORT ? 8008

app = express()
app.use morgan('dev')
app.use errorHandler()
app.use bodyParser.json()
app.use bodyParser.urlencoded(extended: true)
app.use cookieParser()

app.use session
  secret: 'super awesome cool secret'
  resave: false
  saveUninitialized: true

app.use passport.initialize()
app.use passport.session()

passport.serializeUser (user, done) =>
  done null, user.id

passport.deserializeUser (user, done) =>
  done null, user

app.engine 'html', require('ejs').renderFile

app.set 'view engine', 'html'

app.set 'views', __dirname + '/app/views'

try
  meshbluJSON  = require './meshblu.json'
catch
  meshbluJSON =
    uuid:   process.env.MESHBLU_GOOGLE_AUTHENTICATOR_UUID
    token:  process.env.MESHBLU_GOOGLE_AUTHENTICATOR_TOKEN
    name:   process.env.MESHBLU_GOOGLE_AUTHENTICATOR_NAME
    server: process.env.MESHBLU_HOST
    port:   process.env.MESHBLU_PORT


meshbluConn = meshblu.createConnection meshbluJSON

meshbluConn.on 'ready', =>
  debug 'Connected to meshblu'
  app.listen port, =>
    debug "Meshblu Google Authenticator..."
    debug "Listening at localhost:#{port}"

    config = new Config meshbluConn, meshbluJSON
    config.register()

    router = new Router app
    router.register()

meshbluConn.on 'notReady', =>
  debug 'Unable to connect to meshblu'

<commit_msg>Set private key from meshblu device<commit_after>express = require 'express'
morgan = require 'morgan'
bodyParser = require 'body-parser'
errorHandler = require 'errorhandler'
cookieParser = require 'cookie-parser'
session = require 'express-session'
passport = require 'passport'
Router = require './app/routes'
Config = require './app/config'
meshblu = require 'meshblu'
debug = require('debug')('meshblu-google-authenticator:server')

port = process.env.MESHBLU_GOOGLE_AUTHENTICATOR_PORT ? 8008

app = express()
app.use morgan('dev')
app.use errorHandler()
app.use bodyParser.json()
app.use bodyParser.urlencoded(extended: true)
app.use cookieParser()

app.use session
  secret: 'super awesome cool secret'
  resave: false
  saveUninitialized: true

app.use passport.initialize()
app.use passport.session()

passport.serializeUser (user, done) =>
  done null, user.id

passport.deserializeUser (user, done) =>
  done null, user

app.engine 'html', require('ejs').renderFile

app.set 'view engine', 'html'

app.set 'views', __dirname + '/app/views'

try
  meshbluJSON  = require './meshblu.json'
catch
  meshbluJSON =
    uuid:   process.env.MESHBLU_GOOGLE_AUTHENTICATOR_UUID
    token:  process.env.MESHBLU_GOOGLE_AUTHENTICATOR_TOKEN
    name:   process.env.MESHBLU_GOOGLE_AUTHENTICATOR_NAME
    server: process.env.MESHBLU_HOST
    port:   process.env.MESHBLU_PORT


meshbluConn = meshblu.createConnection meshbluJSON

meshbluConn.on 'ready', =>
  debug 'Connected to meshblu'

  meshbluConn.whoami {}, (device) ->
    conn.setPrivateKey(device.privateKey) unless conn.privateKey

  app.listen port, =>
    debug "Meshblu Google Authenticator..."
    debug "Listening at localhost:#{port}"

    config = new Config meshbluConn, meshbluJSON
    config.register()

    router = new Router app
    router.register()

meshbluConn.on 'notReady', =>
  debug 'Unable to connect to meshblu'


{'fraction_non_alphanumeric': 0.11205479452054795, 'fraction_numerical': 0.002191780821917808, 'mean_word_length': 4.651702786377709, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 14, 'https://': 0, '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': '7078238', 'n_tokens_mistral': 1240, 'n_tokens_neox': 1216, 'n_words': 290}