Skip to content

feat(settings): add audit retention days to general settings API - #308

Merged
YuZhiYuanDev merged 1 commit into
mainfrom
feat/audit-retention-via-general-settings
Aug 26, 2026
Merged

feat(settings): add audit retention days to general settings API#308
YuZhiYuanDev merged 1 commit into
mainfrom
feat/audit-retention-via-general-settings

Conversation

@hashbk

@hashbk hashbk commented Aug 23, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Add the audit log retention days configuration to the existing GET/PUT /api/settings/general endpoint, replacing the standalone AuditSettingsService that had no API exposure
  • Administrators can now configure audit retention alongside other general settings without a separate endpoint

Changes

File Change
dto/general-settings.dto.ts Add auditRetentionDays to GeneralSettingsDto and UpdateGeneralSettingsDto with @IsInt and @Min(0)
services/general-settings.service.ts Add AUDIT_RETENTION_DAYS_KEY, getAuditRetentionDays(), and readAuditRetentionDays()
audit/services/audit-cleanup.service.ts Inject GeneralSettingsService instead of AuditSettingsService
services/audit-settings.service.ts Deleted — logic consolidated into GeneralSettingsService
settings.module.ts Remove AuditSettingsService from providers/exports
general-settings.service.spec.ts Add tests for persistence, fallback, and DTO validation

Usage

PUT /api/settings/general
{
  "watermarkEnabled": true,
  "auditRetentionDays": 30
}

A value of 0 disables auto-cleanup (default). The daily cron job in AuditCleanupService reads this setting and deletes audit records older than the configured number of days.

Move the audit log retention days configuration into the existing
GET/PUT /api/settings/general endpoint so administrators can configure
it alongside other general settings without a separate API.

Changes:
- Add auditRetentionDays field to GeneralSettingsDto and
  UpdateGeneralSettingsDto with @ISINT and @min(0) validation
  (0 disables auto-cleanup, which is the default)
- Add getAuditRetentionDays() to GeneralSettingsService for
  AuditCleanupService to consume
- Update AuditCleanupService to inject GeneralSettingsService instead
  of AuditSettingsService
- Remove the now-obsolete AuditSettingsService and its registration
  in SettingsModule
- Add tests for persistence, invalid value fallback, and DTO validation
@hashbk
hashbk force-pushed the feat/audit-retention-via-general-settings branch from 0274a9e to f0ea49e Compare August 26, 2026 11:50
@YuZhiYuanDev
YuZhiYuanDev merged commit 660c51d into main Aug 26, 2026
6 checks passed
@YuZhiYuanDev
YuZhiYuanDev deleted the feat/audit-retention-via-general-settings branch August 26, 2026 11:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants