lib/clerk.rb in clerk-sdk-ruby-4.0.0.beta3 vs lib/clerk.rb in clerk-sdk-ruby-4.0.0.beta4
- old
+ new
@@ -1,63 +1,27 @@
# frozen_string_literal: true
-require_relative "clerk/version"
-require_relative "clerk/constants"
-require_relative "clerk/sdk"
+require "clerk/configuration"
+require "clerk/constants"
+require "clerk/error"
+require "clerk/sdk"
+require "clerk/version"
+if defined?(::Rails)
+ require "clerk/rails"
+end
+
module Clerk
class << self
def configure
- yield(configuration)
+ if block_given?
+ yield(configuration)
+ else
+ configuration
+ end
end
def configuration
- @configuration ||= Config.new
+ @configuration ||= Clerk::Configuration.default
end
end
-
- class Config
- PRODUCTION_BASE_URL = "https://api.clerk.dev/v1/".freeze
- attr_accessor :api_key, :base_url, :publishable_key, :logger, :middleware_cache_store
-
- # An array of route paths on which the middleware will not execute.
- #
- # Only request paths that match _exactly_ one of the routes will be skipped.
- # As a special case, if a route ends with '/*', then all request paths that
- # match the route's prefix will be skipped.
- #
- # For example, given the following configuration:
- #
- # excluded_routes = ["/foo", "/bar/*"]
- #
- # the following requests will be excluded:
- #
- # - /foo
- # - /bar/baz
- # - /bar/abc/xyz
- #
- # while the following requests will NOT be excluded:
- #
- # - /foo/bar
- # - /bar
- #
- attr_accessor :excluded_routes
-
- def initialize
- @base_url = ENV.fetch("CLERK_API_BASE", PRODUCTION_BASE_URL)
- @api_key = ENV["CLERK_API_KEY"]
-
- secret_key = ENV["CLERK_SECRET_KEY"]
- if secret_key && !secret_key.empty?
- @api_key = secret_key
- end
-
- @publishable_key = ENV["CLERK_PUBLISHABLE_KEY"]
-
- @excluded_routes = []
- end
- end
-end
-
-if defined?(::Rails)
- require_relative "clerk/railtie"
end