1
0
mirror of https://github.com/danbee/chess synced 2025-03-04 08:39:06 +00:00
chess/lib/chess_web/controllers/api/opponent_controller.ex
2023-02-04 21:35:56 -06:00

18 lines
391 B
Elixir

defmodule ChessWeb.Api.OpponentsController do
use ChessWeb, :controller
import Chess.Auth, only: [current_user: 1]
alias Chess.Repo
alias Chess.Repo.Queries
def index(conn, %{"q" => query_string}) do
opponents =
conn
|> current_user()
|> Queries.opponents(query_string)
|> Repo.all()
render(conn, "index.json", %{opponents: opponents})
end
end