routes

Define and register HTTP routes and middleware for REST API endpoints.

Updated Apr 16, 2025
One-click install
npx skills add https://github.com/teexiii/boilerplate-rest-bun-for-noob --skill routes-teexiii
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: routes
Source: https://github.com/teexiii/boilerplate-rest-bun-for-noob/tree/main/.agent/skills/routes
Command: npx skills add https://github.com/teexiii/boilerplate-rest-bun-for-noob --skill routes-teexiii

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This guide standardizes how HTTP routes are defined, ordered, and protected so API endpoints behave predictably and securely across the codebase, preventing route collisions and inconsistent access control.

Core Features & Use Cases

  • Clear route file naming and export conventions to simplify registration and discovery.
  • Middleware stacking patterns and examples for authentication, role checks, optional auth, and signature verification.
  • Parameter and nested-resource syntax guidance plus a strict rule requiring both :id and /code/:code route variants for entities with a code field to support short-shareable identifiers.
  • Route ordering strategy to ensure specific routes are matched before generic patterns and a central index that aggregates routes in the correct order.

Quick Start

Create a new [entity]Routes file following the naming convention, register it in routes/index.ts placing specific routes before generic ones, and add both :id and /code/:code variants when the entity has a code field.

Frequently Asked Questions about routes

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

FAQPage Schema
How do I organize REST API routes to prevent route collisions and inconsistent access control?

To prevent REST API route collisions, standardize HTTP route file naming conventions and register them in a central index, placing specific routes before generic patterns to ensure correct matching and predictable access control.

What is the best way to stack middleware for authentication and role checks in a REST API?

The best way to stack middleware is to apply layered patterns for authentication, role checks, optional auth, and signature verification directly within your route definitions to enforce secure, code-based access control.

How do I support both :id and /code/:code parameter variants for nested resources?

To support both parameter variants for nested resources, enforce a strict rule requiring both :id and /code/:code route definitions for any entity with a code field, enabling short-shareable identifiers in your REST API.

Why does route ordering matter when registering HTTP endpoints in a central index?

Route ordering matters because specific HTTP endpoints must be matched before generic patterns in the central index, preventing unintended route collisions and ensuring requests hit the correct REST API handler.

Do I need specific file naming conventions to manage API route discovery and registration?

Yes, you need clear route file naming and export conventions to simplify registration and discovery, requiring an ordered aggregation in a central index file to maintain predictable REST API behavior across the codebase.