UNPKG

paheal

Version:

Simple and user-friendly Wrapper of Rule 34 Paheal

167 lines (133 loc) 4.97 kB
<div align="center"> <a href="https://discord.gg/Cak7GBJ"><img src="https://cdn.discordapp.com/attachments/707201738255368194/897181637907980348/paheal_non-background.png" width="546" alt="paheal"></a> </div> <h1 align="center" font-weight="bold">paheal</h1> <p align="center"> <a href="https://discord.gg/Cak7GBJ"><img src="https://img.shields.io/discord/714877734978846830?color=7289da&logo=discord&logoColor=white" alt="Discord Support" /></a> <a href="https://opensource.org/licenses/MIT" target="_blank"><img src="https://img.shields.io/badge/License-MIT-blue.svg" alt="License"></a> <img src="https://img.shields.io/npm/dt/paheal" alt="NPM downloads"> <img src="https://img.shields.io/npm/v/paheal" alt="NPM version"> </p> > #### Simple and User-Friendly API for [rule34 paheal](https://rule34.paheal.net/). > #### Recommended for REST API, Bots, Sites #### Table of content: * **[Installation](#installation)** * **[Usage](#usage)** * **[Methods](#methods)** * [search()](#search) * [getMedia()](#getMedia) * [byAuthor()](#byAuthor) * **[Data models](#data-models)** * [Media](#media) * [Search Class](#search-class) * [Search Result](#Search-Result) * **[Catching Errors without .catch()](#Catching-Errors-without-catch)** * **[Discord Support](#Support)** * **[License](#license)** ## Installation ```bash $ npm install paheal ``` ## Usage ```js // in async function const paheal = require('paheal') const API = new paheal // Get a Random Doujin await API.search().then(search => console.log(search.results)) // Get a indicated Doujin await API.getMedia(1).then(media => console.log(media)) // Searching await API.byAuthor('dev').then(search => console.log(search.results)) // Next Page const search = await API.search('devil') const nextPage = await search.next() console.log(nextPage.results) ``` ## Methods ### search() > *Returns the **[not full object](#Search-Result)** of a post.* > | Param | Type | Description | > | --- | --- | --- | > | tags | [string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String) | Tags into Search | > > Usage example: > ```js > // in async function > const search = await paheal.search('devil') > console.log(search.results) > ``` > > ###### *Returns: [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[Search model](#search-class) [object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)>* --- ### getMedia() > | Param | Type | Description | > | --- | --- | --- | > | id | [string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)/[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number) | ID of Media Post | > > Usage example: > ```js > // in async function > const media = await paheal.getMedia(1) > console.log(media.href) > ``` > > ###### *Returns: [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[Media model](#media) [object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)>* --- ### byAuthor() > *Returns the **[not full object](#Search-Result)** of a post.* > | Param | Type | Description | > | --- | --- | --- | > | name | [string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String) | Find posts by some Author | > > Usage example: > ```js > // in async function > const search = await paheal.byAuthor('noname') > console.log(search.results) > ``` > > ###### *Returns: [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[Search model](#search-class) [object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)>* --- ## Data Models ### Media ```js { author: String, tags: String[], src: String, href: String } ``` ### Search Class ```js searchResult { results: Array<SearchResult> lastPage: Number, currentPage: Number } ``` ### Search Result ```js { id: Number, tags: String[], href: String } ``` ## Catching Errors without .catch() In a Node.JS 15.x, reject use a strict mode. So, when Promise returns a reject, your app crashes. <br>So, my library is user-friendly, and i don't want crash your app, if some wrong. So, how you can catch a errors? For Example: ```js // in async function let search = await paheal.search('devil') if (search.status) return console.error(search.message); ``` And, your app don't be crashes :) ## Support [Discord Server](https://discord.gg/Cak7GBJ) --- ## License MIT License Copyright © Mikun Hatsune