Command auditing middleware for Commanded CQRS/ES applications.
Records every dispatched command to the configured database storage. Includes whether the command was successfully handled, or any error.
Please refer to the CHANGELOG for features, bug fixes, and any upgrade advice included for each release.
MIT License
-
Add
commanded_audit_middleware
to your list of dependencies inmix.exs
:def deps do [ {:commanded_audit_middleware, "~> 0.3"}, ] end
-
Add the following config section to
config/config.exs
:config :commanded_audit_middleware, ecto_repos: [Commanded.Middleware.Auditing.Repo], serializer: Commanded.Serialization.JsonSerializer
-
By default,
commanded_audit_middleware
should filter allpassword
,password_confirmation
andsecret
in your schemas. If you want to override and define your own filters, you should add the following to yourconfig/config.exs
:config :commanded_audit_middleware, filter_fields: [:credit_card_number, :btc_private_key]
-
Add the following config section to each environment's config (e.g.
config/dev.exs
):config :commanded_audit_middleware, Commanded.Middleware.Auditing.Repo, adapter: Ecto.Adapters.Postgres, database: "commanded_audit_middleware_dev", username: "postgres", password: "postgres", hostname: "localhost", port: "5432"
-
Fetch and compile mix dependencies:
$ mix do deps.get, deps.compile
-
Create and migrate the command audit database:
$ mix ecto.create -r Commanded.Middleware.Auditing.Repo $ mix ecto.migrate -r Commanded.Middleware.Auditing.Repo
-
Add the middleware to your application's Commanded router.
defmodule Router do use Commanded.Commands.Router middleware Commanded.Middleware.Auditing end
Pull requests to contribute new or improved features, and extend documentation are most welcome. Please follow the existing coding conventions.
You should include unit tests to cover any changes. Run mix test
to execute the test suite:
mix deps.get
mix test