# @eyjs/env

Environment configuration service for EyJS framework.

## Features

- Automatic .env file loading with proper precedence
- Environment-specific configuration support
- Variable interpolation and expansion
- Type-safe configuration access
- Integration with EyJS dependency injection

## Installation

```bash
npm install @eyjs/env
```

## Usage

```typescript
import { ConfigService } from '@eyjs/env';

// The service will automatically load .env files
const config = new ConfigService();

// Get environment variables
const apiUrl = config.get('API_URL');
const dbHost = config.require('DB_HOST'); // Throws if not defined
```

## Environment File Loading Order

The service loads environment files in the following order:
1. `.env`
2. `.env.{NODE_ENV}`
3. `.env.local`
4. `.env.{NODE_ENV}.local`

Files loaded later can override variables from earlier files.

## Configuration Options

```typescript
import { ConfigService, type ConfigOptions } from '@eyjs/env';

const options: ConfigOptions = {
    cwd: '/path/to/project',
    env: 'production',
    override: false,
    files: ['.env.custom']
};

const config = new ConfigService();
```

## API Reference

### ConfigService

#### Methods

- `get(key: string): string | undefined` - Get environment variable
- `require(key: string): string` - Get required environment variable (throws if not found)

### Utilities

- `defaultFileOrder(cwd: string, env: string): string[]` - Get default file loading order
- `existing(files: string[]): string[]` - Filter existing files