Client Initialization
Learn how to configure and instantiate the #divisions client with environment variables and custom transport layers.
import { DivisionsClient } from '@divisions/core';
const client = new DivisionsClient({
apiKey: process.env.DIV_KEY,
region: 'us-east-1'
});
Dynamic Routing
Build flexible, parameterized routes with automatic type inference and validation middleware.
router.get('/users/:id/posts', async (ctx) => {
const user = await db.users.findById(ctx.params.id);
return ctx.json(user.posts);
});
Plugin System
Extend core functionality with lifecycle hooks, interceptors, and custom plugin registries.
client.use(authPlugin({ strategy: 'jwt' }));
client.use(loggingPlugin({ level: 'verbose' }));
client.register({ name: 'metrics', version: '1.0.0' });
Environment Configuration
Manage secrets, feature flags, and multi-environment setups with zero-downtime hot reloading.
DIV_ENV=prod
DIV_LOG_LEVEL=warn
DIV_CACHE_TTL=3600
DIV_REGION=eu-west-2
Webhook & Event Bus
Subscribe to system events, configure retry policies, and verify signatures securely.
bus.on('order.created', async (payload) => {
await notifyService(payload);
return { acknowledged: true };
});
Testing Utilities
Mock clients, intercept requests, and run isolated test suites with the built-in harness.
import { createTestClient } from '@divisions/test';
const t = await createTestClient();
t.mock('/api/data').json({ status: 'ok' });