blockend
Blockend
Source-First Backend Toolkit

Production backend code blocks, generated into your project.

Rate limiting, validation, logging, and error handling — generated as pure TypeScript files you read, edit, and own.

$npx blockend-cli add rate-limiter
src/blocks/rate-limiter.ts
Zero Runtime Dep100% Strict TypeScript
// GENERATED FILE: src/blocks/rate-limiter.ts
// Owned by your repository. Zero black-box wrapper dependencies.

import { Request, Response, NextFunction } from 'express';

export interface RateLimitOptions {
  windowMs: number;
  maxRequests: number;
}

export function createRateLimiter(options: RateLimitOptions) {
  const hits = new Map<string, { count: number; resetTime: number }>();

  return (req: Request, res: Response, next: NextFunction) => {
    const ip = req.ip || '127.0.0.1';
    const now = Date.now();
    const record = hits.get(ip) || { count: 0, resetTime: now + options.windowMs };

    if (now > record.resetTime) {
      record.count = 0;
      record.resetTime = now + options.windowMs;
    }

    record.count++;
    hits.set(ip, record);

    if (record.count > options.maxRequests) {
      return res.status(429).json({ error: 'Too Many Requests' });
    }

    next();
  };
}

Designed for backend teams building modern TypeScript services.

Compatible with Express, Fastify, Hono, and Next.js backend layers.

Essential OnlyNPM Dependencies
100%Source Owned
The Problem

Stop relying on black-box middleware dependencies.

  • Boilerplate Redundancy

    Every new backend microservice requires rewriting rate limiting, error classes, loggers, and header parsers from scratch.

  • Node_Modules Lock-in

    Key infrastructure logic ends up buried inside deeply nested external packages, making minor tweaks impossible.

  • Opaque Stack Traces

    Production failures force developers to step through foreign package code rather than inspecting clean local files.

  • Inconsistent Conventions

    Different developers implement error handling and logging differently, fragmenting the architecture across teams.

Workflow

Three commands to clean, native backend blocks.

  1. 01
    Initialize Blockend in your repository.

    Configure your target backend framework (Express, Fastify, Hono, Next.js) and custom block output path.

    $npx blockend-cli init
  2. 02
    Add production blocks on demand.

    Blockend fetches the block template and generates idiomatic TypeScript source files tailored to your framework.

    $npx blockend-cli add rate-limiter
  3. 03
    Commit code directly to Git.

    Read, audit, and customize the generated files inside your project. The code belongs entirely to you.

    $git add src/blocks/
Output Structure

Real TypeScript files in your workspace.

Blockend generates clear, commented TypeScript files inside your project structure. Every file includes framework adapters, strict types, and usage examples.

  • Pragmatic Dependencies: Imports external packages only for security-critical tasks (JWT, Zod).
  • Framework Native: Emits typed handlers for Express, Fastify, Hono, & Next.js.
  • Fully Editable: Rename options, modify algorithms, or adjust log shapes instantly.
Workspace File Tree
Project Root
my-backend-service/
src/
blocks/Generated Source
  • rate-limiter.ts2.1 KB
  • error-handler.ts1.8 KB
  • logger.ts1.4 KB
  • request-validator.ts2.8 KB
server.ts
package.json
System Properties

Engineered for code ownership and maintainability.

  • Complete Source Ownership

    You own every generated block. Tweak logic, rename variables, or extend algorithms directly inside your codebase.

  • Framework Awareness

    Generates native request contexts and middleware signatures for Express, Fastify, Hono, and Next.js.

  • Pragmatic Dependency Tree

    Uses npm dependencies exclusively for non-negotiable security tasks like JWT verification or schema validation.

  • Strict Type Safety

    Written with strict TypeScript type definitions, generic parameters, and explicit return types.

  • High Code Legibility

    Cleanly formatted, idiomatic code designed for fast code reviews and immediate developer comprehension.

  • Production Defaults

    Pre-configured with industry standard defaults for security headers, graceful termination, and structured logs.

Catalog

Production blocks ready for generation.

  • rate-limiter
    HTTP

    Token bucket rate limiting with in-memory or storage adapter options.

    blockend-cli add rate-limiter
  • error-handler
    Errors

    Centralized error normalization pipeline with custom exception classes.

    blockend-cli add error-handler
  • logger
    Observability

    Structured JSON request logging with correlation ID propagation.

    blockend-cli add logger
  • request-validator
    Validation

    Zod-based body and query validation middleware adapter.

    blockend-cli add request-validator
  • response-formatter
    Response

    Standardized API success and error envelope payloads.

    blockend-cli add response-formatter
  • health-check
    Ops

    Liveness and readiness health probe handlers.

    blockend-cli add health-check
  • env-config
    Config

    Type-safe environment variable parser and validator with Zod schemas.

    blockend-cli add env-config
Ecosystem
Native support across HTTP frameworks.

Blockend tailors type definitions and middleware patterns for your preferred stack.

  • Express
  • Fastify
  • Hono
  • Next.js API
Model Context Protocol

Scaffold your infrastructure with natural language.

Blockend includes an MCP server. AI assistants (Cursor, Claude, Windsurf) can query the block catalog, inspect signatures, and generate middleware stacks directly into your repository.

  • Discover Blocks: Live catalog capability discovery for AI.
  • Accurate Generation: Eliminates AI import hallucinations.
  • Automated Adapters: Automatic framework detection.
MCP Agent Session
Cursor / Claude Desktop
"Add rate limiting to my Hono API with custom 429 status code."

Executing Tool: blockend_add_block

Target detected: Hono framework

Generated: src/blocks/rate-limiter.ts

Context: Typed middleware registered

Roadmap

Roadmap & Vision

Now

Core Blocks

Validation, errors, logging, health, shutdown, and response formatting.

Next

Framework Coverage

Refine adapters for Express, Fastify, and Hono.

Next

Security Blocks

JWT, password hashing, CORS, headers, idempotency, and env config.

Later

Starter Kits

SaaS and API starters built from Blockend blocks.

Blockend generates source-first backend code directly into your repository, so you own, inspect, and extend every block.

manifesto // architectural_design

Frontend figured this out years ago.

shadcn/ui proved that developers don't want another dependency—they want raw source control in their own repository to wrap their custom business logic around. Backend infrastructure deserves the exact same approach. No locked black boxes.

  • layer directive
    Read it

    No compiled output to trust blindly. The implementation is sitting right there in your editor.

  • layer directive
    Debug it

    Stack traces point into your own files, not three layers deep in node_modules.

  • layer directive
    Outgrow it

    Refactor or rip it out whenever your architecture changes. Nothing else in your stack depends on it.

FAQ

Frequently Asked Questions

Own your backend code.

Generate your first block in seconds and experience pure source code ownership.

$npx blockend-cli init
;