diff --git a/CHANGELOG.md b/CHANGELOG.md index 2e9b8f2..776d462 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [2.0.0] - 2026-07-04 ### Added -- **Creator Info Middleware**: Injects creator attribution (name, GitHub, Telegram, timestamp) into every JSON response +- **Pagination Metadata**: All list endpoints now include `pagination` object with `currentPage`, `totalPages`, `totalItems`, `itemsPerPage`, `hasNext`, `hasPrev` +- **Creator Info Middleware**: Injects creator attribution (name, GitHub, Telegram, message, timestamp) into every JSON response - **Multi-Mirror Fallback System**: Automatic failover across 5 mirror domains (anikototv.to, anikoto.cz, anikoto.me, anikoto.net, anikototv.se) - **LRU Cache with Configurable TTL**: Replaced basic Map cache with LRU cache supporting per-endpoint TTL (3min to 60min) - **Response Compression**: Added gzip compression middleware (level 6, 1024 byte threshold) @@ -39,7 +40,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Updated `test.js` with optional endpoint handling and performance metrics ### Fixed -- **CRITICAL**: Fixed header merging bug in mirror helper (custom headers were ignored) +- **CRITICAL**: Fixed `extractPages` URL handling bug causing doubled URLs in mirror fallback +- **CRITICAL**: Fixed `creatorInfo` middleware not including `message` field in responses +- Fixed header merging bug in mirror helper (custom headers were ignored) - Fixed mirror URL construction (proper base URL handling) - Fixed cache key sorting in filter controller - Fixed trailing slash inconsistency in console output diff --git a/README.md b/README.md index 44c170e..3bd7bc1 100644 --- a/README.md +++ b/README.md @@ -337,7 +337,8 @@ AniKotoAPI/ │ │ ├── 📄 cache.helper.js # 💾 In-memory caching │ │ ├── 📄 countPages.helper.js # 📄 Pagination counter │ │ ├── 📄 extractPages.helper.js # 📃 Page fetcher -│ │ └── 📄 formatTitle.helper.js # 🔤 Title formatter +│ │ ├── 📄 formatTitle.helper.js # 🔤 Title formatter +│ │ └── 📄 pagination.helper.js # 📊 Pagination metadata generator │ │ │ ├── 📂 middleware/ # 🔧 Express middleware │ │ └── 📄 creatorInfo.js # ✍️ Creator attribution injection @@ -1933,6 +1934,38 @@ console.log(resp.data); } ``` +### Pagination Metadata + +All list endpoints include pagination metadata in the response: + +```json +{ + "success": true, + "results": { + "data": [...], + "pagination": { + "currentPage": 1, + "totalPages": 294, + "totalItems": 8820, + "itemsPerPage": 30, + "hasNext": true, + "hasPrev": false + } + } +} +``` + +| Field | Type | Description | +|:---|:---|:---| +| `currentPage` | `number` | Current page number (1-indexed) | +| `totalPages` | `number` | Total number of pages available | +| `totalItems` | `number` | Estimated total items across all pages | +| `itemsPerPage` | `number` | Number of items per page (default: 30) | +| `hasNext` | `boolean` | Whether there is a next page | +| `hasPrev` | `boolean` | Whether there is a previous page | + +**Endpoints with pagination:** `/api/search`, `/api/most-popular`, `/api/new-release`, `/api/newly-added`, `/api/latest-updated`, `/api/az-list/:letter`, `/api/filter`, `/api/genre/:name`, `/api/type/:name`, `/api/status/:name` + ### Anime Item Object | Field | Type | Description | Example | diff --git a/docs/architecture.md b/docs/architecture.md index fd32151..15a6b5a 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -82,7 +82,8 @@ AniKotoAPI/ │ └── helper/ │ ├── cache.helper.js # LRU cache with configurable TTL │ ├── mirror.helper.js # Multi-mirror fallback (5 domains) -│ └── extractPages.helper.js # Page fetching with mirror fallback +│ ├── extractPages.helper.js # Page fetching with mirror fallback +│ └── pagination.helper.js # Pagination metadata generator │ │ └── middleware/ │ └── creatorInfo.js # Creator attribution injection diff --git a/docs/endpoints.md b/docs/endpoints.md index 668d3a7..2daaf0c 100644 --- a/docs/endpoints.md +++ b/docs/endpoints.md @@ -4,6 +4,40 @@ Base URL: `https://anikototvapi.vercel.app/api` --- +## Pagination + +All list endpoints include pagination metadata in the response: + +```json +{ + "success": true, + "results": { + "data": [...], + "pagination": { + "currentPage": 1, + "totalPages": 294, + "totalItems": 8820, + "itemsPerPage": 30, + "hasNext": true, + "hasPrev": false + } + } +} +``` + +| Field | Type | Description | +|:---|:---|:---| +| `currentPage` | `number` | Current page number (1-indexed) | +| `totalPages` | `number` | Total number of pages available | +| `totalItems` | `number` | Estimated total items across all pages | +| `itemsPerPage` | `number` | Number of items per page (default: 30) | +| `hasNext` | `boolean` | Whether there is a next page | +| `hasPrev` | `boolean` | Whether there is a previous page | + +**Endpoints with pagination:** `/api/search`, `/api/most-popular`, `/api/new-release`, `/api/newly-added`, `/api/latest-updated`, `/api/az-list/:letter`, `/api/filter`, `/api/genre/:name`, `/api/type/:name`, `/api/status/:name` + +--- + ## GET / Returns homepage data: spotlight anime, trending, top-airing, and genres. diff --git a/docs/index.md b/docs/index.md index d6db0a6..dd3044c 100644 --- a/docs/index.md +++ b/docs/index.md @@ -62,6 +62,7 @@ curl "https://anikototvapi.vercel.app/api/info?id=road-of-naruto-ggjw8" - **LRU Cache** — Configurable TTL per endpoint type (3min to 60min) - **Multi-Mirror Fallback** — Automatic failover across 5 mirror domains - **Response Compression** — Gzip compression for faster responses +- **Pagination Metadata** — All list endpoints include `pagination` object with `currentPage`, `totalPages`, `hasNext`, `hasPrev` - **CORS Enabled** — Access from any domain - **JSON Responses** — Standardized `{success, results}` format