StaticcreateCreates a simple context with minimal boilerplate.
This helper eliminates the need to create a new class for simple contexts. Just provide the context name and definitions, and you get a fully functional context.
The name of the context (e.g., 'Products', 'Orders')
Context configuration options
A new context instance
// Before: Manual class creation
class ProductsContext extends BaseContext {
readonly metadata = { name: 'products-context', ... };
readonly name = 'Products';
getCommands() { return [...]; }
getQueries() { return [...]; }
// etc...
}
// After: One-liner with ContextHelpers
const productsContext = ContextHelpers.createSimpleContext('Products', {
commands: [...],
queries: [...]
});
StaticcreateCreates a context with only repositories (useful for shared data contexts).
The name of the context
Repository definitions
Optionaldescription: stringOptional context description
A new context with only repositories
StaticcreateCreates a read-only context with only queries (useful for reporting/analytics).
The name of the context
Query definitions
Optionalrepositories: ContextRepositoryDefinition[]Optional repository definitions
Optionaldescription: stringOptional context description
A new read-only context
Helpers for creating contexts with minimal boilerplate.
Example