<commit_before>require 'rubygems'

# TODO This should probably be in app-config.rb.
require 'jrjackson'

require_relative 'util'

require 'rack/cors'
require 'sinatra/base'
require "sinatra/cookies"

require_relative 'version'
require_relative 'config'
require_relative 'routes/base'
require_relative 'routes/root'
require_relative 'routes/annotations'
require_relative 'routes/nanopubs'
require_relative 'routes/datasets'
require_relative 'routes/expressions'
require_relative 'routes/language'
require_relative 'routes/functions'
require_relative 'routes/relationships'
require_relative 'routes/namespaces'
require_relative 'routes/authenticate'
require_relative 'routes/version'
require_relative 'middleware/auth'

module OpenBEL

  class Server < Sinatra::Application

    configure do
      config = OpenBEL::Config::load!
      OpenBEL.const_set :Settings, config
    end

    if OpenBEL::Settings[:auth][:enabled]
      enable :sessions
      set :session_secret, OpenBEL::Settings['session_secret']
    end

    use Rack::Deflater
    use Rack::Cors do
      allow do
        origins '*'
        resource '*',
          :headers     => :any,
          :methods     => [ :get, :post, :put, :delete, :options ],
          :max_age     => 1,
          :credentials => false,
          :expose      => [
            'Allow',
            'Content-Type',
            'Content-Encoding',
            'Content-Length',
            'ETag',
            'Last-Modified',<commit_msg>config the default URI reader to ref TDB directory<commit_after>require 'rubygems'

# TODO This should probably be in app-config.rb.
require 'jrjackson'
require 'bel_parser'

require_relative 'util'

require 'rack/cors'
require 'sinatra/base'
require "sinatra/cookies"

require_relative 'version'
require_relative 'config'
require_relative 'routes/base'
require_relative 'routes/root'
require_relative 'routes/annotations'
require_relative 'routes/nanopubs'
require_relative 'routes/datasets'
require_relative 'routes/expressions'
require_relative 'routes/language'
require_relative 'routes/functions'
require_relative 'routes/relationships'
require_relative 'routes/namespaces'
require_relative 'routes/authenticate'
require_relative 'routes/version'
require_relative 'middleware/auth'

module OpenBEL

  class Server < Sinatra::Application

    configure do
      config = OpenBEL::Config::load!
      OpenBEL.const_set :Settings, config

      tdbdir = OpenBEL::Settings[:resource_rdf][:jena][:tdb_directory]
      BELParser::Resource.default_uri_reader =
        BELParser::Resource::JenaTDBReader.new(tdbdir)
    end

    if OpenBEL::Settings[:auth][:enabled]
      enable :sessions
      set :session_secret, OpenBEL::Settings['session_secret']
    end

    use Rack::Deflater
    use Rack::Cors do
      allow do
        origins '*'
        resource '*',
          :headers     => :any,
          :methods     => [ :get, :post, :put, :delete, :options ],
          :max_age     => 1,
          :credentials => false,
          :expose      => [
            'Allow',
            'Content-Type',
            'Content-Encoding',
            'Content-Length',
            'ETag',
            'Last-Modified',
{'fraction_non_alphanumeric': 0.10752351097178683, 'fraction_numerical': 0.0006269592476489029, 'mean_word_length': 3.266042780748663, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 13, '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': '732379', 'n_tokens_mistral': 955, 'n_tokens_neox': 953, 'n_words': 209}