Skip to content

[server] remove /admin prefix#5

Merged
capcom6 merged 1 commit into
masterfrom
server/remove-admin-prefix
Apr 14, 2026
Merged

[server] remove /admin prefix#5
capcom6 merged 1 commit into
masterfrom
server/remove-admin-prefix

Conversation

@capcom6
Copy link
Copy Markdown
Contributor

@capcom6 capcom6 commented Apr 14, 2026

Summary by CodeRabbit

  • Bug Fixes

    • Relocated user management endpoints from /admin/users to /users path for improved API organization.
  • Documentation

    • Updated API documentation and request examples to reflect endpoint path changes.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 14, 2026

📝 Walkthrough

Walkthrough

The PR refactors the user management API by relocating endpoints from /admin/users to /users and renaming DTOs to remove admin-specific naming conventions. Module wiring, Swagger documentation, HTTP handlers, and test endpoints are updated consistently to reflect this structural change.

Changes

Cohort / File(s) Summary
API Documentation & Test Endpoints
internal/server/docs/docs.go, requests.http
Updated Swagger paths from /admin/users to /users with schema definitions renamed from UserResponse/UserListResponse to GetResponse/ListResponse. Updated corresponding HTTP test requests to use new endpoint paths.
DTO Definitions
internal/server/users/dto.go
Renamed DTOs: AdminUserFilterListFilter, UpdateUserRequestUpdateRequest, UserResponseGetResponse, UserListResponseListResponse. Updated associated helper functions defaultAdminUserFilter()defaultListFilter() and toUserResponse()toGetResponse().
Handler Logic & Routing
internal/server/users/handler.go
Changed user endpoint routes from /admin/users to /users. Updated handler method references to use renamed DTOs and conversion functions throughout list and update operations.
Module Wiring
internal/server/module.go
Replaced import from internal/server/admin/users to internal/server/users and updated fx.Provide instantiation to reference the new package location.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • [users] add module #2: Main PR that refactors admin user handlers, DTOs, and module wiring—directly overlaps with the same endpoints, schemas, and dependency injection patterns being modified.

Suggested labels

codex

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately and concisely describes the primary change: removing the /admin prefix from user endpoints throughout the codebase.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot added the codex label Apr 14, 2026
@github-actions
Copy link
Copy Markdown

🤖 Pull request artifacts

Platform File
🐳 Docker GitHub Container Registry
🍎 Darwin arm64 backend_Darwin_arm64.tar.gz
🍎 Darwin x86_64 backend_Darwin_x86_64.tar.gz
🐧 Linux arm64 backend_Linux_arm64.tar.gz
🐧 Linux i386 backend_Linux_i386.tar.gz
🐧 Linux x86_64 backend_Linux_x86_64.tar.gz
🪟 Windows arm64 backend_Windows_arm64.zip
🪟 Windows i386 backend_Windows_i386.zip
🪟 Windows x86_64 backend_Windows_x86_64.zip

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (2)
internal/server/users/dto.go (1)

31-34: Use a method-agnostic response name and fix the stale comment.

GetResponse is now the shared payload for both list and update flows, so the name reads narrower than the actual contract, and Line 60 still refers to the removed UserResponse type. A neutral name like Response or UserResponse would make this easier to follow.

Also applies to: 60-61

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@internal/server/users/dto.go` around lines 31 - 34, Rename the GetResponse
struct to a neutral name (e.g., UserResponse or Response) and update its doc
comment to reflect that it is the shared payload for list and update flows
(remove "Get" phrasing and stale reference to UserResponse). Update any
remaining references/comments that mention the removed UserResponse type
(notably the text around lines 60-61) to the new name so the comment and typedef
are consistent (search for GetResponse and the old UserResponse text and replace
accordingly).
requests.http (1)

81-108: Avoid fixed user IDs in the runnable examples.

Line 82, Line 92, and Line 102 depend on IDs 2, 3, and 4, which are not stable across environments. These examples will 404 on a clean database unless the fixture order happens to match. Prefer captured IDs or explicit placeholders so requests.http stays replayable.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@requests.http` around lines 81 - 108, The examples in requests.http use
hard-coded user IDs (PATCH {{baseURL}}/users/2, /users/3, /users/4) which will
404 in fresh environments; replace those fixed IDs with reusable placeholders or
captured variables (for example {{pendingUserId}}, {{blockedUserId}},
{{adminUserId}}) or add preceding create-user requests that extract and set the
ID into those variables so the PATCH examples are replayable; update the three
PATCH request lines and any JSON comments to reference the new placeholders.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@internal/server/users/handler.go`:
- Around line 35-46: The route change in Handler.Register replaced the public
path (/admin/users → /users) breaking existing clients; restore compatibility by
also registering the legacy path (or versioned path) alongside the new one:
update Register to create an additional route group that uses the same
middleware chain (h.errorsHandler, jwtauth.WithRole(users.RoleAdmin)) and binds
the same handlers (h.handleList and validation.DecorateWithBodyEx(h.Validator,
h.handleUpdate)) to the legacy endpoints (e.g., "/admin/users" or
"/api/v1/admin/users") so both old and new paths resolve to the same handler
functions.

---

Nitpick comments:
In `@internal/server/users/dto.go`:
- Around line 31-34: Rename the GetResponse struct to a neutral name (e.g.,
UserResponse or Response) and update its doc comment to reflect that it is the
shared payload for list and update flows (remove "Get" phrasing and stale
reference to UserResponse). Update any remaining references/comments that
mention the removed UserResponse type (notably the text around lines 60-61) to
the new name so the comment and typedef are consistent (search for GetResponse
and the old UserResponse text and replace accordingly).

In `@requests.http`:
- Around line 81-108: The examples in requests.http use hard-coded user IDs
(PATCH {{baseURL}}/users/2, /users/3, /users/4) which will 404 in fresh
environments; replace those fixed IDs with reusable placeholders or captured
variables (for example {{pendingUserId}}, {{blockedUserId}}, {{adminUserId}}) or
add preceding create-user requests that extract and set the ID into those
variables so the PATCH examples are replayable; update the three PATCH request
lines and any JSON comments to reference the new placeholders.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 9b1654e9-5f99-46d4-9946-814f84229a97

📥 Commits

Reviewing files that changed from the base of the PR and between 80fc4e5 and 0c88e73.

📒 Files selected for processing (5)
  • internal/server/docs/docs.go
  • internal/server/module.go
  • internal/server/users/dto.go
  • internal/server/users/handler.go
  • requests.http

Comment thread internal/server/users/handler.go
@capcom6 capcom6 merged commit 708ce3c into master Apr 14, 2026
7 checks passed
@capcom6 capcom6 deleted the server/remove-admin-prefix branch April 14, 2026 07:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant