This is the router file
defmodule MApiWeb.Router do
use MyApiWeb, :router
pipeline :browser do
plug :accepts, ["html"]
plug :fetch_session
plug :fetch_flash
plug :protect_from_forgery
plug :put_secure_browser_headers
end
pipeline :admin do
plug :put_layout, {MyApiWeb.Admin.LayoutView, :app}
end
pipeline :api do
plug :accepts, ["json"]
end
scope "/", MyApiWeb do
pipe_through :browser # Use the default browser stack
# activate page
get "/activate/:code", ActivateController, :from_web
end
scope "/admin", MyApiWeb.Admin do
pipe_through [:browser, :admin]
get "/doctor", DoctorController, :index
get "/doctor/not_approve", DoctorController, :not_approve
get "/doctor/already_approve", DoctorController, :already_approve
get "/doctor/:id/approve", DoctorController, :approve
end
scope "/api", MyApiWeb do
pipe_through :api
# debug
get "/test", TestController, :test
get "/auth_test", TestController, :auth_test
# user signup/signin
post "/verify_mailaddress", UserController, :verify_mailaddress
post "/signup", UserController, :signup
post "/signin", UserController, :signin
post "/refresh", UserController, :refresh
put "/activate", ActivateController, :index
get "/profile", UserController, :get_myprofile
get "/profile/:user_id", UserController, :get_profile
put "/profile/update", UserController, :update_profile
patch "/mailaddress/update", UserController, :update_mailaddress
put "/change_password", UserController, :change_password
post "/generate_reset_code", UserController, :generate_reset_code
put "/reset_password", UserController, :reset_password
# data(static, media)
scope "/data" do
get "/treatment_categories", DataController, :get_treatment_categories
post "/media", DataController, :media_upload
end
scope "/map" do
get "/geometry", MapController, :get_geometry
end
# only CACA
scope "/caca", Caca do
# Question API
scope "/question" do
get "/user", QuestionController, :get_base_user
get "/user/:user_id", QuestionController, :get_base_user
post "/", QuestionController, :post
get "/", QuestionController, :get
get "/:id", QuestionController, :get
put "/:id", QuestionController, :update
delete "/:id", QuestionController, :delete
# Answer API
post "/:question_id/answer", QuestionController, :post_answer
get "/:question_id/answer", QuestionController, :get_answer
scope "/answer" do
put "/:id", QuestionController, :update_answer
delete "/:id", QuestionController, :delete_answer
# Reaction API
get "/:answer_id/reaction", QuestionController, :get_reaction
post "/:answer_id/reaction", QuestionController, :add_reaction
delete "/:answer_id/reaction", QuestionController, :remove_reaction
end
end
scope "/notif" do
get "/answer", NotifController, :get_answer_notif
put "/answer/read", NotifController, :read_answer_notif
get "/question", NotifController, :get_question_notif
put "/question/read", NotifController, :read_question_notif
end
end
# only MY
scope "/my", My do
scope "/user" do
get "/stripe_source", UserController, :get_stripe_sources
post "/stripe_source", UserController, :create_stripe_source
post "/stripe_source/:source_id", UserController, :update_stripe_source
delete "/stripe_source/:source_id", UserController, :delete_stripe_source
end
scope "/doctor" do
post "/search", UserController, :search_doctors
get "/random", UserController, :get_random_doctors
get "/:id/before_after", MedicareController, :get_before_after
get "/:id/surgery", MedicareController, :get_surgery
get "/:id/day_surgery", CalendarController, :get_day_surgeries
end
scope "/counsel" do
# /session
get "/session", CounselController, :session_list
post "/session", CounselController, :create_session
post "/session/:id/reply", CounselController, :create_reply
get "/session/:id", CounselController, :session_detail
patch "/reply/:id/read", CounselController, :read_reply
end
scope "/medicare" do
# /treatment
post "/treatment", MedicareController, :create_treatment
post "/treatment/search", MedicareController, :search_treatments
get "/treatment/random", MedicareController, :get_random_treatments
patch "/treatment/:id", MedicareController, :update_treatment
get "/treatment/:id", MedicareController, :get_treatment
# /appointment
post "/appointment", MedicareController, :create_appointment
post "/appointment/search", MedicareController, :search_appointments
get "/appointment/:id", MedicareController, :get_appointment
put "/appointment/:id", MedicareController, :edit_appointment
patch "/appointment/:id/done", MedicareController, :done_appointment
patch "/appointment/:id/cancel", MedicareController, :cancel_appointment
# /before_after
put "/before_after", MedicareController, :put_before_after
# /surgery
put "/surgery", MedicareController, :put_surgery
end
scope "/calendar" do
# /event
get "/event", CalendarController, :get_events
post "/event", CalendarController, :create_event
patch "/event/:id", CalendarController, :update_event
delete "/event/:id", CalendarController, :remove_event
# /day_surgery
post "/day_surgery", CalendarController, :create_day_surgery
patch "/day_surgery/:id", CalendarController, :update_day_surgery
delete "/day_surgery/:id", CalendarController, :remove_day_surgery
end
scope "/bank_account" do
get "/doctor", BankAccountController, :get_doctor_bank
get "/clinic", BankAccountController, :get_clinic_bank
put "/doctor", BankAccountController, :put_doctor_bank
put "/clinic", BankAccountController, :put_clinic_bank
end
end
end
end