open-index/open-npm huggingface dataset:
npm package: @monolythium/api-utils
Description: Shared stateless utilities for Monolythium ecosystem Express APIs
Latest version: 0.2.1

# @monolythium/api-utils

Shared stateless utilities for Monolythium ecosystem Express APIs.

## Install

```bash
npm install @monolythium/api-utils
```

## Usage

```ts
import {
  createLogger,
  createPool,
  validateBody,
  validateQuery,
  validateParams,
  createHelmet,
  createCors,
  createRateLimit,
  healthCheck,
  gracefulShutdown,
  normalizeAddress,
  isValidEvmAddress,
} from '@monolythium/api-utils';

const logger = createLogger('my-api');
const db = createPool({ connectionString: process.env.DATABASE_URL, logger });

app.use(createHelmet());
app.use(createCors(['https://example.com']));
app.use(createRateLimit({ max: 100 }));
app.get('/health', healthCheck({ db }));

gracefulShutdown(server, () => db.closePool());
```

## Modules

| Module | Exports | Peer Deps |
|--------|---------|-----------|
| logger | `createLogger(name, opts?)` | pino, pino-pretty (opt) |
| db | `createPool(config)` | pg (opt) |
| validation | `validateBody`, `validateQuery`, `validateParams` | zod, express |
| security | `createHelmet`, `createCors`, `createRateLimit` | helmet (opt), cors (opt), express-rate-limit (opt) |
| health | `healthCheck(deps?)` | express |
| shutdown | `gracefulShutdown(server, cleanup?)` | — |
| address | `normalizeAddress`, `isValidEvmAddress` | — |

## License

MIT