aghpb-api v1.0.1
Installation
npm i aghpb-api
About
aghpb-api is a module to easily interact with laynH/Anime-Girls-Holding-Programming-Books (aghpb for short) using the GitHub REST API v3. Due to strict non-authorized GitHub ratelimits, some form of authorization is recommended (OAuth / other).
Examples
Basic Documentation
createClient(authorization?: string): Promise<Client>
Shortener for new Client(authorization).init()
Client
The class used to make requests and store API data.
constructor(authorization?: string)
authorization
: an optional string used to authorize HTTP requests
init(): Promise<Client>
Fetches all directories of the repository, and populates .languages
fetchAll(): Promise<TreeItem[]>
Fetches the contents of all directories in the repository
fetchAllNames(): Promise<string[]>
Fetches all image names in the repository
fetchAllURLs(): Promise<string[]>
Fetches all image URLs in the repository
search(str: string): Promise<string[]>
Sorts all image URLs by similarity to the passed string
.languages: Record<string, Language>
An object with the repository's directory names as keys, and Language
instances as values. (empty before init
is called)
.languageProxy: Record<string, Language>
A proxy for accessing case-insensitive properties on .languages
Language
The class for managing a directory. (should not be manually constructed, instances are available through Client.prototype.languages
)
fetchRawImages(): Promise<TreeItem[]>
Fetches the raw contents of the directory
fetchImageNames(): Promise<string[]>
Fetches the image names of the directory
fetchImages(): Promise<string[]>
Fetches the image URLs of the directory
search(str: string): Promise<string[]>
Sorts the directory's image URLs by similarity to the passed string
TreeItem
Raw file data returned from the GitHub API.
.path: string
The filename
.mode: string
The file mode
.type: string
Either blob
, tree
, or commit
.sha: string
The SHA1 checksum ID of the object in the tree
.url: string
The API URL