create-routes

Wire controllers and middleware to HTTP routes with a DI-friendly router factory.

1|Updated May 21, 2025
One-click install
npx skills add https://github.com/madooei/backend-template --skill create-routes
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: create-routes
Source: https://github.com/madooei/backend-template/tree/main/.claude/skills/create-routes
Command: npx skills add https://github.com/madooei/backend-template --skill create-routes

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Wiring controllers and middleware to HTTP endpoints is error-prone and duplicative across services. This guide explains how a factory-based routing pattern helps you compose modular, testable API layers with clear dependency injection boundaries.

Core Features & Use Cases

  • Factory function pattern for dependency injection enabling mock testing and easy swapping of implementations
  • Global vs per-route middleware wiring for consistent security, validation, and logging
  • Simple mounting in app.ts with typed routes that preserve a clean separation of concerns

Quick Start

Call the factory function with concrete {Entity}Controller and your chosen middleware to mount routes.

Frequently Asked Questions about create-routes

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

FAQPage Schema
How do I wire controllers and middleware to HTTP routes with dependency injection?

Wire controllers and middleware to HTTP routes using a DI-friendly factory function pattern. This standardizes API wiring by injecting concrete controllers into the router factory, enabling mock testing and clean separation of concerns.

What is the factory function pattern for API routing?

The factory function pattern for API routing passes concrete controllers and middleware into a factory method to mount routes. It establishes clear dependency injection boundaries, making API layers modular, testable, and easy to swap implementations.

How do I set up global versus per-route middleware in TypeScript?

Set up global versus per-route middleware in TypeScript by passing middleware arrays to the router factory. Apply global middleware for consistent security and logging, while attaching per-route middleware for specific validation requirements.

Does this routing pattern work with Hono and TypeScript for RESTful services?

Yes, this routing pattern works with Hono and TypeScript for RESTful services. It satisfies typed route definitions and dependency injection requirements, allowing you to mount modular route setups directly in your app entry point.

Why use dependency injection for HTTP route wiring?

Use dependency injection for HTTP route wiring to eliminate duplicative and error-prone API setups. Injecting controllers via a factory function enables mock testing, easy swapping of implementations, and preserves a clean separation of concerns.

What's the best way to structure modular route setups in a TypeScript API?

The best way to structure modular route setups in a TypeScript API is using a factory-based routing pattern. Mount typed routes in your app file by calling the factory with concrete controllers, ensuring testable API layers with clear boundaries.