Skip to main content
Scaffolds a middleware class and its test file into the target module, then registers the class in the middlewares array of the module. It writes modules/<module>/src/middlewares/<Name>Middleware.ts and modules/<module>/tests/middlewares/<Name>Middleware.spec.ts, and installs the @talosjs/middleware dependency if it is missing. Pass --is-socket to generate a WebSocket middleware instead of an HTTP one; if omitted, you are asked interactively.

Usage

talos middleware:create [options]

Examples

talos middleware:create
talos middleware:create --name=Auth --is-socket=false
talos middleware:create --name=RateLimit --module=api --is-socket=true

Options

OptionDescriptionDefault
--nameResource name (the Middleware suffix is appended automatically).Prompted if omitted
--moduleTarget module.shared
--is-socketGenerate a socket middleware instead of an HTTP one.Prompted if omitted
--overrideOverwrite an existing file without confirmation.false

AI Skill

This command ships a matching middleware:create skill. Your AI agent uses it to generate a new HTTP or WebSocket middleware class and its test file, then implement the handler logic for the IMiddleware interface from @talosjs/middleware.
talos claude:init