# Dependency injection

If your service uses a dependency injection provider and you want to use it to resolve class based handlers and workflows, you can provide an adapter to **@node-ts/bus-core** for it to use.

This is provided as an adapter passed using **.withContainer()** to the configuration.

This example uses [inversify](https://www.npmjs.com/package/inversify), but any IoC container that supports resolving instances via a class type will work.

```typescript
import { Bus, ClassConstructor } from '@node-ts/bus-core'
import { Container } from 'inversify'

const start = async () => {
  const container = new Container()

  const bus = await Bus.configure()
    .withContainer({
      get <T>(type: ClassConstructor<T>) {
        return container.get<T>(type)
      }
    })
    .initialize()
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://bus.node-ts.com/guide/dependency-injection.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
