# @alliage/parameters-loader

> Parameters loader module for Alliage

Latest version **0.1.0-beta.6** (published 2025-05-23) · GNU license · 0 weekly downloads

## Install

```sh
npm install @alliage/parameters-loader
pnpm add @alliage/parameters-loader
yarn add @alliage/parameters-loader
bun add @alliage/parameters-loader
```

## Health

**Score 40/100 (D)** — status: maintenance-mode.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads; pre 1.0.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.0-beta.6 |
| Published | 2025-05-23 |
| First published | 2023-04-05 |
| Weekly downloads | 0 |
| License | GNU |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 2 |
| Unpacked size | 41.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | bo.lebon@gmail.com |
| Maintainers | borislebon |

## Links

- npm: https://www.npmjs.com/package/@alliage/parameters-loader
- Repository: https://github.com/alliage-framework/core
- Homepage: https://github.com/alliage-framework/core#readme
- Issues: https://github.com/alliage-framework/core/issues
- npm.io page: https://npm.io/package/@alliage/parameters-loader

## Dependencies (2)

- [glob](https://npm.io/package/glob.md) ^11.0.1
- [json-schema-to-ts](https://npm.io/package/json-schema-to-ts.md) ^3.1.1

## Recent versions

- 0.1.0-beta.6 (latest) — 2025-05-23
- 0.1.0-beta.8 (beta) — 2025-06-08
- 0.1.0-beta.7 — 2025-06-06
- 0.1.0-beta.5 — 2025-05-23
- 0.1.0-beta.4 — 2025-05-23
- 0.1.0-beta.3 — 2023-06-01
- 0.1.0-beta.2 — 2023-05-31
- 0.1.0-beta.1 — 2023-04-12
- 0.1.0-beta.0 — 2023-04-05

## README

# Alliage Parameters Loader

A robust configuration module that provides a flexible way to store and access application parameters within your Alliage projects.

## Overview

This module creates a centralized parameters storage system that any part of your application can access. Define your application's configuration parameters once in a YAML file and consume them anywhere in your services.

## Dependencies

- [@alliage/di](../dependency-injection) - Dependency injection system
- [@alliage/lifecycle](../lifecycle) - Application lifecycle management
- [@alliage/module-installer](../module-installer) - Module installation utilities
- [@alliage/config-loader](../configuration-loader) - Configuration loading system

## Installation

Using yarn:

```bash
yarn add @alliage/parameters-loader
```

Using npm:

```bash
npm install @alliage/parameters-loader
```

## Registration

### Automatic Registration

If you have already installed [@alliage/module-installer](../module-installer), simply run:

```bash
$(npm bin)/alliage-scripts install @alliage/parameters-loader
```

### Manual Registration

Alternatively, update your `alliage-modules.json` file to include:

```json
{
  // ... other modules
  "@alliage/parameters-loader": {
    "module": "@alliage/parameters-loader",
    "deps": [
      "@alliage/lifecycle",
      "@alliage/di",
      "@alliage/module-installer",
      "@alliage/config-loader"
    ],
    "envs": []
  }
}
```

## Usage

Once installed, a new configuration file will be available at `config/parameters.yaml`. This file accepts any valid YAML structure according to your application's needs.

### Example Parameters Configuration

```yaml
# config/parameters.yaml
webserver:
  host: 127.0.0.1
  port: 8080
  credentials:
    username: johnsmith
    password: '411!463|20(|(5'
```

### Using Parameters in Your Services

After defining your parameters, they can be injected into any service through the dependency injection system.

#### JavaScript Example

```js
// MyModule.js
import { AbstractLifeCycleAwareModule, INIT_EVENTS, RUN_EVENTS } from '@alliage/lifecycle';
import { parameter } from '@alliage/di';

import { MyService } from './MyService.js';

export default class MyModule extends AbstractLifeCycleAwareModule {
  // ... other module methods
  
  registerServices(serviceContainer) {
    serviceContainer.registerService('my_service', MyService, [
      parameter('parameters.webserver.host'),
      parameter('parameters.webserver.port'),
      parameter('parameters.webserver.credentials'),
    ]);
  }
}
```

#### TypeScript Example

```ts
// MyModule.ts
import { AbstractLifeCycleAwareModule, INIT_EVENTS, RUN_EVENTS } from '@alliage/lifecycle';
import { ServiceContainer, parameter } from '@alliage/di';

import { MyService } from './MyService.js';

export default class MyModule extends AbstractLifeCycleAwareModule {
  // ... other module methods
  
  registerServices(serviceContainer: ServiceContainer) {
    serviceContainer.registerService('my_service', MyService, [
      parameter('parameters.webserver.host'),
      parameter('parameters.webserver.port'),
      parameter('parameters.webserver.credentials'),
    ]);
  }
}
```

In both examples, the parameters are accessed using dot notation paths that match your YAML structure. The dependency injection system will automatically resolve and inject these values into your service constructor.

---
_Source: https://npm.io/package/@alliage/parameters-loader · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
