Current section

16 Versions

Jump to

Compare versions

5 files changed
+30 additions
-27 deletions
  @@ -1,15 +1,14 @@
1 1 # Warlock
2 2
3 - ![GitHub Workflow Status](https://img.shields.io/github/workflow/status/strangemachines/warlock/test?style=for-the-badge)
4 - [![Hexdocs](https://img.shields.io/badge/docs-hexdocs-blueviolet.svg?style=for-the-badge)](https://hexdocs.pm/warlock)
5 3 [![Hex.pm](https://img.shields.io/hexpm/v/warlock.svg?style=for-the-badge)](https://hex.pm/packages/warlock)
4 + [![Hexdocs](https://img.shields.io/badge/docs-hexdocs-blueviolet.svg?style=for-the-badge)](https://hexdocs.pm/warlock)
6 5
7 6 Warlock is an API building library that generates as much code as possible, without getting in the way.
8 7
9 8 ## Installation
10 9
11 10 ```elixir
12 - {:warlock, "~> 1.0"}
11 + {:warlock, "~> 2.0"}
13 12 ```
14 13
15 14 ## Usage
  @@ -1,7 +1,10 @@
1 - {<<"app">>,<<"warlock">>}.
2 - {<<"build_tools">>,[<<"mix">>]}.
1 + {<<"links">>,
2 + [{<<"GitHub">>,<<"https://github.com/strangemachines/warlock">>}]}.
3 + {<<"name">>,<<"warlock">>}.
4 + {<<"version">>,<<"2.0.1">>}.
3 5 {<<"description">>,<<"A library to build Plug-based APIs">>}.
4 6 {<<"elixir">>,<<"~> 1.10">>}.
7 + {<<"app">>,<<"warlock">>}.
5 8 {<<"files">>,
6 9 [<<"mix.exs">>,<<"lib">>,<<"lib/warlock.ex">>,<<"lib/warlock">>,
7 10 <<"lib/warlock/siren">>,<<"lib/warlock/siren/links.ex">>,
  @@ -13,28 +16,25 @@
13 16 <<"lib/warlock/utils.ex">>,<<"lib/warlock/module_utils.ex">>,
14 17 <<".formatter.exs">>,<<"README.md">>,<<"LICENSE">>]}.
15 18 {<<"licenses">>,[<<"MPL-2.0">>]}.
16 - {<<"links">>,
17 - [{<<"GitHub">>,<<"https://github.com/strangemachines/warlock">>}]}.
18 - {<<"name">>,<<"warlock">>}.
19 19 {<<"requirements">>,
20 - [[{<<"app">>,<<"ecto_sql">>},
21 - {<<"name">>,<<"ecto_sql">>},
20 + [[{<<"name">>,<<"ecto_sql">>},
21 + {<<"app">>,<<"ecto_sql">>},
22 22 {<<"optional">>,true},
23 - {<<"repository">>,<<"hexpm">>},
24 - {<<"requirement">>,<<"~> 3.7">>}],
25 - [{<<"app">>,<<"jason">>},
26 - {<<"name">>,<<"jason">>},
23 + {<<"requirement">>,<<"~> 3.7">>},
24 + {<<"repository">>,<<"hexpm">>}],
25 + [{<<"name">>,<<"jason">>},
26 + {<<"app">>,<<"jason">>},
27 27 {<<"optional">>,false},
28 - {<<"repository">>,<<"hexpm">>},
29 - {<<"requirement">>,<<"~> 1.2">>}],
30 - [{<<"app">>,<<"plug">>},
31 - {<<"name">>,<<"plug">>},
28 + {<<"requirement">>,<<"~> 1.2">>},
29 + {<<"repository">>,<<"hexpm">>}],
30 + [{<<"name">>,<<"plug">>},
31 + {<<"app">>,<<"plug">>},
32 32 {<<"optional">>,false},
33 - {<<"repository">>,<<"hexpm">>},
34 - {<<"requirement">>,<<"~> 1.12">>}],
35 - [{<<"app">>,<<"plug_cowboy">>},
36 - {<<"name">>,<<"plug_cowboy">>},
33 + {<<"requirement">>,<<"~> 1.12">>},
34 + {<<"repository">>,<<"hexpm">>}],
35 + [{<<"name">>,<<"plug_cowboy">>},
36 + {<<"app">>,<<"plug_cowboy">>},
37 37 {<<"optional">>,false},
38 - {<<"repository">>,<<"hexpm">>},
39 - {<<"requirement">>,<<"~> 2.5">>}]]}.
40 - {<<"version">>,<<"2.0.0">>}.
38 + {<<"requirement">>,<<"~> 2.5">>},
39 + {<<"repository">>,<<"hexpm">>}]]}.
40 + {<<"build_tools">>,[<<"mix">>]}.
  @@ -108,6 +108,7 @@ defmodule Warlock.Handler do
108 108 case unquote(controller).delete(id, user) do
109 109 {0, nil} -> unquote(__CALLER__.module).send_404(conn)
110 110 {_, nil} -> unquote(__CALLER__.module).send_204(conn)
111 + {:error, :forbidden} -> unquote(__CALLER__.module).send_403(conn)
111 112 {:error, :not_found} -> unquote(__CALLER__.module).send_404(conn)
112 113 {:error, _} -> unquote(__CALLER__.module).send_500(conn)
113 114 end
  @@ -177,7 +177,10 @@ if Code.ensure_loaded?(Ecto) do
177 177
178 178 @impl true
179 179 def get_count(params, user) do
180 - unquote(__CALLER__.module)
180 + embeds = unquote(__CALLER__.module).embeds(params)
181 +
182 + params
183 + |> unquote(__CALLER__.module).prepare_query(embeds)
181 184 |> unquote(__CALLER__.module).apply_user(user)
182 185 |> unquote(__CALLER__.module).filter_by_params(params)
183 186 |> unquote(__CALLER__.module).count_items()
  @@ -4,7 +4,7 @@ defmodule Warlock.MixProject do
4 4 def project do
5 5 [
6 6 app: :warlock,
7 - version: "2.0.0",
7 + version: "2.0.1",
8 8 elixir: "~> 1.10",
9 9 start_permanent: Mix.env() == :prod,
10 10 description: description(),