Powerful, type-inferred, and hyper-minimalistic library for server request propagation and dependency injection using a novel Supply Chain Architecture
Pure functions and objects with compile-time optimization
Full TypeScript inference throughout the dependency chain
Powerful resupply() for dynamic dependency injection
Get up and running with Supplier in minutes. Here's how easy it is to implement powerful dependency injection.
npm install supplier
import { register, parcel } from "supplier";
// Create a resource
const ConfigResource = register("config")
.asResource<{ apiUrl: string }>();
// Create a service
const ApiService = register("api").asService({
factory: ($) => {
const config = $(ConfigResource.id);
return { fetch: (path) => `${config.apiUrl}${path}` };
}
});
// Supply and use
const api = ApiService.supply(
parcel(ConfigResource.supply({ apiUrl: "https://api.com" }))
);
console.log(api.value.fetch("/users")); // "https://api.com/users"
// Resupply with different context
const testApi = apiService.resupply(
parcel(ConfigResource.supply({
apiUrl: "http://localhost:3000"
}))
);
// Same service, different config!
console.log(testApi.value.fetch("/users"));
// "http://localhost:3000/users"
Supplier's resupply()
method enables powerful testing scenarios and runtime dependency overrides without affecting the original service configuration.
Everything you need for modern dependency injection, designed for performance and developer experience.
Pure functions and objects with compile-time optimization. No reflection, no runtime magic.
Full TypeScript inference throughout the dependency chain. Catch errors at compile time.
Powerful resupply() for dynamic dependency injection and testing scenarios.
Learn the entire API in minutes. Simple, intuitive, and powerful.
Minimal footprint with zero dependencies. Perfect for performance-critical applications.
MIT licensed and community-driven. Contribute on GitHub and shape the future.
Check out our interactive example with 4-level deep component hierarchy demonstrating context switching and dependency injection.
View Live Example