@aopslabs/xf-dm-kits
v0.2.1
Published
Typed service-provider utilities for composing repositories, services, caches, metrics, and resilience policies.
Readme
@aopslabs/xf-dm-kits
Typed service-provider utilities for composing repositories, services, caches, metrics, and resilience policies.
Installation
npm install @aopslabs/xf-dm-kitsBasic usage
import { createFacade, createProvider } from '@aopslabs/xf-dm-kits';
const provider = createProvider({
name: 'customer-services',
getContext: async overrides => ({ tenantId: 'default', ...overrides }),
resolveConfig: context => ({ tenantId: context.tenantId }),
computeConfigKey: config => config.tenantId,
repositories: {
customers: async config => createCustomerRepository(config)
},
services: {
customers: async (_context, _services, repositories) =>
createCustomerService(repositories.customers)
}
});
const services = createFacade(provider);
const customerService = await services.get('customers');Included utilities
| Area | Exports |
| --- | --- |
| Providers | createProvider, repository and service factories, context overrides, runtime statistics |
| Facades | createFacade with cached or fresh service creation |
| Caching | ServiceCache, cache keys, global singleton helpers |
| Metrics | No-op, counter, logger, and multi-collector implementations |
| Resilience | Retry, timeout, and circuit-breaker helpers |
| Configuration | Environment parsing and typed configuration managers |
Repository instances and service instances can be cached independently. getService uses the configured cache key, while createService creates a fresh instance. Cache and registry state can be cleared explicitly through the provider or facade.
License
Copyright (c) 2026 Mehmet Zeki Sönmez.
Licensed under the PolyForm Strict License 1.0.0. The license permits noncommercial use and does not grant permission to modify or redistribute the package.
