better_params alternatives and similar packages
Based on the "Framework Components" category.
Alternatively, view better_params alternatives based on common mentions on social networks and blogs.
-
ex_admin
ExAdmin is an auto administration package for Elixir and the Phoenix Framework -
phoenix_html
Phoenix.HTML functions for working with HTML strings and templates -
phoenix_ecto
Phoenix and Ecto integration with support for concurrent acceptance testing -
absinthe_plug
Plug support for Absinthe, the GraphQL toolkit for Elixir -
react_phoenix
Make rendering React.js components in Phoenix easy -
phoenix_live_reload
Provides live-reload functionality for Phoenix -
params
Easy parameters validation/casting with Ecto.Schema, akin to Rails' strong parameters. -
phoenix_pubsub_redis
The Redis PubSub adapter for the Phoenix framework -
dayron
A repository `similar` to Ecto.Repo that maps to an underlying http client, sending requests to an external rest api instead of a database -
phoenix_token_auth
Token authentication solution for Phoenix. Useful for APIs for e.g. single page apps. -
rummage_phoenix
Full Phoenix Support for Rummage. It can be used for searching, sorting and paginating collections in phoenix. -
sentinel
DEPRECATED - Phoenix Authentication library that wraps Guardian for extra functionality -
phx_component_helpers
Extensible Phoenix liveview components, without boilerplate -
plug_rails_cookie_session_store
Rails compatible Plug session store -
multiverse
Elixir package that allows to add compatibility layers via API gateways. -
filterable
Filtering from incoming params in Elixir/Ecto/Phoenix with easy to use DSL. -
access pass
provides a full user authentication experience for an API. Includes login,logout,register,forgot password, forgot username, confirmation email and all that other good stuff. Includes plug for checking for authenticated users and macro for generating the required routes. -
scrivener_headers
Scrivener pagination with headers and web linking -
phoenix_pubsub_rabbitmq
RabbitMQ adapter for Phoenix's PubSub layer -
plug_checkup
PlugCheckup provides a Plug for adding simple health checks to your app -
plug_rest
REST behaviour and Plug router for hypermedia web applications in Elixir -
trailing_format_plug
An elixir plug to support legacy APIs that use a rails-like trailing format: http://api.dev/resources.json -
Votex
Implements vote / like / follow functionality for Ecto models in Elixir. Inspired from Acts as Votable gem in Ruby on Rails -
phoenix_html_simplified_helpers
Some helpers for phoenix html( truncate, time_ago_in_words, number_with_delimiter, url_for, current_page? ) -
plug_canonical_host
PlugCanonicalHost ensures that all requests are served by a single canonical host.
Learn Elixir in as little as 12 Weeks
Do you think we are missing an alternative of better_params or a related project?
README
BetterParams
Cleaner request parameters in Elixir web applications ๐
BetterParams
is a simple Elixir Plug that allows passed
request parameters to be called as atoms
instead of Strings. The
sole purpose of this Plug is to pattern match on maps with atom keys
instead of string keys in routers/controllers to calm my OCD down.
Usage
Once installed, it lets you pattern match request parameters like
%{id: id}
instead of %{"id" => id}
in Phoenix applications:
# web/controllers/some_controller.ex
def show(conn, %{id: id}) do
# do something
end
def create(conn, %{id: id, post: %{title: title, body: body}}) do
# do something
end
Notes
- Implementation uses
String.to_existing_atom
to prevent against DoS attacks, so it only converts those params to atoms that you use in your application. - You can continue to use String keys without breaking your existing
matches if you want. All request parameters are available for both
String
andAtom
keys (that have already been defined in the application). - This doesn't pollute your Request Logs with duplicate params.
- For other
Plug.Router
based applications, you can also access request params similarly by calling them likeconn.params[:id]
orconn.params.post.title
.
Installation
Add better_params
to your project dependencies in mix.exs
:
def deps do
[{:better_params, "~> 0.5.0"}]
end
Phoenix Framework
For Phoenix applications, call the plug at the end of the controller
method in web/web.ex
(inside the quote
block):
# web/web.ex
def controller do
quote do
use Phoenix.Controller
# Other stuff...
plug BetterParams
end
end
Alternatively, you can also call it your Router Pipelines or in individual controllers directly.
Other Plug.Router Apps
For other applications using Plug.Router
, call the Plug anytime after
calling the :match
and :dispatch
plugs:
defmodule MyApp.Router do
use Plug.Router
plug :match
plug :dispatch
plug BetterParams
# Rest of the router...
end
Removing String Keys Entirely
If your use case calls for a params object with only Atom
keys, you
may pass the option drop_string_keys
to the plug. Much as it says on
the can, this will replace the String
-type keys altogether, rather
than preserving them alongside the Atom
keys.
plug BetterParams, drop_string_keys: true
Roadmap
- [x] Write Tests
- [x] Write Documentation
- [x] Symbolize the collective
params
map - [x] Option to remove string keys entirely
- [ ] Symbolize individual parameter maps (if the need arises)
- [ ]
path_params
- [ ]
body_params
- [ ]
query_params
- [ ]
Contributing
- Fork, Enhance, Send PR
- Lock issues with any bugs or feature requests
- Implement something from Roadmap
- Spread the word :heart:
License
This package is available as open source under the terms of the MIT License.
*Note that all licence references and agreements mentioned in the better_params README section above
are relevant to that project's source code only.