Skip to content

Auth Middleware Module

Composable authentication middleware module with pluggable providers. Ships with reference implementations for JWT, Clerk, Auth0, Supabase, and API key validation. The provider registry pattern makes it trivial to add custom auth strategies. Middleware is compatible with both Hono and Express request handlers.

Namemodule-auth-ts
Version0.1.0
Categorycomposable-modules
LicenseApache-2.0
Personaengineering
Tagsauth, middleware, jwt, typescript, security
Sourcetemplates/module-auth-ts

Render it

Three front doors, one catalog. Pick whichever suits the caller.

# CLI
npx @nanohype/sdk render module-auth-ts --out ./my-app

# SDK
import { LocalSource, renderTemplate } from "@nanohype/sdk";
const result = await renderTemplate(source, "module-auth-ts", variables);

# MCP — from an agent
get_template({ name: "module-auth-ts" })

Prerequisites

ToolVersionWhy
node>=22Node.js runtime for the auth module

Variables

Required

ProjectName string
Kebab-case project name, used as package name and directory Must be lowercase kebab-case starting with a letter.

Optional

Description string — defaults to Composable authentication middleware with pluggable providers
Short project description for package.json and README
AuthProvider string — defaults to jwt
Default auth provider to use (jwt, clerk, auth0, supabase, apikey, or a custom name)

What it produces

27 files. Placeholder names such as __APP_NAME__ are what the renderer substitutes into.

.env.example
.gitignore
biome.json
package.json
README.md
src/auth/__tests__/error-paths.test.ts
src/auth/__tests__/guards.test.ts
src/auth/__tests__/jwt.test.ts
src/auth/__tests__/registry.test.ts
src/auth/bootstrap.ts
src/auth/guards.ts
src/auth/index.ts
src/auth/middleware.ts
src/auth/providers/apikey.ts
src/auth/providers/auth0.ts
src/auth/providers/clerk.ts
src/auth/providers/index.ts
src/auth/providers/jwt.ts
src/auth/providers/mock.ts
src/auth/providers/registry.ts
src/auth/providers/supabase.ts
src/auth/providers/types.ts
src/auth/resilience/__tests__/circuit-breaker.test.ts
src/auth/resilience/circuit-breaker.ts
src/auth/types.ts
tsconfig.json
vitest.config.ts

Composes with

Composites that use it

  • AI Chatbot — Full-stack AI chatbot with agentic loop, HTTP service, authentication, evaluation harness, and deployment..
  • AI Platform — Full AI platform with HTTP service, LLM gateway, vector store, data pipeline, auth, billing, and monitoring.
  • AI Web Application — Full-stack web application with Next.js frontend, RAG pipeline, authentication, database, and deployment..
  • Document Intelligence — Document search and question-answering system with RAG pipeline, HTTP service, file storage, database, and deployment..
  • Enterprise AI Infrastructure — Full enterprise AI stack with agents, tool servers, safety guardrails, evaluation, prompt management, observability, and Kubernetes deployment..
  • Multi-Agent System — Multi-agent architecture with A2A protocol peers, MCP tool servers, and an orchestrating agent.
  • Product Launch — Full product launch kit spanning engineering, design, QA, product, marketing, and operations.
  • Production API Service — Production-grade TypeScript API service with auth, database, caching, rate limiting, background jobs, observability, and deployment..
  • RAG-Powered Agent — AI agent that uses retrieval-augmented generation as a tool.