node-typescript-service

node-typescript-service is a cursor rule for Cursor from vanessamarely/ai-playbook-reposito. It costs 0 tokens per session (914 once invoked), scanned A, original, MIT.

A set of rules for building Node.js and TypeScript microservice endpoints, including input checks, structured errors, logging, and tests.

In plain words
What is it for?
Use it to create or modify Express, Nest.js, or Fastify endpoints, validate requests with Zod, Joi, or class-validator, and add unit and integration tests.
Why use it?
It gives backend work a consistent path from request handling through validation and testing, reducing gaps in API behavior.

Cursor rule for Cursor

Written for Cursor: installed under .cursor/.

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add rules/vanessamarely/ai-playbook-reposito/node-typescript-service
Clone the repo
git clone --depth 1 https://github.com/vanessamarely/ai-playbook-reposito

Made for: Cursor.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for node-typescript-service

README.md
[![agentmods](https://agentmods.dev/badge/rules/vanessamarely/ai-playbook-reposito/node-typescript-service.svg)](https://agentmods.dev/rules/vanessamarely/ai-playbook-reposito/node-typescript-service)
Your own site
<a href="https://agentmods.dev/rules/vanessamarely/ai-playbook-reposito/node-typescript-service"><img src="https://agentmods.dev/badge/rules/vanessamarely/ai-playbook-reposito/node-typescript-service.svg" alt="Measured on agentmods" height="20"></a>
Per session 0 Nothing until a file matches its globs; then the whole rule loads.
When invoked 914 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00000 $0.00914
Opus 5 $0.00000 $0.00457
Sonnet 5 $0.00000 $0.00183
Haiku 4.5 $0.00000 $0.00091

Measured 5d ago against content hash 9242e84e5fcd, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-05, from the pricing page.

Security

Grade A, and why

node-typescript-service scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 5d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

ai-playbook/.cursor/rules/node-typescript-service.mdc · 80 lines

How it starts

The opening of the file, as written. The whole thing — 80 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Node.js/TypeScript Service

Create or modify Node.js/TypeScript backend services with proper validation, error handling, logging, and testing. Not for React frontend components, UI elements, or accessibility audits — see react-components / a11y-automation for those.

For a guided end-to-end build (handler + validation + tests + routing), run /node-microservice-builder.

Procedure

  1. Detect the framework from package.json dependencies: express → Express.js, @nestjs/core → Nest.js, fastify → Fastify. If unclear, ask for clarification.
  2. Follow the backend-policy rule for Node.js/TypeScript conventions (module system, logging, validation libraries).
  3. Define a request validation schema using the project's validation library (Zod, Joi, or class-validator for Nest.js):
    import { z } from 'zod'
    const CreateUserSchema = z.object({
      email: z.string().email(),
      name: z.string().min(1),
      age: z.number().int().positive().optional()
    })
    type CreateUserRequest = z.infer<typeof CreateUserSchema>
    
  4. Implement the route handler:
    • Express: parse/validate in the handler, delegate to a service, catch and forward errors.
      router.post('/users', async (req: Request, res: Response) => {
        try {
          const data = CreateUserSchema.parse(req.body)
          const user = await createUser(data)
          res.status(201).json({ success: true, data: user })
        } catch (error) {
          handleError(error, res)
        }
      })
      
    • Nest.js: controller class with decorators, DTO with validation decorators, constructor-injected service.
      @Controller('users')
      export class UsersController {
        constructor(private readonly usersService: UsersService) {}
        @Post()
        async create(@Body() createUserDto: CreateUserDto) {
          return this.usersService.create(createUserDto)
        }
      }
      
  5. Implement error handling — map errors to HTTP status codes (400 validation, 401 auth required, 403 forbidden, 404 not found, 409 conflict, 500 internal). Return structured error responses:
    { success: false, error: { code: 'VALIDATION_ERROR', message: 'Invalid input data', details: [...] } }
    
    Prefer a Result<T, E> discriminated union in the service layer over throwing across boundaries where the project already uses that pattern.
  6. Add structured logging (Winston, Pino, or the framework's logger) — never console.log in production code:
    logger.info('User created', { userId: user.id })
    logger.error('Database connection failed', { error })
    
  7. Keep business logic in the service layer, not the route handler:
    class UsersService {
      async create(data: CreateUserRequest): Promise<User> {
        const existing = await this.findByEmail(data.email)
        if (existing) throw new ConflictError('Email already registered')
        return this.repository.save(data)
      }
    }
    
  8. Generate tests adjacent to the handler — unit tests for the service in isolation, integration tests for the full HTTP request/response (e.g. with supertest), covering success and error cases.
  9. Register the endpoint in the project's routing configuration and verify there's no route conflict.
  10. Validate the implementation: validation applied, error handling comprehensive, responses consistently structured, logging captures relevant context, tests cover success and error paths. Suggest npm run lint, npm test, npm run build.

Read the full file on GitHub · 80 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 5d ago First seen · 80 lines · 0 tokens per session scan A 9242e84e5fcd

Subscribe to this mod's changes

node-typescript-service is a cursor rule published in the GitHub repository vanessamarely/ai-playbook-reposito (2 stars, last pushed 1mo ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 914 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.