UNPKG

ctan

Version:

CTAN (Comprehensive TeX Archive Network) API client for Node.js

38 lines (37 loc) 1.57 kB
import { ClientBase, buildParams } from "../../client-base.js"; import { Searchable } from "../search/mixin.js"; import * as schemas from "./schemas.js"; export class Client extends ClientBase { constructor(base) { super(base); } async authors(params, config) { return await this.get(`/json/2.0/authors`, buildParams(params, ["key"]), schemas.Authors, config); } async author(key, params, config) { return await this.get(`/json/2.0/author/${key}`, buildParams(params, ["ref"]), schemas.Authors.items, config); } async topics(params, config) { return await this.get('/json/2.0/topics', buildParams(params, ["key"]), schemas.Topics, config); } async topic(key, params, config) { return await this.get(`/json/2.0/topic/${key}`, buildParams(params, ["ref"]), schemas.Topic, config); } async packages(params, config) { return await this.get('/json/2.0/packages', buildParams(params, ["key"]), schemas.Packages, config); } async pkg(key, params, config) { const urlparams = buildParams(params, ["drop", "keep-url"]); urlparams.delete('drop'); return await this.get(`/json/2.0/pkg/${key}`, urlparams, schemas.Package, config); } async licenses(params, config) { return await this.get('/json/2.0/licenses', buildParams(params, ["key"]), schemas.Licenses, config); } async version(config) { return await this.get('/json/2.0/version', null, schemas.ApiVersion, config); } } (() => { Searchable.mixin(Client); })();