Skip to content

Commit

Permalink
1.1.6: add key for disable or change userAgent
Browse files Browse the repository at this point in the history
  • Loading branch information
kravetsone committed Nov 10, 2022
1 parent bc1d71f commit fde6dd4
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,11 @@ import { EnkaNetwork } from "enkanetwork"; //const { EnkaNetwork } = require("en
const enka = new EnkaNetwork({ language: "EN", caching: true });
```
| Key | In API | Type | Description | Required? |
| -------- | ------ | ------- | ----------------------------------------------------------------------------------------------------- | --------- |
| language | - | number | The language to be used in the localization of names (characters, artifacts, etc.). Default is «`EN`» | - |
| caching | - | boolean | Cache responses? Default is `true` | - |
| Key | In API | Type | Description | Required? |
| --------- | ------ | ----------------- | ----------------------------------------------------------------------------------------------------- | --------- |
| language | - | number | The language to be used in the localization of names (characters, artifacts, etc.). Default is «`EN`» | - |
| caching | - | boolean | Cache responses? Default is `true` | - |
| userAgent | - | string or boolean | Disable or change the header `User-Agent`. (`false` for disable) | - |
## Fetch user by uid from the game (response is [FetchUserUID](#fetchuseruid))
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "enkanetwork",
"version": "1.1.5",
"version": "1.1.6",
"description": "NodeJS/TypeScript api wrapper data from https://enka.network/",
"main": "./dist/index.js",
"module": "./dist/index.js",
Expand Down
13 changes: 11 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,23 @@ export class EnkaNetwork {
language: TLanguage;
private readonly request: Axios;
private readonly cache?: NodeCache;
constructor(data: { language?: TLanguage; caching: boolean }) {
constructor(data: {
language?: TLanguage;
caching: boolean;
userAgent?: string | boolean;
}) {
this.language = data.language || "EN";
this.request = new Axios({
baseURL: "https://enka.network",
timeout: 10 * 1000,
headers: {
Accept: "application/json",
"User-Agent": "enkaNetwork@1.1.5",
...(data.userAgent !== false && {
"User-Agent":
typeof data.userAgent == "string"
? data.userAgent
: "enkaNetwork@1.1.6",
}),
},
});
this.cache =
Expand Down

0 comments on commit fde6dd4

Please sign in to comment.