open-index/open-npm huggingface dataset:
npm package: @fiyuu/cli
Description: Command-line interface for the Fiyuu framework.
Latest version: 0.5.2

# @fiyuu/cli

Command-line interface for the Fiyuu framework.

## Installation

```bash
npm install -g @fiyuu/cli
# or use via npx
npx @fiyuu/cli dev
```

## Commands

| Command | Description |
|---------|-------------|
| `fiyuu dev` | Start development server with live reload |
| `fiyuu build` | Production build |
| `fiyuu start` | Run production server |
| `fiyuu sync` | Generate project graph and AI docs |
| `fiyuu doctor` | Validate project structure |
| `fiyuu doctor --fix` | Auto-fix common issues |
| `fiyuu graph stats` | Show route statistics |
| `fiyuu graph export` | Export route graph as JSON |
| `fiyuu generate page <name>` | Scaffold a new page |
| `fiyuu generate action <name>` | Scaffold a new action |
| `fiyuu deploy` | Deploy via SSH |

## Quick Start

```bash
# Create a new project
npx create-fiyuu-app my-app
cd my-app

# Start development
npm run dev

# Build for production
npm run build
npm start
```

## Configuration

Create `fiyuu.config.ts` in your project root:

```typescript
import type { FiyuuConfig } from "@fiyuu/core";

const config: FiyuuConfig = {
  app: { name: "My App", port: 4050 },
  data: { driver: "f1" },
  websocket: { enabled: true },
};

export default config;
```

## License

MIT
npm package: @fiyuu/core
Description: Core contracts, decorators, components, and DI container for the Fiyuu framework.
Latest version: 0.5.3

# @fiyuu/core

Core contracts, decorators, components, and DI container for the Fiyuu framework.

## Installation

```bash
npm install @fiyuu/core
```

## Contracts

Define type-safe routes with the 5-file contract system:

```typescript
import { defineQuery, defineAction, definePage, defineMeta, defineMiddleware } from "@fiyuu/core";
import { z } from "zod";

// Schema-driven query
export const query = defineQuery({
  input: z.object({ page: z.number().default(1) }),
  output: z.object({ users: z.array(z.object({ id: z.string(), name: z.string() })) }),
  description: "List users",
});

// Server action
export const action = defineAction({
  input: z.object({ name: z.string(), email: z.string().email() }),
  output: z.object({ success: z.boolean() }),
  description: "Create user",
});
```

## Decorators (Spring Boot Style)

```typescript
import {
  Controller, Get, Post, Put, Delete,
  Param, Body, Query,
  Service, Repository, Scheduled,
  Guard, UseGuard, ExceptionHandler,
  Injectable,
} from "@fiyuu/core/decorators";

@Controller("/api/users")
class UserController {
  constructor(private userService: UserService) {}

  @Get("/")
  async list() { return this.userService.findAll(); }

  @Get("/:id")
  async getById(@Param("id") id: string) { return this.userService.findById(id); }

  @Post("/")
  async create(@Body() dto: CreateUserDTO) { return this.userService.create(dto); }
}

@Service()
class UserService {
  constructor(private repo: UserRepository) {}
  async findAll() { return this.repo.findAll(); }
}

@Repository("users")
class UserRepository { ... }
```

## DTO Validation

```typescript
import { IsString, IsEmail, MinLength, IsOptional, validateDTO } from "@fiyuu/core/decorators";

class CreateUserDTO {
  @IsString()
  @MinLength(2)
  name!: string;

  @IsEmail()
  email!: string;

  @IsOptional()
  @IsString()
  bio?: string;
}

const user = validateDTO(CreateUserDTO, requestBody);
```

## Components

```typescript
import { FiyuuImage, FiyuuVideo, FiyuuLink, FiyuuHead } from "@fiyuu/core/components";

FiyuuImage({ src: "/hero.jpg", alt: "Hero", width: 1200, height: 600 });
FiyuuVideo({ src: "/demo.mp4", width: 1280, height: 720, poster: "/poster.jpg" });
FiyuuLink({ href: "/about", children: "About", prefetch: true });
FiyuuHead({ title: "My Page", description: "SEO description" });
```

## HTTP Exceptions

```typescript
import { NotFoundException, BadRequestException, UnauthorizedException } from "@fiyuu/core";

throw new NotFoundException("User not found");
throw new BadRequestException("Invalid email", { field: "email" });
```

## License

MIT
npm package: @fiyuu/db
Description: F1 DB - Embedded JSON database for the Fiyuu framework. Zero dependencies, zero configuration.
Latest version: 0.5.2

# @fiyuu/db

F1 DB - Embedded JSON database for the Fiyuu framework. Zero dependencies, zero configuration.

## Installation

```bash
npm install @fiyuu/db
```

## Quick Start

```typescript
import { createDB } from "@fiyuu/db";

const db = createDB({ path: ".data" });
await db.initialize();

// Insert
const user = db.table("users").insert({ name: "Ali", email: "ali@test.com" });

// Query
const users = db.table("users").find({ name: "Ali" });
const user = db.table("users").findById("d_abc123");

// Update
db.table("users").update(user._id, { name: "Ali Updated" });

// Delete
db.table("users").delete(user._id);
```

## Schema Definition

```typescript
import { defineTable } from "@fiyuu/db";

defineTable({
  name: "users",
  columns: {
    name: { type: "string" },
    email: { type: "string", unique: true },
    role: { type: "string", index: true, default: "user" },
    active: { type: "boolean", default: true },
  },
});
```

## SQL Queries

```typescript
const result = db.query("SELECT * FROM users WHERE role = ? ORDER BY name LIMIT 10", ["admin"]);
db.query("INSERT INTO users (name, email) VALUES (?, ?)", ["Ali", "ali@test.com"]);
db.query("UPDATE users SET role = ? WHERE _id = ?", ["admin", userId]);
db.query("DELETE FROM users WHERE active = ?", [false]);
```

## Transactions

```typescript
await db.transaction(async (tx) => {
  const user = tx.table("users").insert({ name: "Ali" });
  tx.table("profiles").insert({ userId: user._id, bio: "Hello" });
  // If anything throws, all changes are rolled back
});
```

## Migrations

```typescript
const runner = db.migrator();

runner.register({
  name: "001_create_users",
  version: 1,
  up: async (db) => {
    await db.createTable({
      name: "users",
      columns: { name: { type: "string" }, email: { type: "string", unique: true } },
    });
  },
  down: async (db) => {
    await db.dropTable("users");
  },
});

await runner.up(); // Apply pending migrations
```

## Features

- Zero dependencies
- JSON file storage with auto-save
- Schema validation with unique constraints
- SQL query support (SELECT, INSERT, UPDATE, DELETE)
- Transaction support with rollback
- Migration system
- Index manager for fast lookups
- Auto-generated `_id`, `_createdAt`, `_updatedAt` fields

## License

MIT
npm package: @fiyuu/realtime
Description: Real-time communication for the Fiyuu framework. WebSocket + optional NATS support with channels, rooms, and auth.
Latest version: 0.5.2

# @fiyuu/realtime

Real-time communication for the Fiyuu framework. WebSocket + optional NATS support with channels, rooms, and auth.

## Installation

```bash
npm install @fiyuu/realtime

# Optional: NATS support
npm install nats
```

## Quick Start

```typescript
import { FiyuuRealtime } from "@fiyuu/realtime";

const realtime = new FiyuuRealtime({
  transports: ["websocket"],
  websocket: { path: "/__fiyuu/ws", heartbeatMs: 30000 },
});

await realtime.initialize(httpServer);

// Create a channel
const notifications = realtime.channel("notifications");

// Publish to channel
notifications.publish("new-message", { text: "Hello!" });

// Subscribe to channel
const unsubscribe = notifications.subscribe((data) => {
  console.log("Received:", data);
});
```

## Rooms

```typescript
const ws = realtime.ws!;

// Join a socket to a room
ws.joinRoom(socketId, "room-123");

// Broadcast to room
ws.toRoom("room-123", "message", { text: "Hello room!" });

// Leave room
ws.leaveRoom(socketId, "room-123");

// List rooms
ws.listRooms(); // ["room-123", "room-456"]
```

## Authentication

```typescript
const realtime = new FiyuuRealtime({
  transports: ["websocket"],
  websocket: {
    auth: (request) => {
      const token = request.headers["authorization"];
      return !!token && verifyToken(token);
    },
  },
});
```

## NATS Transport

```typescript
const realtime = new FiyuuRealtime({
  transports: ["websocket", "nats"],
  nats: { url: "nats://localhost:4222", name: "my-app" },
});
```

## License

MIT
npm package: @fiyuu/runtime
Description: Server runtime for the Fiyuu framework. Handles HTTP server, routing, rendering, middleware, WebSocket, and background services.
Latest version: 0.5.2

# @fiyuu/runtime

Server runtime for the Fiyuu framework. Handles HTTP server, routing, rendering, middleware, WebSocket, and background services.

## Installation

```bash
npm install @fiyuu/runtime
```

## Features

- HTTP server with file-based routing
- SSR, CSR, and SSG rendering modes
- Dynamic route matching (`[id]`, `[...slug]`, `[[...optional]]`)
- Middleware pipeline
- WebSocket integration
- Background service management
- esbuild-based client bundling
- Live reload in development
- Developer tools (unified inspector)

## Architecture

```
server.ts          - Main orchestrator
server-router.ts   - Route matching engine
server-loader.ts   - Dynamic module loading & caching
server-renderer.ts - HTML document & status page rendering
server-middleware.ts - Middleware chain
server-websocket.ts - WebSocket setup
service.ts         - Background service lifecycle
bundler.ts         - esbuild client bundling
client-runtime.ts  - Client-side runtime script
```

## Route Matching

Routes are matched in order of specificity:

1. Exact matches first (O(1) lookup)
2. Dynamic segments (`/blog/[id]`)
3. Catch-all routes (`/docs/[...slug]`)
4. Optional catch-all (`/files/[[...path]]`)

## Rendering Modes

Configure per-route in `meta.ts`:

```typescript
export default defineMeta({
  intent: "User List",
  render: "ssr",      // Server-side rendering (default)
  // render: "csr",   // Client-side rendering
  // render: "ssg",   // Static site generation
  // revalidate: 300, // ISR: revalidate every 5 minutes
});
```

## License

MIT