Sha256: 57deef50bd193baa1f365f62763935ed7e8c365c750d10d90875cdb2911fff9f

Contents?: true

Size: 1.73 KB

Versions: 3

Compression:

Stored size: 1.73 KB

Contents

ShopifyApp.configure do |config|
  config.application_name = "<%= @application_name %>"
  config.old_secret = "<%= @old_secret %>"
  config.scope = "<%= @scope %>" # Consult this page for more scope options:
                                  # https://help.shopify.com/en/api/getting-started/authentication/oauth/scopes
  config.embedded_app = <%= embedded_app? %>
  config.after_authenticate_job = false
  config.api_version = "<%= @api_version %>"
  config.shop_session_repository = 'Shop'

  config.reauth_on_access_scope_changes = true

  config.api_key = ENV.fetch('SHOPIFY_API_KEY', '').presence
  config.secret = ENV.fetch('SHOPIFY_API_SECRET', '').presence

  if defined? Rails::Server
    raise('Missing SHOPIFY_API_KEY. See https://github.com/Shopify/shopify_app#requirements') unless config.api_key
    raise('Missing SHOPIFY_API_SECRET. See https://github.com/Shopify/shopify_app#requirements') unless config.secret
  end
end

Rails.application.config.after_initialize do
  if ShopifyApp.configuration.api_key.present? && ShopifyApp.configuration.secret.present?
    ShopifyAPI::Context.setup(
      api_key: ShopifyApp.configuration.api_key,
      api_secret_key: ShopifyApp.configuration.secret,
      api_version: ShopifyApp.configuration.api_version,
      host_name: URI(ENV.fetch('HOST', '')).host || '',
      scope: ShopifyApp.configuration.scope,
      is_private: !ENV.fetch('SHOPIFY_APP_PRIVATE_SHOP', '').empty?,
      is_embedded: ShopifyApp.configuration.embedded_app,
      session_storage: ShopifyApp::SessionRepository,
      logger: Rails.logger,
      private_shop: ENV.fetch('SHOPIFY_APP_PRIVATE_SHOP', nil),
      user_agent_prefix: "ShopifyApp/#{ShopifyApp::VERSION}"
    )

    ShopifyApp::WebhooksManager.add_registrations
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
shopify_app-19.0.2 lib/generators/shopify_app/install/templates/shopify_app.rb.tt
shopify_app-19.0.1 lib/generators/shopify_app/install/templates/shopify_app.rb.tt
shopify_app-19.0.0 lib/generators/shopify_app/install/templates/shopify_app.rb.tt