Nothing in this codebase imports its own dependencies. Modules are factory functions taking a plain object, and the container decides what goes in it — which is what makes the services testable without mocking module loaders.
This is an excerpt; the real file is roughly 500 lines of exactly this shape:
// IMPERSONATION (generic — shared by every future impersonable actor type)
import { makeImpersonationSessionsRepo } from "./modules/impersonation/impersonationSessions.repo.js";
// LANDLORD_ADMIN RATE LIMITERS
import { makeLandlordadminRateLimiters } from "./modules/landlord_admin/middlewares/landlordadminRateLimiters.js";
const container = createContainer();
// -------------------------------------
// GLOBAL DEPENDENCIES
// -------------------------------------
container.register({
db: asValue(db),
redis: asValue(redis),
env: asValue(env),
logger: asValue(logger)
});
// -------------------------------------
// GLOBAL UTILITIES
// -------------------------------------
container.register({
passwordService: asFunction(makePasswordService).singleton(),
tokenService: asFunction(makeTokenService).singleton(),
linkService: asFunction(makeLinkService).singleton()
});
// -------------------------------------
// HQLEAD MIDDLEWARES
// -------------------------------------
container.register({
verifyHQLeadJWT: asFunction(makeVerifyHQLeadJWT).singleton(),
verifyHQLeadRole: asFunction(makeVerifyHQLeadRole).singleton(),
verifyHQLeadCSRF: asFunction(makeVerifyHQLeadCSRF).singleton(),
getHQLeadActor: asFunction(makeGetHQLeadActor).singleton()
});
// -------------------------------------
// HQLEAD REPO / SERVICE / CONTROLLER
// -------------------------------------
container.register({
asValue registers something already constructed — the database pool,
the Redis client, the logger. asFunction registers a factory the
container calls, resolving each parameter by name.
So a service declaring { redis, landlordadminIdentityRepo } receives
them without naming a file path. In tests it receives fakes instead, with
no module interception and no framework. The cost is real and worth
stating: resolution happens by string name, so a typo surfaces at runtime
rather than when the file is compiled.