# inversify-service-config

> Inversify environment based configuration files.

Latest version **0.0.8** (published 2021-08-10) · ISC license · 0 weekly downloads

## Install

```sh
npm install inversify-service-config
pnpm add inversify-service-config
yarn add inversify-service-config
bun add inversify-service-config
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.8 |
| Published | 2021-08-10 |
| First published | 2021-08-06 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 14 |
| Unpacked size | 58.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Evan Garrett |
| Maintainers | evang522 |
| Keywords | dependency-injection, inversify, configuration, di, SOLID, ioc |

## Links

- npm: https://www.npmjs.com/package/inversify-service-config
- Repository: https://github.com/evang522/inversify-service-config
- Homepage: https://github.com/evang522/inversify-service-config#readme
- Issues: https://github.com/evang522/inversify-service-config/issues
- npm.io page: https://npm.io/package/inversify-service-config

## Dependencies (14)

- [np](https://npm.io/package/np.md) ^7.5.0
- [jest](https://npm.io/package/jest.md) ^27.0.6
- [eslint](https://npm.io/package/eslint.md) ^7.30.0
- [inversify](https://npm.io/package/inversify.md) ^5.1.1
- [typescript](https://npm.io/package/typescript.md) ^4.3.5
- [@babel/core](https://npm.io/package/@babel/core.md) ^7.14.6
- [@types/jest](https://npm.io/package/@types/jest.md) ^26.0.24
- [reflect-metadata](https://npm.io/package/reflect-metadata.md) ^0.1.13
- [@babel/preset-env](https://npm.io/package/@babel/preset-env.md) ^7.14.7
- [typescript-eslint](https://npm.io/package/typescript-eslint.md) 0.0.1-alpha.0
- [@babel/preset-typescript](https://npm.io/package/@babel/preset-typescript.md) ^7.14.5
- [@typescript-eslint/parser](https://npm.io/package/@typescript-eslint/parser.md) ^4.28.2
- [@typescript-eslint/eslint-plugin](https://npm.io/package/@typescript-eslint/eslint-plugin.md) ^4.28.2
- [@babel/plugin-proposal-decorators](https://npm.io/package/@babel/plugin-proposal-decorators.md) ^7.14.5

## Alternatives

- [memory-cache](https://npm.io/package/memory-cache.md) — 795.0K weekly downloads
- [@httptoolkit/proxy-agent](https://npm.io/package/@httptoolkit/proxy-agent.md) — 11.2K weekly downloads
- [express-cache-controller](https://npm.io/package/express-cache-controller.md) — 5.3K weekly downloads
- [http-cache-middleware](https://npm.io/package/http-cache-middleware.md) — 4.5K weekly downloads
- [cache2](https://npm.io/package/cache2.md) — 1.5K weekly downloads

## Recent versions

- 0.0.8 (latest) — 2021-08-10
- 0.0.7 — 2021-08-10
- 0.0.6 — 2021-08-06
- 0.0.5 — 2021-08-06
- 0.0.4 — 2021-08-06
- 0.0.2 — 2021-08-06
- 0.0.1 — 2021-08-06
- 0.0.0 — 2021-08-06

## README

<img src="/assets/inversify_config_logo.png" width="109" alt="inversify_logo" title="Inversify Logo"/>

# Inversify Container Bindings
[![npm version](https://badge.fury.io/js/inversify-service-config.svg)](https://badge.fury.io/js/inversify-service-config)

The purpose of this project is to provide a ts-file config based approach to registering container services with
inversify instead of needing to do so via procedural code.

❌ For example, the *typical* way of registering services ❌:
```ts
// registerServices.ts

if (process.env.NODE_ENV === 'prod')
{
    container.bind(interfaces.HttpClient).to(CurlHttpClient);
    container.bind(interfaces.SenderInterface).to(EmailClient)
}
elseif(process.env.NODE_ENV === 'dev')
{
    container.bind(interfaces.HttpClient).to(MockCurlHttpClient);
    container.bind(interfaces.SenderInterface).to(MockEmailClient)
}

// This tends to get messy pretty quickly.

```

✅ With this package's configuration ✅:

```ts
// serviceConfig.ts

export const infrastructureConfig: BoundServiceStructure[] = [
    {
        bindingAction: BindingAction.BindServiceIdToClass,
        serviceId: interfaces.HttpClient,
        targetClass: CurlHttpClient,
        global: true,
    },
    {
        bindingAction: BindingAction.BindServiceIdToClass,
        serviceId: interfaces.SenderInterface,
        targetClass: MockEmailClient,
        environments: ['dev', 'test'],
    },
    {
        bindingAction: BindingAction.BindServiceIdToClass,
        serviceId: interfaces.SenderInterface,
        targetClass: EmailClient,
        environments: ['staging', 'prod', 'qa'],
    },
];
```


## Quick Start

```ts
import { BindingManager } from 'inversify-service-config';
import container from './inversify.config.ts';  // however you decide to initialise your inversify container.


const manager = new BindingManager(
    infrastructureConfig,
    new Environment<'development'|'production'>('development'),
    container,
);

// Running 'processServicesConfig' will bind all services according to your configuration.

manager.processServicesConfig();

// Done. 
```


> The package comes with validation and will throw proper and helpful exceptions when a passed configuration does not make sense or contradicts another.

---
_Source: https://npm.io/package/inversify-service-config · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
