> For the complete documentation index, see [llms.txt](https://kinesis-school-of-programming.gitbook.io/nestjs-unleashed/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://kinesis-school-of-programming.gitbook.io/nestjs-unleashed/core-module-backend-development-with-nestjs/configuration/reducing-boilerplate.md).

# Reducing boilerplate

There's an interesting alternative to the injection of the configuration namespace in the dynamic module.

Here, I'll just show another approach to injecting the configuration namespace in TypeORM's dynamic module configuration, but feel free to choose either one according to your preference.

If you notice, three options are being used to configure the <mark style="color:blue;">`TypeOrmModule`</mark>, which are <mark style="color:blue;">`type`</mark>, <mark style="color:blue;">`url`</mark> and <mark style="color:blue;">`autoLoadEntities`</mark>. What we can do is to already have all these options set in the configuration namespace, and with that, inject it in a much less verbose way.

We can return to the <mark style="color:purple;">database.config</mark> file and have all those options configured here, and also type the object according to these options.

```typescript
export default registerAs('database', () => {
  const config = {
    type: 'postgres',
    url: process.env.DATABASE_URL,
    autoLoadEntities: true,
  } as const satisfies TypeOrmModuleOptions;
  return config;
});
```

After that, we can substitute all that boilerplate code for simply this:

```typescript
TypeOrmModule.forRootAsync(databaseConfig.asProvider())
```

<mark style="color:green;">**Commit**</mark> - Reducing boilerplate in dynamic module configuration
