Skip to content

feat(server): add admin endpoint to delete 7-day inactive hosts - #153

Merged
rodriguecyber merged 1 commit into
Open-Source-Kigali:developfrom
DrDead0:issue-125-delete-incative-host
Aug 28, 2026
Merged

feat(server): add admin endpoint to delete 7-day inactive hosts#153
rodriguecyber merged 1 commit into
Open-Source-Kigali:developfrom
DrDead0:issue-125-delete-incative-host

Conversation

@DrDead0

@DrDead0 DrDead0 commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Summary

This PR addresses the issue of old, disconnected host records persisting in the database by introducing a secure deletion endpoint.

Scope: Backend only (UI confirmation modal will be implemented in a separate frontend PR).

We added a DELETE /hosts/:id endpoint that strictly enforces:

  1. The host exists (returns 404 otherwise).
  2. The host is not ONLINE (returns 409 Conflict otherwise).
  3. The host has been inactive for at least 7 days using lastSeen (or createdAt as a fallback for legacy records).
    It is protected by the @Roles('ADMIN') guard.

Type of change

  • Bug fix
  • New feature
  • Refactor / cleanup
  • Docs
  • Infrastructure / CI
  • Breaking change

Areas touched

  • apps/server (NestJS)
  • apps/web (React / Vite)
  • apps/agent (Go)
  • packages/protocol (shared WebSocket contracts)
  • infrastructure / .github/workflows
  • docs

Related issues

Closes #125

How to test

  1. Ensure the backend is running with a local postgres database (npm run db:migrate).
  2. Run npm run test --workspace=@docksight/server and verify that all host deletion tests pass.
  3. Start the server (npm run dev:server), open the Swagger UI at http://localhost:3000/api/docs, and verify the DELETE /hosts/:id endpoint is documented with the correct responses and requires an Admin Bearer token.

Checklist

  • Change is focused and stays within the existing modular monolith boundaries.
  • Ran the relevant checks locally (see below).
  • Updated docs under docs/ if module boundaries or the protocol changed.
  • Added an ADR under docs/decisions/ if this is a larger architectural change.
Local checks
# packages/protocol must be built first — apps/server and apps/web
# import it from its dist output.
npm run build --workspace=@docksight/protocol
npm run test  --workspace=@docksight/protocol

npm run build --workspace=@docksight/server
npm run lint  --workspace=@docksight/server
npm run test  --workspace=@docksight/server

npm run build --workspace=@docksight/web
npm run lint  --workspace=@docksight/web

Copilot AI lite review requested due to automatic review settings August 27, 2026 17:28

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@DrDead0

DrDead0 commented Aug 27, 2026

Copy link
Copy Markdown
Contributor Author

I have Added the feature according to the issue with no frontend changes

@DrDead0
DrDead0 requested a balanced review from Copilot August 27, 2026 17:33

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@rodriguecyber
rodriguecyber merged commit e74debb into Open-Source-Kigali:develop Aug 28, 2026
1 check passed
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.

[Backend] Delete hosts inactive for at least seven days

3 participants