rest-endpoint

Adds REST API endpoints to Express web controllers with auth decorators and tests.

Updated Apr 2, 2026
One-click install
npx skills add https://github.com/nico0695/ai-tools --skill rest-endpoint-nico0695
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: rest-endpoint
Source: https://github.com/nico0695/ai-tools/tree/main/projects/slack-bot/skills/rest-endpoint
Command: npx skills add https://github.com/nico0695/ai-tools --skill rest-endpoint-nico0695

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Adding new REST endpoints to the slack-bot project requires following strict conventions: decorator stacking order, input validation with BadRequestError, service error handling, route registration, and matching Jest test patterns. This Skill encodes all of those conventions so endpoints are implemented consistently every time. ## Core Features & Use Cases - Endpoint Templates: Ready-to-use patterns for GET list, GET by ID, POST, PUT, and DELETE endpoints with @HttpAuth and @Permission decorators in the correct order. - Validation & Error Handling: Standardized input validation throwing BadRequestError with Spanish messages, plus service response error checks before accessing data. - Route Registration & Testing: Guidance for registering routes in registerRoutes() and app.ts, plus Jest test patterns that mock auth decorators and services. - Use Case: When asked to add a new CRUD resource to the slack-bot API, generate the controller methods, wire up the routes, and produce matching unit tests in one pass. ## Quick Start Add a new REST endpoint to the slack-bot web controller following the project conventions for auth decorators, validation, and tests.

Frequently Asked Questions about rest-endpoint

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

FAQPage Schema
How do I add a REST endpoint to an Express controller in TypeScript?▼

Define an async method decorated with @HttpAuth above @Permission, validate input and throw BadRequestError on failure, call the service layer, check the response for errors, then send the data. Register the route in registerRoutes() and mount the controller router in app.ts.

How do I test Express controllers that use auth decorators in Jest?▼

Mock the auth middleware module with jest.mock, replacing HttpAuth and Permission with identity decorators that return the descriptor unchanged. Then mock the service singleton, set controller.userData directly, and assert that BadRequestError is thrown for invalid input or service errors.

What is the correct decorator order for authenticated Express routes?▼

Place @HttpAuth above @Permission. HttpAuth runs first to authenticate the request and inject userData, then Permission checks the user's profile against the allowed roles such as USER, USER_PREMIUM, and ADMIN.

Do decorated Express controller methods need .bind(this)?▼

Methods decorated with @HttpAuth do not need .bind(this) because the decorator wraps them and preserves the correct context. However, verify whether the project binds undecorated methods elsewhere before relying on this behavior.

How should Express controllers handle service layer errors?▼

Check the service response for an error property before accessing data. If response.error exists, throw a BadRequestError with that message; otherwise send response.data. This keeps error handling consistent across all endpoints.