Class: BetterAuth::Auth

Inherits:
Object
  • Object
show all
Defined in:
lib/better_auth/auth.rb

Constant Summary collapse

TELEMETRY_ADAPTER_IDS =
{
  "BetterAuth::Adapters::Memory" => "memory",
  "BetterAuth::Adapters::Postgres" => "postgres",
  "BetterAuth::Adapters::MySQL" => "mysql",
  "BetterAuth::Adapters::SQLite" => "sqlite",
  "BetterAuth::Adapters::MSSQL" => "mssql"
}.freeze
TELEMETRY_DATABASE_IDS =
{
  memory: "memory",
  postgres: "postgres",
  mysql: "mysql",
  sqlite: "sqlite",
  mssql: "mssql"
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Auth

Returns a new instance of Auth.



23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/better_auth/auth.rb', line 23

def initialize(options = {})
  @options = Configuration.new(options)
  @context = Context.new(@options)
  @context.set_adapter(build_adapter)
  @context.set_internal_adapter(Adapters::InternalAdapter.new(@context.adapter, @options))
  @plugin_registry = PluginRegistry.new(@context)
  @plugin_registry.run_init!
  @error_codes = build_error_codes
  @endpoints = build_endpoints
  Router.check_endpoint_conflicts(@options, @options.logger)
  @api = API.new(@context, @endpoints)
  @handler = Router.new(@context, @endpoints)
  @telemetry = build_telemetry_publisher
end

Instance Attribute Details

#apiObject (readonly)

Returns the value of attribute api.



21
22
23
# File 'lib/better_auth/auth.rb', line 21

def api
  @api
end

#contextObject (readonly)

Returns the value of attribute context.



21
22
23
# File 'lib/better_auth/auth.rb', line 21

def context
  @context
end

#error_codesObject (readonly)

Returns the value of attribute error_codes.



21
22
23
# File 'lib/better_auth/auth.rb', line 21

def error_codes
  @error_codes
end

#handlerObject (readonly)

Returns the value of attribute handler.



21
22
23
# File 'lib/better_auth/auth.rb', line 21

def handler
  @handler
end

#optionsObject (readonly)

Returns the value of attribute options.



21
22
23
# File 'lib/better_auth/auth.rb', line 21

def options
  @options
end

#telemetryObject (readonly)

Returns the value of attribute telemetry.



21
22
23
# File 'lib/better_auth/auth.rb', line 21

def telemetry
  @telemetry
end

Instance Method Details

#call(env) ⇒ Object



38
39
40
# File 'lib/better_auth/auth.rb', line 38

def call(env)
  handler.call(env)
end