2017-12-08 09:58:14 +01:00
|
|
|
defmodule EventosWeb.Router do
|
2018-01-14 17:56:50 +01:00
|
|
|
@moduledoc """
|
|
|
|
Router for eventos app
|
|
|
|
"""
|
2017-12-08 09:58:14 +01:00
|
|
|
use EventosWeb, :router
|
|
|
|
|
|
|
|
pipeline :api do
|
2018-07-27 10:45:35 +02:00
|
|
|
plug(:accepts, ["json"])
|
2017-12-08 09:58:14 +01:00
|
|
|
end
|
|
|
|
|
2018-05-17 11:32:23 +02:00
|
|
|
pipeline :well_known do
|
2018-07-27 10:45:35 +02:00
|
|
|
plug(:accepts, ["json/application", "jrd-json"])
|
2018-05-17 11:32:23 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
pipeline :activity_pub do
|
2018-07-27 10:45:35 +02:00
|
|
|
plug(:accepts, ["activity-json"])
|
2018-05-17 11:32:23 +02:00
|
|
|
plug(EventosWeb.HTTPSignaturePlug)
|
|
|
|
end
|
|
|
|
|
2017-12-09 14:58:37 +01:00
|
|
|
pipeline :api_auth do
|
2018-07-27 10:45:35 +02:00
|
|
|
plug(:accepts, ["json"])
|
|
|
|
plug(EventosWeb.AuthPipeline)
|
2017-12-08 09:58:14 +01:00
|
|
|
end
|
|
|
|
|
2018-01-09 17:52:26 +01:00
|
|
|
pipeline :browser do
|
2018-07-27 10:45:35 +02:00
|
|
|
plug(:accepts, ["html"])
|
|
|
|
plug(:fetch_session)
|
|
|
|
plug(:fetch_flash)
|
|
|
|
plug(:protect_from_forgery)
|
|
|
|
plug(:put_secure_browser_headers)
|
2018-01-09 17:52:26 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
scope "/api", EventosWeb do
|
2018-07-27 10:45:35 +02:00
|
|
|
pipe_through(:api)
|
2017-12-08 09:58:14 +01:00
|
|
|
|
2018-05-17 11:32:23 +02:00
|
|
|
scope "/v1" do
|
2018-07-27 10:45:35 +02:00
|
|
|
post("/users", UserController, :register)
|
|
|
|
get("/users/validate/:token", UserController, :validate)
|
|
|
|
post("/users/resend", UserController, :resend_confirmation)
|
|
|
|
|
|
|
|
post("/users/password-reset/send", UserController, :send_reset_password)
|
|
|
|
post("/users/password-reset/post", UserController, :reset_password)
|
|
|
|
|
|
|
|
post("/login", UserSessionController, :sign_in)
|
|
|
|
get("/groups", GroupController, :index)
|
|
|
|
get("/events", EventController, :index)
|
|
|
|
get("/events/all", EventController, :index_all)
|
|
|
|
get("/events/search/:name", EventController, :search)
|
|
|
|
get("/events/:uuid/ics", EventController, :export_to_ics)
|
|
|
|
get("/events/:uuid/tracks", TrackController, :show_tracks_for_event)
|
|
|
|
get("/events/:uuid/sessions", SessionController, :show_sessions_for_event)
|
|
|
|
get("/events/:uuid", EventController, :show)
|
|
|
|
get("/comments/:uuid", CommentController, :show)
|
|
|
|
get("/bots/:id", BotController, :show)
|
|
|
|
get("/bots", BotController, :index)
|
|
|
|
|
|
|
|
get("/actors", ActorController, :index)
|
|
|
|
get("/actors/search/:name", ActorController, :search)
|
|
|
|
get("/actors/:name", ActorController, :show)
|
2018-08-01 14:45:18 +02:00
|
|
|
|
|
|
|
resources("/followers", FollowerController, except: [:new, :edit])
|
|
|
|
|
2018-07-27 10:45:35 +02:00
|
|
|
resources("/tags", TagController, only: [:index, :show])
|
|
|
|
resources("/categories", CategoryController, only: [:index, :show])
|
|
|
|
resources("/sessions", SessionController, only: [:index, :show])
|
|
|
|
resources("/tracks", TrackController, only: [:index, :show])
|
|
|
|
resources("/addresses", AddressController, only: [:index, :show])
|
|
|
|
|
|
|
|
get("/search/:name", SearchController, :search)
|
2018-05-17 11:32:23 +02:00
|
|
|
end
|
2017-12-08 09:58:14 +01:00
|
|
|
end
|
|
|
|
|
2018-08-01 14:45:18 +02:00
|
|
|
# Authentificated API
|
2017-12-08 09:58:14 +01:00
|
|
|
scope "/api", EventosWeb do
|
2018-07-27 10:45:35 +02:00
|
|
|
pipe_through(:api_auth)
|
|
|
|
|
|
|
|
scope "/v1" do
|
|
|
|
get("/user", UserController, :show_current_actor)
|
|
|
|
post("/sign-out", UserSessionController, :sign_out)
|
|
|
|
resources("/users", UserController, except: [:new, :edit, :show])
|
|
|
|
post("/actors", ActorController, :create)
|
|
|
|
patch("/actors/:name", ActorController, :update)
|
|
|
|
post("/events", EventController, :create)
|
|
|
|
patch("/events/:uuid", EventController, :update)
|
|
|
|
put("/events/:uuid", EventController, :update)
|
|
|
|
delete("/events/:uuid", EventController, :delete)
|
|
|
|
post("/events/:uuid/join", ParticipantController, :join)
|
|
|
|
post("/comments", CommentController, :create)
|
|
|
|
patch("/comments/:uuid", CommentController, :update)
|
|
|
|
put("/comments/:uuid", CommentController, :update)
|
|
|
|
delete("/comments/:uuid", CommentController, :delete)
|
|
|
|
resources("/bots", BotController, except: [:new, :edit, :show, :index])
|
|
|
|
post("/groups", GroupController, :create)
|
|
|
|
post("/groups/:name/join", GroupController, :join)
|
|
|
|
resources("/members", MemberController)
|
|
|
|
resources("/sessions", SessionController, except: [:index, :show])
|
|
|
|
resources("/tracks", TrackController, except: [:index, :show])
|
|
|
|
get("/tracks/:id/sessions", SessionController, :show_sessions_for_track)
|
|
|
|
resources("/categories", CategoryController)
|
|
|
|
resources("/tags", TagController)
|
|
|
|
resources("/addresses", AddressController, except: [:index, :show])
|
|
|
|
end
|
2018-05-17 11:32:23 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
scope "/.well-known", EventosWeb do
|
2018-07-27 10:45:35 +02:00
|
|
|
pipe_through(:well_known)
|
2018-05-17 11:32:23 +02:00
|
|
|
|
2018-07-27 10:45:35 +02:00
|
|
|
get("/host-meta", WebFingerController, :host_meta)
|
|
|
|
get("/webfinger", WebFingerController, :webfinger)
|
|
|
|
get("/nodeinfo", NodeinfoController, :schemas)
|
2018-05-17 11:32:23 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
scope "/nodeinfo", EventosWeb do
|
|
|
|
get("/:version", NodeinfoController, :nodeinfo)
|
|
|
|
end
|
|
|
|
|
|
|
|
scope "/", EventosWeb do
|
2018-07-27 10:45:35 +02:00
|
|
|
pipe_through(:activity_pub)
|
|
|
|
|
|
|
|
get("/@:name", ActivityPubController, :actor)
|
|
|
|
get("/@:name/outbox", ActivityPubController, :outbox)
|
|
|
|
get("/@:name/following", ActivityPubController, :following)
|
|
|
|
get("/@:name/followers", ActivityPubController, :followers)
|
|
|
|
get("/events/:uuid", ActivityPubController, :event)
|
2018-08-24 11:34:00 +02:00
|
|
|
get("/comments/:uuid", ActivityPubController, :event)
|
2018-07-27 10:45:35 +02:00
|
|
|
post("/@:name/inbox", ActivityPubController, :inbox)
|
|
|
|
post("/inbox", ActivityPubController, :inbox)
|
2017-12-08 09:58:14 +01:00
|
|
|
end
|
2018-01-09 17:52:26 +01:00
|
|
|
|
2018-07-27 10:45:35 +02:00
|
|
|
if Mix.env() == :dev do
|
2018-07-04 14:29:17 +02:00
|
|
|
# If using Phoenix
|
2018-07-27 10:45:35 +02:00
|
|
|
forward("/sent_emails", Bamboo.SentEmailViewerPlug)
|
2018-07-04 14:29:17 +02:00
|
|
|
end
|
|
|
|
|
2018-01-09 17:52:26 +01:00
|
|
|
scope "/", EventosWeb do
|
2018-07-27 10:45:35 +02:00
|
|
|
pipe_through(:browser)
|
2018-01-09 17:52:26 +01:00
|
|
|
|
2018-07-27 10:45:35 +02:00
|
|
|
get("/*path", PageController, :index)
|
2018-01-09 17:52:26 +01:00
|
|
|
end
|
2017-12-08 09:58:14 +01:00
|
|
|
end
|