@akomalabs/kemono
Version:
A production-grade TypeScript API wrapper for the Kemono/Coomer platforms
62 lines • 2.16 kB
JavaScript
import { CreatorsApi } from './api/creators';
import { PostsApi } from './api/posts';
import { FavoritesApi } from './api/favorites';
import { HttpClient } from './utils/http-client';
import { createLogger } from './utils/logger';
import { createCache } from './utils/cache';
import { createRateLimiter } from './utils/rate-limiter';
import { KemonoConfigSchema } from './schemas';
/**
* Main Kemono API client
* @example
* ```typescript
* const client = new KemonoClient({
* sessionKey: 'your-session-key',
* cache: {
* enabled: true,
* ttl: 300,
* },
* rateLimit: {
* maxRequests: 100,
* windowMs: 60,
* },
* });
*
* // List all creators
* const creators = await client.creators.listAll();
*
* // Get recent posts
* const posts = await client.posts.listRecent();
*
* // Add a creator to favorites
* await client.favorites.addCreator('fanbox', '12345');
* ```
*/
export class KemonoClient {
httpClient;
/** Creators API endpoints */
creators;
/** Posts API endpoints */
posts;
/** Favorites API endpoints */
favorites;
constructor(config = {}) {
// Validate configuration using Zod schema
const validatedConfig = KemonoConfigSchema.parse(config);
const logger = createLogger(validatedConfig.logging);
const cache = createCache(validatedConfig.cache, logger);
const rateLimiter = createRateLimiter(validatedConfig.rateLimit, logger);
this.httpClient = new HttpClient(validatedConfig, cache, rateLimiter, logger);
// Initialize API endpoints
this.creators = new CreatorsApi(this.httpClient);
this.posts = new PostsApi(this.httpClient);
this.favorites = new FavoritesApi(this.httpClient);
}
}
// Export error types
export { KemonoApiError, AuthenticationError, NotFoundError, ValidationError, RateLimitError, } from './errors/api-error';
// Export schemas and schema-inferred types
export {
// Schemas
KemonoBaseUrlSchema, KemonoServiceSchema, KemonoConfigSchema, FileSchema, AttachmentSchema, PostSchema, CreatorSchema, SearchParamsSchema, } from './schemas';
//# sourceMappingURL=index.js.map