This commit is contained in:
@@ -1,6 +1,5 @@
|
|||||||
defmodule DecentralisedBookIndex.Metadata do
|
defmodule DecentralisedBookIndex.Metadata do
|
||||||
use Ash.Domain,
|
use Ash.Domain, otp_app: :decentralised_book_index, extensions: [AshJsonApi.Domain, AshPhoenix]
|
||||||
otp_app: :decentralised_book_index
|
|
||||||
|
|
||||||
alias DecentralisedBookIndex.Metadata
|
alias DecentralisedBookIndex.Metadata
|
||||||
|
|
||||||
@@ -64,4 +63,13 @@ defmodule DecentralisedBookIndex.Metadata do
|
|||||||
|
|
||||||
resource DecentralisedBookIndex.Metadata.AuthorRole
|
resource DecentralisedBookIndex.Metadata.AuthorRole
|
||||||
end
|
end
|
||||||
|
|
||||||
|
json_api do
|
||||||
|
routes do
|
||||||
|
base_route "/author", Metadata.Author do
|
||||||
|
get :read
|
||||||
|
index :search
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -2,11 +2,16 @@ defmodule DecentralisedBookIndex.Metadata.Author do
|
|||||||
use Ash.Resource,
|
use Ash.Resource,
|
||||||
otp_app: :decentralised_book_index,
|
otp_app: :decentralised_book_index,
|
||||||
domain: DecentralisedBookIndex.Metadata,
|
domain: DecentralisedBookIndex.Metadata,
|
||||||
data_layer: AshPostgres.DataLayer
|
data_layer: AshPostgres.DataLayer,
|
||||||
|
extensions: [AshJsonApi.Resource]
|
||||||
|
|
||||||
require Ash.Query
|
require Ash.Query
|
||||||
alias DecentralisedBookIndex.Metadata
|
alias DecentralisedBookIndex.Metadata
|
||||||
|
|
||||||
|
json_api do
|
||||||
|
type "author"
|
||||||
|
end
|
||||||
|
|
||||||
postgres do
|
postgres do
|
||||||
table "authors"
|
table "authors"
|
||||||
repo DecentralisedBookIndex.Repo
|
repo DecentralisedBookIndex.Repo
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
defmodule DecentralisedBookIndexWeb.AshJsonApiRouter do
|
defmodule DecentralisedBookIndexWeb.AshJsonApiRouter do
|
||||||
use AshJsonApi.Router,
|
use AshJsonApi.Router,
|
||||||
domains: [],
|
domains: [Module.concat(["DecentralisedBookIndex.Metadata"])],
|
||||||
open_api: "/open_api"
|
open_api: "/open_api"
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -21,12 +21,12 @@ defmodule DecentralisedBookIndexWeb.Router do
|
|||||||
plug :set_actor, :user
|
plug :set_actor, :user
|
||||||
end
|
end
|
||||||
|
|
||||||
scope "/api/json" do
|
scope "/api/v1/json" do
|
||||||
pipe_through [:api]
|
pipe_through [:api]
|
||||||
|
|
||||||
forward "/swaggerui",
|
forward "/swaggerui",
|
||||||
OpenApiSpex.Plug.SwaggerUI,
|
OpenApiSpex.Plug.SwaggerUI,
|
||||||
path: "/api/json/open_api",
|
path: "/api/v1/json/open_api",
|
||||||
default_model_expand_depth: 4
|
default_model_expand_depth: 4
|
||||||
|
|
||||||
forward "/", DecentralisedBookIndexWeb.AshJsonApiRouter
|
forward "/", DecentralisedBookIndexWeb.AshJsonApiRouter
|
||||||
|
|||||||
Reference in New Issue
Block a user