open-index/open-npm huggingface dataset:
npm package: @project-karin/config
Description: Type-safe configuration management for Karin
Latest version: 0.5.21

# @project-karin/config

Configuration management plugin for Karin with environment variable loading and validation.

## Installation

```bash
bun add @project-karin/config
```

## Overview

The Config plugin provides:
- ✅ Environment variable loading from `.env` files
- ✅ Schema validation with Zod
- ✅ Type-safe configuration access
- ✅ Required keys validation
- ✅ Custom configuration loaders

## Quick Start

```typescript
import { KarinFactory } from "@project-karin/core";
import { ConfigPlugin } from "@project-karin/config";

const config = new ConfigPlugin({
  requiredKeys: ["DATABASE_URL", "PORT"],
});

const app = await KarinFactory.create(adapter, {
  plugins: [config],
});

// Access config in services
@Service()
class AppService {
  constructor(private config: ConfigService) {}

  getDatabaseUrl() {
    return this.config.get("DATABASE_URL");
  }
}
```

## Features

### Environment Variables

Automatically loads `.env` files:

```env
# .env
DATABASE_URL=mongodb://localhost:27017/mydb
PORT=3000
API_KEY=secret123
```

### Required Keys

Ensure critical configuration is present:

```typescript
const config = new ConfigPlugin({
  requiredKeys: ["DATABASE_URL", "API_KEY"],
});
// Throws error if keys are missing
```

### Schema Validation

Validate configuration with Zod:

```typescript
import { z } from "zod";

const config = new ConfigPlugin({
  schema: z.object({
    PORT: z.string().transform(Number),
    DATABASE_URL: z.string().url(),
    LOG_LEVEL: z.enum(["debug", "info", "warn", "error"]),
  }),
});
```

### Custom Loaders

Load configuration from any source:

```typescript
const config = new ConfigPlugin({
  load: async () => ({
    port: 3000,
    database: await fetchFromVault(),
  }),
});
```

## Usage in Services

```typescript
import { Service } from "@project-karin/core";
import { ConfigService } from "@project-karin/config";

@Service()
export class DatabaseService {
  constructor(private config: ConfigService) {}

  connect() {
    const url = this.config.get("DATABASE_URL");
    // Connect to database
  }

  getAllConfig() {
    return this.config.getAll();
  }
}
```

## Lazy Resolution in Plugins

Use config values in other plugins:

```typescript
const config = new ConfigPlugin({
  requiredKeys: ["MONGO_URI"],
});

const app = await KarinFactory.create(adapter, {
  plugins: [
    config,
    new MongoosePlugin({
      uri: () => config.get("MONGO_URI"), // Lazy resolution
    }),
  ],
});
```

## API

### ConfigPlugin Options

```typescript
interface ConfigPluginOptions {
  // Load from .env file (default: true)
  loadEnv?: boolean;

  // Custom loader function
  load?: () => Record<string, any> | Promise<Record<string, any>>;

  // Zod schema for validation
  schema?: z.ZodSchema;

  // Required configuration keys
  requiredKeys?: string[];
}
```

### ConfigService Methods

```typescript
class ConfigService {
  // Get a configuration value
  get<T = string>(key: string): T;

  // Get all configuration
  getAll(): Record<string, any>;
}
```

## License

MIT
npm package: @project-karin/drizzle
Description: Drizzle ORM integration plugin for Karin.
Latest version: 0.5.21

# @project-karin/drizzle

Drizzle ORM integration plugin for Karin.

## Installation

```bash
bun add @project-karin/drizzle drizzle-orm
```

You will also need a driver, for example `postgres`, `mysql2`, or `@libsql/client`.

## Usage

### Basic Setup (e.g. with Turso/LibSQL)

```typescript
import { DrizzlePlugin } from "@project-karin/drizzle";
import { drizzle } from "drizzle-orm/libsql";
import { createClient } from "@libsql/client";

// Initialize client and db
const client = createClient({ 
  url: process.env.TURSO_DATABASE_URL, 
  authToken: process.env.TURSO_AUTH_TOKEN 
});
const db = drizzle(client);

const app = await KarinFactory.create(adapter, {
  plugins: [
    new DrizzlePlugin({
      db,
      client, // Pass client to handle graceful shutdown
    }),
  ],
});
```

### Lazy Initialization

You can pass a factory function to initialize the DB only when the plugin installs.

```typescript
new DrizzlePlugin({
  db: () => {
    const client = createClient({ ... });
    return drizzle(client);
  },
  // If you need to close the client, use onDisconnect with lazy init
  onDisconnect: async (db) => {
    // You might need to access the client from the db object if possible, 
    // or manage the client scope differently.
  }
})
```

### Dependency Injection

Inject the database instance into your services.

```typescript
import { InjectDrizzle } from "@project-karin/drizzle";
import { LibSQLDatabase } from "drizzle-orm/libsql";
import { users } from "./schema";

@Service()
class UserService {
  constructor(@InjectDrizzle() private db: LibSQLDatabase) {}

  async findAll() {
    return this.db.select().from(users);
  }
}
```

### Serverless Support

The plugin automatically detects serverless environments (AWS Lambda, Vercel, Cloudflare Workers, etc.) and skips the disconnection step to allow connection reuse (Warm Starts).

You can override this behavior:

```typescript
new DrizzlePlugin({
  db,
  serverless: true // Force serverless mode
})
```

## Options

```typescript
interface DrizzlePluginOptions {
  db: any | (() => any);
  client?: any;
  onDisconnect?: (db: any, client?: any) => Promise<void> | void;
  token?: string;
  serverless?: boolean;
}
```
npm package: @project-karin/platform-h3
Description: H3 HTTP adapter for Karin, optimized for maximum performance on Bun.
Latest version: 0.5.21

# @project-karin/platform-h3

H3 HTTP adapter for Karin, optimized for maximum performance on Bun.

## Installation

```bash
bun add @project-karin/core @project-karin/platform-h3
```

## Overview

The H3 adapter provides:
- ✅ Maximum performance
- ✅ Optimized for Bun
- ✅ Minimal overhead
- ✅ Production-ready

## Usage

```typescript
import { KarinFactory } from "@project-karin/core";
import { H3Adapter } from "@project-karin/platform-h3";

const app = await KarinFactory.create(new H3Adapter(), {
  scan: "./src/**/*.ts",
});

app.listen(3000);
```

## Features

- **High Performance**: Optimized for speed
- **Low Overhead**: Minimal abstraction layer
- **Production Ready**: Battle-tested H3 foundation
- **Modern**: Built for modern runtimes

## Performance

H3 adapter provides the best performance among Karin adapters:
- Fastest request handling
- Lowest latency
- Optimized for high-throughput scenarios

## When to Use

Choose H3 adapter when:
- Maximum performance is the priority
- Running on Bun (not Edge)
- Building high-traffic APIs
- You need the fastest possible framework overhead

Choose Hono adapter when:
- Deploying to Edge runtimes
- Portability across runtimes is important
- Building serverless functions

## License

MIT
npm package: @project-karin/platform-hono
Description: Hono HTTP adapter for Karin, optimized for Edge runtimes and serverless deployments.
Latest version: 0.5.21

# @project-karin/platform-hono

Hono HTTP adapter for Karin, optimized for Edge runtimes and serverless deployments.

## Installation

```bash
bun add @project-karin/core @project-karin/platform-hono
```

## Overview

The Hono adapter provides:
- ✅ Edge runtime support (Cloudflare Workers, Deno Deploy)
- ✅ Lightweight and fast
- ✅ Built-in middleware ecosystem
- ✅ Excellent TypeScript support

## Usage

```typescript
import { KarinFactory } from "@project-karin/core";
import { HonoAdapter } from "@project-karin/platform-hono";

const app = await KarinFactory.create(new HonoAdapter(), {
  scan: "./src/**/*.ts",
});

app.listen(3000);
```

## Serverless Deployment

### Cloudflare Workers

```typescript
import { HonoAdapter } from "@project-karin/platform-hono";
import { KarinFactory } from "@project-karin/core";
import { AppController } from "./app.controller";

const app = await KarinFactory.create(new HonoAdapter(), {
  controllers: [AppController],
  scan: false, // Disable file scanning for serverless
});

export default app.getHttpServer();
```

### Deno Deploy

```typescript
import { HonoAdapter } from "npm:@project-karin/platform-hono";
import { KarinFactory } from "npm:@project-karin/core";

const app = await KarinFactory.create(new HonoAdapter(), {
  scan: "./src/**/*.ts",
});

Deno.serve(app.getHttpServer().fetch);
```

## Features

- **Edge-first**: Designed for modern Edge runtimes
- **Lightweight**: Minimal overhead
- **Fast**: Excellent performance characteristics
- **Flexible**: Works in Bun, Deno, and Edge

## Performance

Hono adapter provides excellent performance:
- ~97,000 req/sec (wrk benchmark)
- ~102,000 req/sec (oha benchmark)
- Sub-millisecond average latency

## When to Use

Choose Hono adapter when:
- Deploying to Edge runtimes (Cloudflare Workers, Deno Deploy)
- Building serverless functions
- You need a lightweight, portable solution
- Edge computing is a priority

Choose H3 adapter when:
- Maximum performance is critical
- Running on traditional servers (Bun)
- You don't need Edge runtime support

## License

MIT