axiosleo/node-koapp/koapp-controller
Claude Code and agent skill by axiosleo/node-koapp
- community
Checking that the SKILL.md file is still in the repository.
Organize route handlers into reusable classes by extending the @axiosleo/koapp Controller base class. Use when grouping related handlers, reusing response helpers (this.success/failed/result/response/error/log), sharing state across handlers, or scaffolding service modules for a koapp project.
Install
npx vskill@latest install axiosleo/node-koapp/koapp-controllerSKILL.md
@axiosleo/koapp Controller
Source: `src/controller.js`.
Controller is a thin base class that mirrors the response helpers as instance methods. Extend it to keep related handlers together and share auxiliary state.
Import
Instance API
| Method | Equivalent function | Notes | |
|---|---|---|---|
this.success(data?, headers?) | success(data, headers) | 200 OK JSON envelope | |
this.failed(data?, code?, status?, headers?) | failed(data, code, status, headers) | Non-2xx JSON envelope | |
this.result(data, status?, headers?) | result(data, status, headers) | Raw body pass-through | |
this.response(data, code, status?, headers?) | response(data, code, status, headers) | Full control envelope | |
this.error(status, msg, headers?) | error(status, msg, headers) | Shortcut error envelope | |
this.log(...data) | debug.log from @axiosleo/cli-tool | Conditional logging |
All this.success / failed / result / response / error throw, same as the functional helpers. See koapp-response for envelope details.
Basic usage
Why use Controller over plain functions?
- Shared state: load DB handles, caches, or config once in the
constructor and reuse across methods.
- Inheritance: define a
BaseControllerwith common middlewares or
helpers, then extend it per module (the init scaffolding template at `assets/monorepo/apps/services/src/modules/controller.ts.tmpl` does this).
- Testability: easier to mock a controller instance than free-floating
functions.
Binding handlers to routes
Controller methods expect a context argument and may use this, so bind them explicitly when registering with the router:
Pure wrappers (ctx) => controller.method(ctx) preserve this and avoid .bind clutter.
Error handling
Since this.success / failed / ... throw, any code after them does not run. The workflow catches the throw and writes the response. Keep try / catch only where you intend to shape a different error:
Logging
this.log is wired to debug.log from @axiosleo/cli-tool. Enable it by running with DEBUG=1 (or the cli-tool equivalent), or by setting debug: true on the application.
Composing with validators
Validation stays on the router:
The validator runs before the handler, so by the time controller.create executes you already have a validated context.body.
Scaffold output
There is no code generator; modules are written by hand following the layout produced by npx @axiosleo/koapp init <name> (monorepo template). It ships a project-local BaseController at apps/services/src/modules/controller.ts that extends Controller and adds request-scoped helpers (the template source is `assets/monorepo/apps/services/src/modules/controller.ts.tmpl`):
Each business module then follows the three-file convention src/modules/<name>/<name>.router.ts + <name>.controller.ts + <name>.model.ts, where the controller extends BaseController and is exported as a singleton bound to routes with arrow wrappers:
Common pitfalls
- Forgetting to pass
contextinto instance methods:router.get('/x', controller.handler)losesthiswhen the router calls the method as a free function. Use arrow wrappers. - Returning
this.success(...)from a handler is redundant - the throw short-circuits execution. - Controllers are long-lived across requests; never stash per-request data on
this. Usecontextor local variables instead.
See also
- Response helper details: koapp-response
- Grouping controllers under a router tree: koapp-router
- Concrete controller recipes: examples.md
Security
- Security scanPassed, 95 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingassets/skills/koapp-controller/SKILL.md
Popularity
- Repository stars
- 44
- Repository forks
- 11
- Repository npm downloads, 7 days
- 548
- 7-day trend score
- 34
Stars and forks are for the whole GitHub repository, not this skill alone. Downloads are for the repository's npm package. Refreshed 1 Aug 2026, 3 months ago.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/axiosleo/node-koapp/koapp-controller)