# frozen_string_literal: true

module Api
  class ApplicationController < ActionController::API
    include Pundit

    before_action :default_format_json
    before_action :authenticate!

    protected

    def authenticate!
      warden.authenticate!(:jwt)
    end

    def current_user
      warden.user
    end
    helper_method :current_user

    def default_format_json
      request.format = "json"
    end

    def warden
      request.env["warden"]
    end
  end
end
