Skip to content

Package Overview

ModularityJS is organized as a monorepo with packages grouped by role.

Core

PackageDescription
@modularityjs/diAbstract DI contract — decorators and container interface
@modularityjs/di-inversifyInversifyJS implementation of the DI contract
@modularityjs/di-awilixAwilix implementation of the DI contract
@modularityjs/modularityModule system — loader, lifecycle, pools, validators
@modularityjs/pluginsPlugin system with before/after/around interception
@modularityjs/viewComponent registry and recursive view validator

Contracts and Drivers

Each service follows the contract/driver pattern: an abstract contract package and one or more concrete driver packages. See Architecture for details on the two variants (service contracts and module-level contracts).

Service Contracts

ServiceContractDrivers
Cache@modularityjs/cachecache-memory, cache-redis
Lock@modularityjs/locklock-memory, lock-redis
Queue@modularityjs/queuequeue-memory, queue-redis
Session@modularityjs/sessionsession-memory, session-redis
Auth@modularityjs/authauth-jwt, auth-api-key, auth-local, auth-oidc, auth-oidc-introspection
Authz@modularityjs/authzauthz-rbac, authz-policy
Storage@modularityjs/storagestorage-memory, storage-local, storage-s3
Encryption@modularityjs/encryptionencryption-aes
I18n@modularityjs/i18ni18n-json
Rate Limit@modularityjs/rate-limitrate-limit-memory, rate-limit-redis
Webhook@modularityjs/webhookwebhook-memory, webhook-direct, webhook-queue
Image Processing@modularityjs/media-imagemedia-image-sharp
Video Processing@modularityjs/media-videomedia-video-ffmpeg
Audio Processing@modularityjs/media-audiomedia-audio-ffmpeg
Media (shared)@modularityjs/mediamedia-ffmpeg (FFmpeg utilities), media-storage-stream (storage pipeline extension)
Template@modularityjs/templatetemplate-handlebars, template-ejs
Assets@modularityjs/assetsDrivers: assets-local (filesystem). Bridges: http-assets (serves /static/*), template-assets ( helper). CLI: assets-cli (assets:collect)
Validation@modularityjs/validationvalidation-zod, validation-ajv
Outbox@modularityjs/outboxStores: outbox-memory, outbox-typeorm, outbox-prisma (Postgres). Publisher: outbox-events (→ EventBus). Bridges: outbox-scheduler (cron dispatch + retention), outbox-cli (outbox:dispatch/list/stats/retry), outbox-telemetry (OTel)
Secrets@modularityjs/secretsDrivers: secrets-memory, secrets-vault (HashiCorp Vault), secrets-aws (AWS Secrets Manager), secrets-gcp (GCP Secret Manager). Bridge: secrets-config plugs SecretsService into ConfigSource so secrets flow through ConfigService.resolve()
Feature Flags@modularityjs/feature-flagsDrivers: feature-flags-static (forRoot config), feature-flags-growthbook (GrowthBook SDK). Bridge: http-feature-flags provides @Variant(key) / @Flag(key) parameter decorators backed by getFeatureContext(request)
MFA@modularityjs/mfaPool-based factor model. Drivers: mfa-totp (RFC 6238), mfa-sms / mfa-email (one-time codes via SmsService/MailService), mfa-backup-codes (single-use recovery), mfa-webauthn (passkeys via @simplewebauthn/server). Bridge: http-mfa provides @RequireMfa() guard. App implements MfaSecretStore.

Transport-Pool Contracts

ServiceContractDriversDescription
Logger@modularityjs/loggerlogger-console, logger-fileTransport-pool dispatch with channel routing and level filtering

Module-Level Contracts

ServiceContractDriverDescription
HTTP@modularityjs/httphttp-fastifyPool-based controller discovery with framework-owned decorators
CLI@modularityjs/clicli-commanderPool-based command discovery with Commander.js
Database@modularityjs/databasedatabase-typeorm, database-prismaAbstract DatabaseConnection, MigrationRunner, MigrationGenerator; driver-specific entity/schema registration
Scheduler@modularityjs/schedulerscheduler-cronerCron-based job scheduler with distributed locking
Events@modularityjs/eventsevents-memory, events-redisTyped event bus with pool-based listener discovery and per-handler once deduplication
WebSocket@modularityjs/wsws-fastifyGateway-based WebSocket routing with @WsGateway and @OnMessage

Infrastructure

PackageDescription
@modularityjs/exceptionStructured exception hierarchy with HTTP mapping. Allowed everywhere — no module wiring required.
@modularityjs/retryRetry-policy primitive — computeDelay(policy, attempt) with fixed/exponential strategies, optional jitter and cap. Zero deps, no DI, no Module. Used by queue, webhook-direct, future delivery drivers.
@modularityjs/validation-schemaSchema typing primitive — Schema<T> interface, ValidationResult, and the native-schema side-channel registry (recordNativeSchema / getNativeSchema) used by validation drivers and OpenAPI tooling. Zero deps, no DI, no Module.
@modularityjs/redisShared ioredis client for all Redis drivers
@modularityjs/configScoped configuration with pluggable sources
@modularityjs/config-envEnvironment variable config source

HTTP Extensions

PackageDescription
@modularityjs/http-sessionSession middleware for HTTP — cookie-based session persistence via HttpServer hooks
@modularityjs/http-authAuth middleware for HTTP — token extraction and identity injection via extractor pool
@modularityjs/http-auth-jwtJWT Bearer adapter — registers an HttpAuthenticator that reads Authorization: Bearer and resolves identity via JwtAuthService
@modularityjs/http-auth-api-keyAPI key extractor adapter — registers X-API-Key header extractor
@modularityjs/http-auth-localLocal auth adapter — HTTP Basic authentication
@modularityjs/http-auth-oidcOIDC Bearer token adapter
@modularityjs/http-auth-sessionSession-based auth adapter — resolves identity from session data
@modularityjs/http-authzAuthorization enforcement — @RequirePermission() checked in the HTTP adapter pipeline (before guards) via AuthzService.can()
@modularityjs/http-uploadAbstract upload contract — HttpUploadConfig (max size, MIME allowlist) + sanitizeFilename; driver-agnostic
@modularityjs/http-fastify-uploadFastify driver — registers @fastify/multipart and binds @UploadedFile()/@UploadedFiles() resolvers
@modularityjs/http-fastify-formbodyFastify-driver extension — registers @fastify/formbody for application/x-www-form-urlencoded bodies
@modularityjs/http-storageUpload-to-storage integration — HttpStorageService with store() and download()
@modularityjs/http-i18nLocale extraction middleware
@modularityjs/http-rate-limitRate limiting middleware
@modularityjs/http-validationValidation parameter decorators — @ValidatedBody/Query/Params/Headers(schema) returning 422 on failure
@modularityjs/http-fastify-corsFastify-driver extension — registers @fastify/cors with framework-managed config
@modularityjs/http-fastify-compressionFastify-driver extension — registers @fastify/compress (br/gzip/deflate)
@modularityjs/http-fastify-security-headersFastify-driver extension — registers @fastify/helmet (CSP, HSTS, X-Frame-Options, …)
@modularityjs/http-csrfCSRF protection — session-stored or HMAC double-submit; @CsrfProtect() decorator
@modularityjs/http-htmxHTMX decorator — request helpers and partial-response conventions
@modularityjs/http-mfaMFA decorator — @RequireMfa() guard backed by MfaService via session attrs
@modularityjs/http-feature-flagsFeature-flags adapter — @Variant(key) / @Flag(key) parameter decorators
@modularityjs/http-openapiServes /openapi.json plus a /docs UI via the OpenApiUiRenderer contract
@modularityjs/http-openapi-swaggerSwagger UI driver — binds OpenApiUiRenderer + ships swagger-ui-dist through the assets pipeline
@modularityjs/http-openapi-redocRedoc driver — binds OpenApiUiRenderer + ships redoc.standalone through the assets pipeline
@modularityjs/http-openapi-rapidocRapiDoc driver — binds OpenApiUiRenderer + ships rapidoc-min through the assets pipeline
@modularityjs/http-openapi-scalarScalar API Reference driver — binds OpenApiUiRenderer + ships the standalone bundle through the assets pipeline
@modularityjs/http-telemetryOpenTelemetry HTTP spans for requests and routes
@modularityjs/http-assetsServes hashed static assets at /static/* from the assets pipeline
@modularityjs/http-webhookWebhook endpoint adapter

Extensions

PackageDescription
@modularityjs/healthHealth check indicators
@modularityjs/scopeScope chain resolver for multi-tenant contexts
@modularityjs/exceptionStructured exception hierarchy
@modularityjs/oidc-clientOAuth2/OIDC Authorization Code flow helpers (OidcClientService, OidcFlowService with PKCE)
@modularityjs/testingcreateTestHarness() utility for module integration tests