Documentation

Documentation

Matrix Framework Documentation

Welcome to the Matrix Framework documentation. Here you’ll find everything you need to understand and implement middleware solutions using our tree-based architecture.

Quick Links

Installation

npm install matrix-framework

Basic Usage

Here’s a simple example that sets up a middleware tree with authentication and logging:

import { MiddlewareTree, MessageRouter } from 'matrix-framework';

// Create middleware nodes
const tree = new MiddlewareTree();
const auth = new AuthMiddleware();
const logging = new LoggingMiddleware();
const handler = new MessageHandler();

// Build the middleware tree
tree.addNode('auth', auth);
tree.addNode('logging', logging, 'auth'); // Add logging as child of auth
tree.addNode('handler', handler, 'logging'); // Add handler as child of logging

// Create and start the router
const router = new MessageRouter(tree);
router.start();

// Send a message through the middleware tree
await router.route({
    type: 'greeting',
    payload: { message: 'Hello, World!' }
});

Next Steps