route

Update route handlers to delegate business logic to context classes.

169|19|Updated Apr 8, 2022
One-click install
npx skills add https://github.com/counterfact/api-simulator --skill route-counterfact
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: route
Source: https://github.com/counterfact/api-simulator/tree/main/skills/route
Command: npx skills add https://github.com/counterfact/api-simulator --skill route-counterfact

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Edit Counterfact route files to add endpoint behavior while keeping handlers thin and delegating business logic to context classes.

Core Features & Use Cases

  • Enforce the use of the $ API in every route handler (path, query, body, response, context, loadContext).
  • Keep route handlers thin and delegate business logic to a context class in an appropriate _.context.ts file.
  • Provide a consistent pattern for updating or adding route handlers across the routes/ directory.

Quick Start

Modify a route file under routes/ to delegate business logic to a context class and return the response through the $.response API.

Frequently Asked Questions about route

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I keep API route handlers thin and delegate business logic to context classes?▼

You can enforce thin route handlers by delegating business logic to context classes within _.context.ts files. This pattern uses the $ API for path, query, body, and response handling, ensuring route files remain lightweight and maintainable.

What is the $ API in Counterfact route files and how does it work?▼

The $ API provides path, query, body, response, context, and loadContext utilities for route handlers. It enforces a consistent pattern where route handlers remain thin while delegating business logic to context classes.

Can I use this route delegation pattern with JavaScript or only TypeScript APIs?▼

This route delegation pattern supports both TypeScript and JavaScript route definitions under the routes/ directory. It enforces consistent thin handler logic and context delegation across both languages.

What's the best way to organize API logic between route files and context classes?▼

The best way to organize API logic is keeping route handlers thin by handling request and response routing through the $ API, while delegating all business logic to dedicated context classes within _.context.ts files.

Why should I avoid unit tests when applying the route handler delegation pattern?▼

You should avoid unit tests when applying this route handler delegation pattern because this skill focuses exclusively on editing route files to enforce the $ API and context delegation. Testing delegated business logic belongs in the context class workflow.