For the complete documentation index, see llms.txt. This page is also available as Markdown.

Soap Express

This page and the plugin itself are still in development, a lot will change.

@soapjs/soap-express is the HTTP layer for SoapJS on Express — controllers, routing, middleware, auth guards, and CQRS wiring — assembled with a single bootstrap() call.

Current version: 0.3.x. Requires @soapjs/soap ≥ 0.10.

Install

npm install @soapjs/soap @soapjs/soap-express reflect-metadata express

Bootstrap

bootstrap() wires Express, middleware, routing, auth and CQRS in one call:

import 'reflect-metadata';
import { bootstrap } from '@soapjs/soap-express';

const app = await bootstrap({
  port: 3000,
  container,                 // your pre-wired DIContainer
  controllers: [CharactersController, AuthController],
  middleware: { cors: true, helmet: true, logging: true, compression: true },
  auth: jwtStrategy,         // guards @Auth() routes
  cqrs: true,                // wire CommandBus + QueryBus
  healthCheck: true,
});

Controllers & routes

Route decorators: @Get @Post @Put @Delete @Patch @Head @Options. Auth decorators: @Auth(strategy) @AdminOnly() @RolesOnly(roles) @SelfOnly() @Public().

Authentication

Strategies come from @soapjs/soap-auth. Register them on the app, and pass one as auth: in bootstrap() to guard @Auth() routes:

CQRS & Events

With cqrs: true, bootstrap() binds CommandBus + QueryBus and registers every @CommandHandler / @QueryHandler. Controllers inject the buses and dispatch. Domain events use @EventHandler — note they are registered but not auto-wired; you connect your own event bus. Full details: CQRS & Events.

Errors → HTTP

ResultMapper.toResponse(result, res) maps a Result failure to a status code. Register custom mappings at startup:

Full reference

A complete app (controllers, CQRS, events, auth, sockets): the Comics Universe demo.

Last updated