<commit_before>require 'logger'
require 'kato/local/node'

class ApplicationController < Sinatra::Base
  helpers ApplicationHelper, CurrentUserHelper, ErrorHandlingHelper

  set :raise_errors, true
  set :show_exceptions, false

  # IP Spoofing protection isn't that helpful and
  # causes a lot of warnings in the log
  set :protection, :except => :ip_spoofing

  set :logging, Logger::DEBUG

  # The session is only used for the duration of the login process
  # the expiration is set to 2 hours to allow for clock skew
  # between clients and the server.
  use Rack::Session::ActiveRecord, {
    :sidbits => 1024,
    :expire_after => 2 * 60 * 60, #2 hours
    :httponly => true
  }

  configure :development do
    # The normal Sinatra logger
    set :logging, Logger::DEBUG

    # This is another logger for use in the Application scope
    logger = Logger.new $stdout
    logger.level = Logger::DEBUG
    logger.datetime_format = '%a %d-%m-%Y %H%M '
    set :logger, logger
    $stdout.sync = true
  end

  helpers do
    def logger
      settings.logger
    end
  end

  # OAuth2 Resource Server
  require 'rack/oauth2'
  require 'rack/oauth2/server/token/extension/jwt'
  use Rack::OAuth2::Server::Resource::Bearer, 'AOK Protected Resources' do |req|
    AccessToken.valid.find_by_token(req.access_token) || req.invalid_token!
  end


  # Register with the router
  require 'nats/client'
  def self.nats_message(subject, message)
    NATS.start(:uri => CCConfig[:message_bus_uri], :max_reconnect_attempts => 999999) do
      NATS.publish(subject, message)
      NATS.stop
    end
  end
  configure do
    Aok::Config::Strategy.initialize_strategy
    Aok::Config.initialize_database
    set :public_folder, File.expand_path('../../public', __FILE__)
    logger.debug "Serving static files from #{settings.public_folder.inspect}"

    bind_address = Kato::Local::Node.get_local_node_id<commit_msg>more robust router registration<commit_after>require 'logger'
require 'kato/local/node'

class ApplicationController < Sinatra::Base
  helpers ApplicationHelper, CurrentUserHelper, ErrorHandlingHelper

  set :raise_errors, true
  set :show_exceptions, false

  # IP Spoofing protection isn't that helpful and
  # causes a lot of warnings in the log
  set :protection, :except => :ip_spoofing

  set :logging, Logger::DEBUG

  # The session is only used for the duration of the login process
  # the expiration is set to 2 hours to allow for clock skew
  # between clients and the server.
  use Rack::Session::ActiveRecord, {
    :sidbits => 1024,
    :expire_after => 2 * 60 * 60, #2 hours
    :httponly => true
  }

  configure :development do
    # The normal Sinatra logger
    set :logging, Logger::DEBUG

    # This is another logger for use in the Application scope
    logger = Logger.new $stdout
    logger.level = Logger::DEBUG
    logger.datetime_format = '%a %d-%m-%Y %H%M '
    set :logger, logger
    $stdout.sync = true
  end

  helpers do
    def logger
      settings.logger
    end
  end

  # OAuth2 Resource Server
  require 'rack/oauth2'
  require 'rack/oauth2/server/token/extension/jwt'
  use Rack::OAuth2::Server::Resource::Bearer, 'AOK Protected Resources' do |req|
    AccessToken.valid.find_by_token(req.access_token) || req.invalid_token!
  end


  # Register with the router
  require 'nats/client'
  def self.nats_message(subject, message, logger)
    NATS.start(:uri => CCConfig[:message_bus_uri], :max_reconnect_attempts => 999999) do
      NATS.publish(subject, message) do
        logger.debug "NATS server received message."
        NATS.stop
      end
    end
  end
  configure do
    Aok::Config::Strategy.initialize_strategy
    Aok::Config.initialize_database
    set :public_folder, File.expand_path('../../public', __FILE__)
    logger.debug "Serving static files from #{settings.public_folder.inspect}"

    bind_address = Kato::Local::Node.get_local_node_id
{'fraction_non_alphanumeric': 0.09507944643772424, 'fraction_numerical': 0.010763710917478216, 'mean_word_length': 3.6575178997613365, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 15, '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': '3088884', 'n_tokens_mistral': 1257, 'n_tokens_neox': 1181, 'n_words': 358}