Add /api/collection endpoint

This commit is contained in:
Claudio Ortolina
2025-03-10 11:17:51 +00:00
parent bd9f88ab02
commit 3d0eec3bff
4 changed files with 67 additions and 0 deletions
@@ -14,4 +14,20 @@ defmodule MusicLibraryWeb.CollectionController do
render(conn, :show, record: random_record)
end
def index(conn, params) do
limit =
Map.get(params, "limit", "20")
|> String.to_integer()
offset =
Map.get(params, "offset", "0")
|> String.to_integer()
total = Collection.search_records_count("")
records = Collection.search_records("", limit: limit, offset: offset)
render(conn, :index, total: total, limit: limit, offset: offset, records: records)
end
end