# Container Options, extendability

You can configure the Container with

```typescript
{
    enableAutoCreate: boolean; // if dependency does not exist in the container, create it and register
    initializers?: Type<IInitializer>[]; // runs after instatnitation 
}
```

### enableAutoCreate

When you call container.resolve / resolveByType etc. It will try to resolve with the registered dependencies and if the required dependency is not registered (.register, .registerByType..)  it will throw an error, BUT you have the option to register types when resolution is happening (no need for registration). It will resolve Types automatically with the use of the [@Injectable({instantiation: "singleton" | "prototype"})](/type-chef-di/fundamentals/decorators/injectable.md) decorator. Basically, it's like a strict mode you can choose.

### Initializers

Initializers run after every instantiation. The container has some default initializatizers eg. [@MethodWrapper(key: string | Type\<IMethodWrapper>)](/type-chef-di/fundamentals/decorators/methodwrapper-key-string.md), [@RunBefore(key: string | Type\<IRunBefore>)](/type-chef-di/fundamentals/decorators/runbefore-key-string.md), [@InitMethod()](/type-chef-di/fundamentals/decorators/initmethod.md) etc. You can create your own just implement the IInitializer interface:

```typescript
class StatusInitializer implements IInitializer {
    constructor(readonly resolver: IResolver) {
    }

    run(resolvedInstance: any, definition: IBaseDefinition): Promise<any> {
        resolvedInstance.status = "your change";
        return resolvedInstance;
    }
}
```

Then add to the container:

```typescript
new Container({
    initializers: [StatusInitializer]
})
```


---

# 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://zer0-2.gitbook.io/type-chef-di/fundamentals/container-options-extendability.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.
