Skip to content
Agentmart
Submit a tool

backend-router

Skill by davidleonmayor

IndexedMIT★ 3
Write a review

Chalk Labs

Need help deploying backend-router?

Chalk Labs sets up agents like this inside real teams: connected to your tools, tested on your data, with a human in the loop where it matters.

Book a call

Install

Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.

npx agentmarket install skill/davidleonmayor-backend-router

Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.

Get the weekly diff

The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.

We use your email only for this newsletter. Privacy

About

The publisher has not written a description yet.

Use cases: backend

No reviews yet. Installed it? Reviews come from verified installers only. How reviews work

Permissions: not checked yet.

What's inside

Skill name
backend-router
Description
None
License
MIT
Instructions
112 lines in SKILL.md · view on GitHub

Agent Skills spec issues

  • missing YAML frontmatter
  • name: missing
  • description: missing

Files (1)

  • SKILL.md

SKILL.md (first lines)

# Backend Router (Express.js)

## Overview

This skill defines the convention for declaring Express.js routers using an Object-Oriented approach.

## Trigger

When creating or updating route definitions for a backend feature.

## Do's

- **Use Classes**: Define routes inside a class (e.g., `FeatureRoutes`).
- **Encapsulate Router**: Expose a `public router: Router` property initialized in the constructor with `Router()`.
- **Instantiate Dependencies**: Initialize the respective `Controller` and any specific `Middleware` inside the constructor.
- **`initRoutes()` Method**: Bind all routes in a dedicated `initRoutes()` method called from the constructor.
- **Middleware Execution Order**: ALWAYS place `validateSchema` as the FIRST middleware in the route chain, BEFORE `isAuthenticatedUser`, `isConfirmed`, or any role checks. This ensures the payload and headers (like the authorization token) are structurally valid before running auth queries.
- **Controller Binding**: Pass the controller method reference directly (e.g., `this.controller.methodName`). Ensure the controller constructor binds its methods (`this.methodName = this.methodName.bind(this)`).

## Don'ts

- **Don't use inline `.bind()` in the router**: Never do `this.controller.create.bind(this.controller)` inside the router definition. The router should look extremely clean (see Example Structure). Method binding MUST happen inside the Controller's constructor.
- **Don't use functional routers**: Avoid top-level `const router = Router(); export default router;`. Stick to the Class structure.
- **Don't define inline route handlers**: Do not put business or response logic directly in the `.post()` or `.get()` callback. Always delegate to the Controller.
- **Don't mix schema logic in the router**: Validation schemas must be imported from the respective `*.schema.ts` file.

## Example Structure

- Always validate input data first with validateSchema() to prevent the passage of malformed or malicious data.
- If necessary, then use the authentication and/or user role middleware; the authentication middleware should come first, followed by the user role.
- Finally goes the controller to manage only the busines logic

```typescript
import { Router } from "express";
import { FeatureController } from "./feature.controller";
import { validateSchema } from "../common/middleware/validateSchema";
import { AuthMiddleware } from "../common/middleware/AuthMiddleware";
import { CreateFeatureSchema } from "./feature.schema";

export class FeatureRoutes {
  public router: Router;
  private controller: FeatureController;
  private authMiddleware: AuthMiddleware;

  constructor() {
    this.router = Router();
    this.controller = new FeatureController();
    this.authMiddleware = new AuthMiddleware();
    this.initRoutes();
  }

  initRoutes() {
    this.router.post(
      "/",
      validateSchema(CreateFeatureSchema),
      this.controller.create,
    );

    this.router.get(
      "/",
      validateSchema(CreateFeatureSchema),
      this.authMiddleware.isAuthenticatedUser,
      this.authMiddleware.isConfirmed,
      this.controller.getAll,
    );
  }
}
```

## Don't do

- don't

```typescript
import { Router } from "express";
import { FeatureController } from "./feature.controller";
import { validateSchema } from "../common/middleware/validateSchema";
import { AuthMiddleware } from "../common/middleware/AuthMiddleware";
import { CreateFeatureSchema } from "./feature.schema";

export class FeatureRoutes {
  public router: Router;
  private controller: FeatureController;
  private authMiddleware: AuthMiddleware;

  constructor() {
    this.router = Router();
    this.controller = new FeatureController();
    this.authMiddleware = new AuthMiddleware();
    this.initRoutes();
  }

  // don't use validateSchema before enyting, Alwais validale schema goes first
  initRoutes() {
    this.router.post(
      "/",
      this.controller.create,
      validateSchema(CreateFeatureSchema),
    );

    // don't use, Allwais goes auth middlewares after validate schema
    this.router.get(
      "/",
      validateSchema(CreateFeatureSchema),
      this.controller.getAll,
      this.authMiddleware.isAuthenticatedUser,
      this.authMiddleware.isConfirmed,
    );
  }
}
```

From davidleonmayor/proyecto-grado-unimayor, MIT.

Signals

Stars
3
Forks
0
Open issues
1
Last commit (this folder)
May 2, 2026 (6 months ago)

From GitHub (fetched Oct 24, 2026).

Details

License
MIT
First seen
Oct 24, 2026
Last checked
Oct 24, 2026

More from davidleonmayor

Done for you

Rather not set it up yourself?

Chalk Labs scopes, builds and runs agents for your team: the task audit, the eval harness, the integrations and the weekly ops report. Fixed scope, priced before we start.

See how we build AI agents →Read the case studies

Chalk Labs is a two-founder AI and growth studio. We build AI agents, CRMs and MVPs for Web3 and AI companies, and have shipped 50+ product and token launches.

launches shipped
50+
launches shipped
media placements
500+
media placements
founders on every account
2
founders on every account

Press we've placed: Forbes · CoinDesk · Decrypt · Cointelegraph · The Block

Rahil Jain, Co-founder, Chalk Labs. Ex-Goldman Sachs engineer. You talk to the person who builds it.

Get backend-router running in your business

Tell us what you want to automate. A founder replies within one working day with a plan, not a pitch deck.

Goes to the Chalk Labs founders, not the newsletter. Privacy

Need help deploying backend-router?

CallGet help
Cite this page

backend-router skill. Agent Mart. https://agentmart.dev/skills/davidleonmayor-backend-router (last updated 2026-10-24)