Sha256: 7f7f5790c41b2024cad67f6761313bbc4a74211de093a0a7b1bc1e0b73782f38

Contents?: true

Size: 1.29 KB

Versions: 5

Compression:

Stored size: 1.29 KB

Contents

Rails.application.config.middleware.use OmniAuth::Builder do
  provider :github,     ENV['GITHUB_KEY'],    ENV['GITHUB_SECRET'],     scope: %W{ read:org repo user public_repo }
  provider :bitbucket,  ENV['BITBUCKET_KEY'], ENV['BITBUCKET_SECRET'],  scope: %W{ repository issue pullrequest account team webhook }, prompt: 'consent'
end


Rails.application.config.middleware.insert_before 0, Rack::Cors do
  allow do
    origins '*'
    resource '*', headers: :any, credentials: true, methods: [:get, :post, :put, :patch, :delete, :options, :head]
  end
end

class AppConfig
  attr_accessor :ui_root_url, :api_root_url
  def initialize
    @ui_root_url = ENV['UI_ROOT'] || 'http://localhost:3000'
    @api_root_url = ENV['API_ROOT'] || 'http://localhost:3000/api'
  end
end

Config = AppConfig.new

class CustomAdapter < ActiveModelSerializers::Adapter::Json

  def meta
    meta = {
        version: '0.1.0'
    }

    if serializer.object.respond_to?(:next_page)
      meta.merge!({
          page: serializer.object.current_page,
          pages: serializer.object.total_pages,
          total_count: serializer.object.total_count,
          count: serializer.object.length,
          next_page: serializer.object.next_page
      })
    end

    meta
  end

end

ActiveModelSerializers.config.adapter = CustomAdapter

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
jobs-api-0.2.1 config/initializers/app_setup.rb
jobs-api-0.2.0 config/initializers/app_setup.rb
jobs-api-0.1.2 config/initializers/app_setup.rb
jobs-api-0.1.1 config/initializers/app_setup.rb
jobs-api-0.1.0 config/initializers/app_setup.rb