* define api routes and create controllers, sketch out index and create actions * add api v1 organizations CRUD spec and docs spec, need to run swagger * swagger dry run on admin organizations routes, typo fix in api.rb * flesh out specs and sketch out admin actions * move actions out of concerns/include pattern and into v1 inline * remove private constant call * add v1 accept header to doc spec, fix syntax in a before block * update controllers to address failing specs * simplify controller and clarify route config * flesh out tests for errors * fix long line * add missing commas * return username show route to v0 concern controller * create separate show route and action name, remove nesting from create/update params requirement * clean up syntax in controller params and update show path in specs; move routes * fix up syntax in params permit * create organization in index spec * one more syntax tweak for org params * refactoring to one show route that handles username or id * tweak spec syntax to expect the right array * tweak controller and specs, simplify routing to show * remove create route, action, and specs from this branch * add clarifying comment in show controller action * add explicit not found return to show route * fix controller formatting causing 404 errors * remove comment, update specs * remove commment and fix id show response and specs * fix show route and request spec for username param * update unauthorized user specs to use put for now instead of post, regenerate swagger docs * adjust update 422 spec to break org validity * fix admin update spec, rerun swagger * reorganiza controller actions, update specs, ensure authorized update and delete * improve spec, handle finding one org more gracefully, delete via worker * copy routes into api namespace instead of moving them from general namespace * update param in v0 show route to fit more general naming * regenerate v1 swagger docs * use profile image url getter in update controller response * update swagger docs and remove unneeded comment from org' model * configure organizations destroy action for super admins only (for now)
64 lines
2.1 KiB
Ruby
64 lines
2.1 KiB
Ruby
namespace :admin do
|
|
resources :users, only: [:create]
|
|
end
|
|
|
|
resources :articles, only: %i[index show create update] do
|
|
collection do
|
|
get "/search", to: "articles#search"
|
|
get "me(/:status)", to: "articles#me", constraints: { status: /published|unpublished|all/ }
|
|
get "/:username/:slug", to: "articles#show_by_slug"
|
|
get "/latest", to: "articles#index", defaults: { sort: "desc" }
|
|
end
|
|
end
|
|
|
|
resources :comments, only: %i[index show]
|
|
resources :videos, only: [:index]
|
|
resources :podcast_episodes, only: [:index]
|
|
resources :users, only: %i[show] do
|
|
collection do
|
|
get :me
|
|
end
|
|
end
|
|
resources :tags, only: [:index]
|
|
resources :follows, only: [:create] do
|
|
collection do
|
|
get :tags
|
|
end
|
|
end
|
|
namespace :followers do
|
|
get :users
|
|
get :organizations
|
|
end
|
|
resources :readinglist, only: [:index]
|
|
|
|
get "/analytics/totals", to: "analytics#totals"
|
|
get "/analytics/historical", to: "analytics#historical"
|
|
get "/analytics/past_day", to: "analytics#past_day"
|
|
get "/analytics/referrers", to: "analytics#referrers"
|
|
|
|
resources :health_checks, only: [] do
|
|
collection do
|
|
get :app
|
|
get :database
|
|
get :cache
|
|
end
|
|
end
|
|
|
|
resources :profile_images, only: %i[show], param: :username
|
|
|
|
# The show route now handles the conventional "by id" lookup as well as by `username` (original way),
|
|
# so nested resources look up a param called organization_id_or_slug for now. (`username` is an alias for `slug`)
|
|
# Later on we may wish to refactor to a show route (and namespace for nested routes)
|
|
# that assumes an id has been given but can lookup by username if a query param is provided.
|
|
# however, this might cause friction with a consumer accustomed to lookups by username,
|
|
# so we may want to communicate such a change in advance before implementing it.
|
|
resources :organizations, only: [:show], param: :id_or_slug do
|
|
resources :users, only: [:index], to: "organizations#users"
|
|
resources :articles, only: [:index], to: "organizations#articles"
|
|
end
|
|
|
|
resource :instance, only: %i[show]
|
|
|
|
constraints(RailsEnvConstraint.new(allowed_envs: %w[test])) do
|
|
resource :feature_flags, only: %i[create show destroy], param: :flag
|
|
end
|