docs: expand README with detailed setup, tech stack, development, and project structure.

This commit is contained in:
2025-12-17 06:52:58 -05:00
parent f16ac80b7e
commit c527a6eac5

View File

@@ -1,12 +1,71 @@
```
npm install
npm run dev
```
# Aniplay API
```
npm run deploy
```
API for [Aniplay](https://github.com/silverAndroid/aniplay), built with Cloudflare Workers, Hono, and Drizzle ORM.
## Tech Stack
- **Cloudflare Workers**: Serverless execution environment.
- **Hono**: Ultrafast web framework (OpenAPI).
- **GraphQL**: Used internally for communicating with the [AniList](https://anilist.co) API.
- **Drizzle ORM**: TypeScript ORM for D1 (Cloudflare's serverless SQL database).
- **Vitest**: Testing framework.
## Prerequisites
- **Node.js**
- **pnpm**: Package manager.
## Getting Started
1. **Installation**
```bash
pnpm install
```
2. **Environment Setup**
Generate the environment types:
```bash
pnpm exec wrangler types
```
3. **Database Setup**
Apply migrations to the local D1 database:
```bash
pnpm exec wrangler d1 migrations apply aniplay
```
## Development
If a route is internal-only or doesn't need to appear on the OpenAPI spec (that's autogenerated by Hono), use the `Hono` class. Otherwise, use the `OpenAPIHono` class from `@hono/zod-openapi`.
### Running Locally
Start the development server:
```bash
pnpm run dev
```
### Testing
Run the tests using Vitest:
```bash
pnpm test
```
## Deployment
Deploy to Cloudflare Workers:
```bash
pnpm run deploy
```
## Project Structure
- `src/controllers`: API route handlers (titles, episodes, search, etc.)
- `src/libs`: Shared utilities and logic (AniList integration, background tasks)
- `src/models`: Database schema and models
- `src/scripts`: Utility scripts for maintenance and setup
- `src/types`: TypeScript type definitions