### Manual Installation with npm Source: https://adogrove.stouder.io/packages/auditing/installation.html Install the package using npm and then configure it. ```sh npm install @adogrove/adonis-auditing node ace configure @adogrove/adonis-auditing ``` -------------------------------- ### Model Setup with Auditable Mixin Source: https://adogrove.stouder.io/packages/auditing/basic-usage/model-setup.html Extend your Lucid models with the `Auditable` mixin using the `compose` helper to add auditing capabilities. Ensure the package is installed before use. ```typescript import { DateTime } from 'luxon' import { BaseModel, column } from '@adonisjs/lucid/orm' import { compose } from '@adonisjs/core/helpers' import { Auditable } from '@adogrove/adonis-auditing' export default class Book extends compose(BaseModel, Auditable) { @column({ isPrimary: true }) declare id: number @column() declare title: string @column.dateTime({ autoCreate: true }) declare createdAt: DateTime @column.dateTime({ autoCreate: true, autoUpdate: true }) declare updatedAt: DateTime } ``` -------------------------------- ### Manual Installation with pnpm Source: https://adogrove.stouder.io/packages/auditing/installation.html Install the package using pnpm and then configure it. ```sh pnpm add @adogrove/adonis-auditing node ace configure @adogrove/adonis-auditing ``` -------------------------------- ### Manual Installation with yarn Source: https://adogrove.stouder.io/packages/auditing/installation.html Install the package using yarn and then configure it. ```sh yarn add @adogrove/adonis-auditing node ace configure @adogrove/adonis-auditing ``` -------------------------------- ### Install with Ace Command Source: https://adogrove.stouder.io/packages/auditing/installation.html Use this command to automatically install and configure the package. ```sh node ace add @adogrove/adonis-auditing ``` -------------------------------- ### Retrieve Audits for a Book Source: https://adogrove.stouder.io/packages/auditing/basic-usage/getting-audits.html Fetch audits associated with a specific book instance. This includes getting the first available book, all its audits, the first audit, or the last audit. ```typescript // Get the first available book const book = await Book.firstOrFail() // Get all associated audits const audits = await book.audits() // Get the first audit const first = await book.audits().first() // Get the last audit const last = await book.audits().last() ``` -------------------------------- ### Default Auditing Configuration Source: https://adogrove.stouder.io/packages/auditing/configuration/general-configuration.html This is the default configuration for the auditing module. It sets up context warning behavior and specifies resolvers for IP address, user agent, and URL. ```typescript import { defineConfig } from '@adogrove/adonis-auditing/setup' export default defineConfig({ warnOnMissingContext: true, userResolver: () => import('#audit_resolvers/user_resolver'), resolvers: { ip_address: () => import('#audit_resolvers/ip_address_resolver'), user_agent: () => import('#audit_resolvers/user_agent_resolver'), url: () => import('#audit_resolvers/url_resolver'), }, }) ``` -------------------------------- ### Custom Audit Resolver Implementation Source: https://adogrove.stouder.io/packages/auditing/advanced-usage/audit-resolvers.html Implement the Resolver interface to create a custom audit resolver. The resolve method should return a Promise of unknown, typically containing request-specific metadata. ```typescript import { HttpContext } from '@adonisjs/core/http' import { Resolver } from '@stouder-io/adonis-auditing' export default class RandomResolver implements Resolver { async resolve(ctx: HttpContext) { return Math.random() * 100 } } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.