| name | route |
| description | Edit Counterfact route files to add endpoint behavior while keeping handlers thin and delegating business logic to context classes.
|
| applyTo | ["**/routes/**/*.{ts,js}"] |
Route Skill
Purpose
Implement or update route behavior in generated route files.
Required rules
- Use the
$ API in every handler ($.path, $.query, $.body, $.response,
$.context, $.loadContext).
- Route handlers must stay thin.
- Business logic must be delegated to a context class in an appropriate
_.context.ts file.
- Do not create unit tests in this skill; routes are HTTP adapters and
behavior should be validated through context tests and black-box/integration
flows when available.
Step-by-step
- Open the target file under
routes/ (e.g. routes/pet/{petId}.ts).
- Read input using
$ ($.path, $.query, $.body).
- Call a context method for logic/state changes.
- Return a response using
$.response[status].
- If needed, add new context methods instead of embedding logic in the route.
Pattern
export const POST: HTTP_POST = ($) => {
const created = $.context.createThing($.body);
return $.response[201].json(created);
};
References