add more api endpoints

This commit is contained in:
DocuSeal
2023-10-01 01:57:47 +03:00
parent 872fbbc875
commit 1f41807412
9 changed files with 208 additions and 38 deletions
@@ -3,6 +3,12 @@
module Api
class ApiBaseController < ActionController::API
include ActiveStorage::SetCurrent
include Pagy::Backend
DEFAULT_LIMIT = 10
MAX_LIMIT = 100
wrap_parameters false
before_action :authenticate_user!
check_authorization
@@ -17,6 +23,16 @@ module Api
private
def paginate(relation)
result = relation.order(id: :desc)
.limit([params[:limit] || DEFAULT_LIMIT, MAX_LIMIT].min)
result = result.where('id < ?', params[:after]) if params[:after].present?
result = result.where('id > ?', params[:before]) if params[:before].present?
result
end
def current_account
current_user&.account
end