Skip to content

Commit

Permalink
feat: v1.3.10
Browse files Browse the repository at this point in the history
  • Loading branch information
janleigh committed Jul 19, 2022
1 parent 12c2170 commit a8d3785
Show file tree
Hide file tree
Showing 17 changed files with 260 additions and 270 deletions.
4 changes: 2 additions & 2 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ insert_final_newline = true

[*.{js,json,yml}]
charset = utf-8
indent_style = space
indent_size = 2
indent_style = tab
indent_size = 4
40 changes: 20 additions & 20 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
{
"env": {
"es2021": true,
"node": true
},
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended"
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 7,
"sourceType": "module"
},
"plugins": [
"@typescript-eslint"
],
"rules": {
"@typescript-eslint/no-explicit-any": "off"
}
}
"env": {
"es2021": true,
"node": true
},
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended"
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 7,
"sourceType": "module"
},
"plugins": [
"@typescript-eslint"
],
"rules": {
"@typescript-eslint/no-explicit-any": "off"
}
}
27 changes: 21 additions & 6 deletions README.md → .github/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,18 @@ this readme sucks
</div>

<!--- INSTALLATION --->
### ❖ Installation
## :wrench: <samp>INSTALLATION</samp>

You can use the following command to install this package, or replace `yarn add` with your package manager of choice.
```
$ yarn add trace.moe.ts
$ yarn add trace.moe.ts
```

---

<!--- USAGE --->
### ❖ Usage
## :rocket: <samp>USAGE</samp>

```js
const { TraceMoe } = require("trace.moe.ts");
// ES6 Import.
Expand All @@ -48,7 +50,7 @@ this readme sucks
await api.fetchMe(); // Returns Promise<MeResult>
```

### ❖ Example Responses
## :scroll: <samp>EXAMPLES</samp>

* `API#fetchAnime()` and `API#fetchAnimeFromBuffer()`
```js
Expand Down Expand Up @@ -97,6 +99,19 @@ this readme sucks

---

<!--- DONATIONS --->
## :money_with_wings: <samp>TIP JAR</samp>

If you enjoyed it and would like to show your appreciation, you may want to tip me here.

It is never required but always appreciated. Thanks from the bottom of my heart!

| Donate With | Address |
| :-----------: | :------------------------------------------------: |
| Ko-fi | [Click Here](https://ko-fi.com/M4M272EAY) |
| PayPal | [Click Here](https://paypal.me/JanLeighAugustineM) |

<!--- LICENSE --->
### ❖ License
* This project is licensed under the [GPL-3.0](LICENSE) license.
## :book: <samp>LICENSE</samp>

This project is licensed under the [GPL-3.0](LICENSE) license.
8 changes: 8 additions & 0 deletions .github/renovate.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"extends": [
"config:base"
],
"ignorePresets": [ ":dependencyDashboard" ],
"labels": [ "Type: Dependencies" ],
"schedule": [ "every weekend" ]
}
1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Folders
.circleci
.github
.yarn
node_modules
lib
Expand Down
17 changes: 9 additions & 8 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
{
"semi": true,
"trailingComma": "none",
"tabWidth": 4,
"bracketSpacing": true,
"singleQuote": false,
"arrowParens": "always",
"quoteProps": "consistent",
"printWidth": 120
"semi": true,
"trailingComma": "none",
"useTabs": true,
"tabWidth": 4,
"bracketSpacing": true,
"singleQuote": false,
"arrowParens": "always",
"quoteProps": "consistent",
"printWidth": 120
}
62 changes: 0 additions & 62 deletions CHANGELOG.md

This file was deleted.

File renamed without changes.
140 changes: 70 additions & 70 deletions lib/classes/API.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,84 +6,84 @@ import { SearchResponse } from "../structures/SearchResponse";
import { Utils } from "./Utils";

export class API {
private uris: {
search: string;
me: string;
};
private uris: {
search: string;
me: string;
};

/**
* The utils class.
*/
public utils: Utils;
/**
* The utils class.
*/
public utils: Utils;

/**
* Constructs an instance of the API.
*/
constructor() {
this.uris = {
search: Endpoints.SEARCH,
me: Endpoints.ME
};
this.utils = new Utils();
}
/**
* Constructs an instance of the API.
*/
constructor() {
this.uris = {
search: Endpoints.SEARCH,
me: Endpoints.ME
};
this.utils = new Utils();
}

/**
* Searches the website for the similar anime.
* @param {string} imageURL The URL for the image.
* @param {SearchParameters} options Optional parameters for the search.
* @returns {SearchResponse}
*/
async fetchAnime(imageURL: string, options?: SearchParameters): Promise<SearchResponse> {
if (!imageURL || typeof imageURL !== "string")
throw new TypeError(`'imageURL' should be type string. Got type ${typeof imageURL} instead.`);
/**
* Searches the website for the similar anime.
* @param {string} imageURL The URL for the image.
* @param {SearchParameters} options Optional parameters for the search.
* @returns {SearchResponse}
*/
async fetchAnime(imageURL: string, options?: SearchParameters): Promise<SearchResponse> {
if (!imageURL || typeof imageURL !== "string")
throw new TypeError(`'imageURL' should be type string. Got type ${typeof imageURL} instead.`);

const url = this.utils.handleOptionalParameters(this.uris.search, imageURL, options);
const url = this.utils.handleOptionalParameters(this.uris.search, imageURL, options);

return await fetch(url)
.then((res) => res.json())
.catch((err) => {
throw new Error(err);
});
}
return await fetch(url)
.then((res) => res.json())
.catch((err) => {
throw new Error(err);
});
}

/**
* Searches the website for the similar anime but this time using an image file.
* @param {Buffer} buffer The image buffer. Limited to 25 MB.
* @param {SearchParameters} options Optional parameters for the search.
* @returns {SearchResponse}
*/
async fetchAnimeFromBuffer(buffer: Buffer, options?: SearchParameters): Promise<SearchResponse> {
if (!buffer || !(buffer instanceof Buffer))
throw new TypeError(`'buffer' should be type Buffer. Got type ${typeof buffer} instead.`);
/**
* Searches the website for the similar anime but this time using an image file.
* @param {Buffer} buffer The image buffer. Limited to 25 MB.
* @param {SearchParameters} options Optional parameters for the search.
* @returns {SearchResponse}
*/
async fetchAnimeFromBuffer(buffer: Buffer, options?: SearchParameters): Promise<SearchResponse> {
if (!buffer || !(buffer instanceof Buffer))
throw new TypeError(`'buffer' should be type Buffer. Got type ${typeof buffer} instead.`);

const url = this.utils.handleOptionalParameters(this.uris.search, undefined, options);
const url = this.utils.handleOptionalParameters(this.uris.search, undefined, options);

return await fetch(url, {
method: "POST",
body: buffer,
headers: {
"Content-Type": "application/x-www-form-urlencoded"
}
})
.then((res) => res.json())
.catch((err) => {
throw new Error(err);
});
}
return await fetch(url, {
method: "POST",
body: buffer,
headers: {
"Content-Type": "application/x-www-form-urlencoded"
}
})
.then((res) => res.json())
.catch((err) => {
throw new Error(err);
});
}

/**
* Returns your search quota and limits for your account.
* @param {string} key Your API key for trace.moe.
* @returns {MeResponse}
*/
async fetchMe(key?: string): Promise<MeResponse> {
let url = this.uris.me;
if (key) url += `?key=${key}`;
/**
* Returns your search quota and limits for your account.
* @param {string} key Your API key for trace.moe.
* @returns {MeResponse}
*/
async fetchMe(key?: string): Promise<MeResponse> {
let url = this.uris.me;
if (key) url += `?key=${key}`;

return await fetch(url)
.then((res) => res.json())
.catch((err) => {
throw new Error(err);
});
}
return await fetch(url)
.then((res) => res.json())
.catch((err) => {
throw new Error(err);
});
}
}
Loading

0 comments on commit a8d3785

Please sign in to comment.