Commanded audit middleware
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.
Installation
Add
commanded_audit_middlewareto your list of dependencies inmix.exs:def deps do[{:commanded_audit_middleware, "~> 0.1"},]endAdd the following config section to
config/config.exs:config :commanded_audit_middleware,ecto_repos: [Commanded.Middleware.Auditing.Repo],serializer: Commanded.Serialization.JsonSerializerAdd 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.compileCreate and migrate the command audit database:
$ mix ecto.create -r Commanded.Middleware.Auditing.Repo$ mix ecto.migrate -r Commanded.Middleware.Auditing.RepoAdd the middleware to your application's Commanded router.
defmodule Router douse Commanded.Commands.Routermiddleware Commanded.Middleware.Auditingend