Code Examples

Practical demonstrations of Eiseniiaiia patterns, APIs, and capabilities.

๐Ÿ“ Example Categories

Core Features

Basic usage patterns demonstrating module creation, configuration, and event handling.

View Examples

Advanced

Complex usage patterns including performance optimizations, middleware integration, and large systems.

View Examples

๐Ÿ”ง Core Usage Examples

Basic Module Setup


// src/index.js
const Module = require('@eiseniiaia/core');

new Module({
    name: 'demo',
    version: '1.0.0'
}).init().then(() => {
    console.log('Module is ready');
});
                        

Create a minimal module with default settings. This demonstrates the most basic module lifecycle.

Event Handling


// Event example
Module.events.on('startup', () => {
    console.log('System is running');
});

Module.trigger('startup');
                        

Demonstrates how to register and trigger custom events in Eiseniiaia. Events help with decoupling components.

๐Ÿš€ Advanced Pattern Examples

Performance Optimization


// Caching example
const cache = {};
Module.hooks.before = (ctx) => {
    if (cache[ctx.key]) {
        return cache[ctx.key];
    }
    
    return fetch(ctx.resource).then(res => {
        cache[ctx.key] = res;
        return res;
    });
};
                        

Implements a sophisticated caching layer using module hooks to reduce redundant network calls.

Middleware Integration


// Express middleware
Module.use(req, res, next) {
    console.log('Processing request');
    res.setHeader('X-Powered-By', 'Eiseniiaia');
    return next();
}
                        

Example of integrating Eiseniiaia with external middleware systems like Express.js or Fastify.

๐Ÿ”ฅ Want to Try This Yourself?

All examples are production-ready code that work in current node.js LTS environments.