create gists

This commit is contained in:
zack 2024-10-26 15:01:33 -04:00
parent 79a17290d5
commit 43a8412f06
No known key found for this signature in database
GPG key ID: 5F873416BCF59F35
90 changed files with 1777 additions and 2107 deletions

View file

@ -0,0 +1,25 @@
defmodule ZoeyscomputerWeb.GistJSON do
alias Zoeyscomputer.Gists.Gist
@doc """
Renders a list of gists.
"""
def index(%{gists: gists}) do
%{data: for(gist <- gists, do: data(gist))}
end
@doc """
Renders a single gist.
"""
def show(%{gist: gist}) do
%{data: data(gist)}
end
defp data(%Gist{} = gist) do
%{
id: gist.id,
code: gist.code,
lang: gist.lang
}
end
end