stacks-routes

Define and organize route files in a Stacks application via app/Routes.ts registry.

622|17|Updated Apr 26, 2022
One-click install
npx skills add https://github.com/stacksjs/stacks --skill stacks-routes
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: stacks-routes
Source: https://github.com/stacksjs/stacks/tree/main/.claude/skills/stacks-routes
Command: npx skills add https://github.com/stacksjs/stacks --skill stacks-routes

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Defines and organizes route files and their registrations in a Stacks application, ensuring routes are discovered, loaded, and managed from a central registry.

Core Features & Use Cases

  • Route Registry & Prefixing: Maps route files to URL prefixes via an app/Routes.ts registry, enabling clean, scalable routing.
  • Route File Creation & Grouping: Define routes in routes/ with inline handlers or controllers, and group them with shared middleware for consistency.
  • Versioned & Health Routes: Support for versioned route modules (e.g., routes/v1.ts) and automatic health checks for observability.
  • Best Practices: Ensure route files are registered in app/Routes.ts to be loaded by the router system.

Quick Start

Create a new API route file under routes/api.ts and register it in app/Routes.ts to begin defining endpoints.

Frequently Asked Questions about stacks-routes

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

FAQPage Schema
How do I organize route files and registrations in a Stacks application?▼

To organize Stacks routes, you define route files in the routes/ directory and map them to URL prefixes via a central app/Routes.ts registry. This registry-driven structure ensures routes are discovered, loaded, and managed cleanly for projects of any size.

What is the best way to group routes with shared middleware in Stacks?▼

The best way to group Stacks routes with shared middleware is by defining them in route files under routes/ and using the registry's grouping capabilities. This ensures consistency across endpoints and scales cleanly for applications of any size.

Does Stacks support versioned API routes?▼

Yes, Stacks supports versioned API routes by allowing you to define versioned route modules, such as routes/v1.ts. These modules are then registered in the central app/Routes.ts registry to be properly loaded and managed by the routing system.

Why are my Stacks route files not being loaded by the router?▼

Stacks route files are not loaded if they are not registered in the central app/Routes.ts registry. You must ensure every route file created under the routes/ directory is explicitly mapped in this registry for the router system to discover and load it.

Can I use inline handlers instead of controllers for my routes?▼

Yes, you can use inline handlers instead of controllers for your routes. When defining routes in the routes/ directory, Stacks allows you to specify either inline handlers for quick endpoints or controllers for more structured logic before registering them.

How do I add automatic health check routes in Stacks?▼

To add automatic health check routes in Stacks, you leverage the built-in support for observability within the routing system. By organizing your route files and registering them in app/Routes.ts, automatic health checks are supported for monitoring endpoint availability.