# @joker.server/core

`@joker.server/core` is the core server-side framework of the Joker ecosystem. Built upon the KOA framework, it's designed to empower developers with an efficient and streamlined experience for building server-side applications. By inheriting KOA's lightweight and flexible nature, it simplifies common server-side development workflows through thoughtful encapsulation and extensions.

## Key Features

-   **KOA-Powered Foundation**: Fully compatible with KOA's middleware architecture and ecosystem. Seamlessly integrate existing KOA middleware (e.g., `koa-router`, `koa-bodyparser`) to minimize learning curve and migration efforts.
-   **Simplified Configuration**: Offers straightforward initialization and sensible defaults, reducing boilerplate code and letting developers focus on business logic.
-   **Batteries-Included**: Bundles essential features like routing, request handling, and error trapping, eliminating the need to stitch together multiple libraries.
-   **Highly Extensible**: Supports custom middleware and plugins, adapting flexibly to diverse project requirements.
-   **Integrated Caching**: Manages multiple caching strategies (in-memory, Redis, etc.) to boost response times and reduce server load.
-   **Request Validation**: Automatically checks incoming parameters against predefined rules (types, ranges, required fields), minimizing manual validation code.
-   **JWT Authentication**: Implements JSON Web Token authentication with token generation, verification, and role-based access control for secure API endpoints.

## Quick Start

### Installation

Install via npm or yarn:

```bash
npm install @joker.server/core
# or
pnpm add @joker.server/core
```

### Basic Usage

Initialize the server, register routes, and start serving requests in just a few lines of code.

## Relationship with KOA

`@joker.server/core` is built on top of KOA, inheriting its core `app` instance. This means:

-   All native KOA methods (e.g., `use`, `listen`) work out-of-the-box.
-   KOA ecosystem middleware can be directly imported and used, ensuring full compatibility with existing KOA projects.
-   Leverages KOA's `async/await`-based asynchronous flow control for cleaner, more readable code without callback hell.
