Add Adminapi Endpoint
Developmentadd-adminapi-endpointAdd Adminapi Endpoint is an Agent Skill for development published in the talkincode/toughradius repository on GitHub: a SKILL.md instruction file an AI agent can load to do this task.
Add a group of Admin REST endpoints in the management backend (TR-F012). Use when a feature needs management APIs such as create/read/update/delete.
QUICK START
How to use this skill
Bring this guide into your coding agent with a prompt tailored to the tool you use.
- Open your project in Codex.
- Copy and paste the prompt below.
- Review files and risks before approving any action.
Prompt to paste
Inspect the Agent Skill at https://github.com/talkincode/toughradius/blob/HEAD/.agents/skills/add-adminapi-endpoint/SKILL.md and all supporting files. Report provenance, permissions, scripts, dependencies, and security risks. Propose an exact installation into .agents/skills/add-adminapi-endpoint, but wait for my approval before writing files or running scripts.
Copying this prompt does not install or run the skill. Review third-party files before use.
Skill: Add Admin REST Endpoints
Feature ID:
TR-F012| Milestone: M2 and others
When to use
When adding a group of REST endpoints to the management backend.
Pre-research
view internal/adminapi/adminapi.go # Init() registration entry
view internal/adminapi/nodes.go # standard CRUD reference
view internal/adminapi/helpers.go # parsePagination / filter helpers
view internal/adminapi/responses.go # unified responses
view internal/adminapi/authz.go # requireAdmin() and other authz
Implementation steps
- New file
internal/adminapi/<feature>.go, packageadminapi. - Request structs: define the payload with
validatetags (referencenodePayload). - register function:
func register<Feature>Routes() { webserver.ApiGET("/<path>", list<Feature>) webserver.ApiPOST("/<path>", create<Feature>, requireAdmin()) webserver.ApiPUT("/<path>/:id", update<Feature>, requireAdmin()) webserver.ApiDELETE("/<path>/:id", delete<Feature>, requireAdmin()) } - Register in Init: add
register<Feature>Routes()toInit()inadminapi.go. - Data access: always use
app.GDB(); never inject*gorm.DB. - Shared conventions: reuse pagination, filtering, validation, authz, unified responses, and error handling.
Acceptance
- Add
<feature>_test.gocovering CRUD and authz failure -
go test ./internal/adminapi/...passes -
golangci-lint runpasses - If the frontend is involved, pair with
../add-react-admin-resource/SKILL.md - PR references
TR-F012and the milestone ID