Skip to content

Commit

Permalink
Add missing API
Browse files Browse the repository at this point in the history
  • Loading branch information
jasl committed Feb 1, 2025
1 parent e698496 commit 1908109
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
15 changes: 15 additions & 0 deletions app/controllers/api/events_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,21 @@

module Api
class EventsController < ::Api::ApplicationController
def index
@pagy, @records = pagy_uuid_cursor(
Event.all,
after: params[:after], primary_key: :eid, order: { id: :asc }
)

render json: {
status: ErrorConstants::OK,
events: @records.map(&:nip1_hash),
pagination: {
has_more: @pagy.has_more?
}
}
end

def show
@event = Event.find_by!(eid: params[:id])

Expand Down
2 changes: 1 addition & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
end
end

resources :events, only: %i[show create] do
resources :events, only: %i[index show create] do
collection do
post "batch", to: "events#batch_create"
end
Expand Down

0 comments on commit 1908109

Please sign in to comment.