INNER CODE UNIT · TypeScript
buildAppContainer
jeffijoe/awilix · benchmarks/realistic-app.ts:16
function buildAppContainer(strict = false) {
const container = createContainer({ strict })
// ── Infrastructure (5 entries) ──────────────────────────────
container.register({
config: asValue({ port: 3000, dbUrl: 'postgres://localhost/app' }),
dbConnection: asFunction(({ config }: any) => ({ query: () => [], config }), {
lifetime: Lifetime.SINGLETON,
}),
logger: asFunction(() => ({ log: () => {}, error: () => {} }), {
lifetime: Lifetime.SINGLETON,
}),
cache: asFunction(({ logger }: any) => ({ get: () => null, set: () => {}, logger }), {
lifetime: Lifetime.SINGLETON,
}),
eventBus: asFunction(({ logger }: any) => ({ emit: () => {}, on: () => {}, logger }), {
lifetime: Lifetime.SINGLETON,
}),