Skip to content
This repository has been archived by the owner on Jan 24, 2022. It is now read-only.

Commit

Permalink
fix(API): Use Array#find since its array not an object (#104)
Browse files Browse the repository at this point in the history
* fix(API): Use Array#find since its array not an object

* fix(ci): Solve eslint error
  • Loading branch information
satoufuyuki authored Dec 23, 2020
1 parent 962af8d commit f2157a3
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 39 deletions.
4 changes: 2 additions & 2 deletions dist/src/Zhycorp.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ class ZhycorpWrapper {
if (!USER_PATTERN.test(id))
throw Error("Invalid user id");
const { body: result } = await superagent_1.get(this.baseURL);
if (!result[id])
if (!result.find((b) => b.botID === id))
throw new ZhycorpError_1.default("Not Found");
const bot = result[id];
const bot = result.find((b) => b.botID === id);
const user = await Bot_1.getOwner(id);
return {
approved: bot.approved,
Expand Down
4 changes: 2 additions & 2 deletions src/Zhycorp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ export class ZhycorpWrapper {
if (!USER_PATTERN.test(id)) throw Error("Invalid user id");

const { body: result } = await get(this.baseURL);
if (!result[id]) throw new ZhycorpError("Not Found");
const bot = result[id];
if (!result.find((b: Bot) => b.botID === id)) throw new ZhycorpError("Not Found");
const bot = result.find((b: Bot) => b.botID === id);
const user = await getOwner(id);
return {
approved: bot.approved,
Expand Down
35 changes: 0 additions & 35 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -145,14 +145,6 @@
"@typescript-eslint/typescript-estree" "4.11.0"
debug "^4.1.1"

"@typescript-eslint/[email protected]":
version "4.10.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-4.10.0.tgz#dbd7e1fc63d7363e3aaff742a6f2b8afdbac9d27"
integrity sha512-WAPVw35P+fcnOa8DEic0tQUhoJJsgt+g6DEcz257G7vHFMwmag58EfowdVbiNcdfcV27EFR0tUBVXkDoIvfisQ==
dependencies:
"@typescript-eslint/types" "4.10.0"
"@typescript-eslint/visitor-keys" "4.10.0"

"@typescript-eslint/[email protected]":
version "4.11.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-4.11.0.tgz#2d906537db8a3a946721699e4fc0833810490254"
Expand All @@ -161,30 +153,11 @@
"@typescript-eslint/types" "4.11.0"
"@typescript-eslint/visitor-keys" "4.11.0"

"@typescript-eslint/[email protected]":
version "4.10.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-4.10.0.tgz#12f983750ebad867f0c806e705c1953cd6415789"
integrity sha512-+dt5w1+Lqyd7wIPMa4XhJxUuE8+YF+vxQ6zxHyhLGHJjHiunPf0wSV8LtQwkpmAsRi1lEOoOIR30FG5S2HS33g==

"@typescript-eslint/[email protected]":
version "4.11.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-4.11.0.tgz#86cf95e7eac4ccfd183f9fcf1480cece7caf4ca4"
integrity sha512-XXOdt/NPX++txOQHM1kUMgJUS43KSlXGdR/aDyEwuAEETwuPt02Nc7v+s57PzuSqMbNLclblQdv3YcWOdXhQ7g==

"@typescript-eslint/[email protected]":
version "4.10.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-4.10.0.tgz#1e62e45fd57866afd42daf5e9fb6bd4e8dbcfa75"
integrity sha512-mGK0YRp9TOk6ZqZ98F++bW6X5kMTzCRROJkGXH62d2azhghmq+1LNLylkGe6uGUOQzD452NOAEth5VAF6PDo5g==
dependencies:
"@typescript-eslint/types" "4.10.0"
"@typescript-eslint/visitor-keys" "4.10.0"
debug "^4.1.1"
globby "^11.0.1"
is-glob "^4.0.1"
lodash "^4.17.15"
semver "^7.3.2"
tsutils "^3.17.1"

"@typescript-eslint/[email protected]":
version "4.11.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-4.11.0.tgz#1144d145841e5987d61c4c845442a24b24165a4b"
Expand All @@ -199,14 +172,6 @@
semver "^7.3.2"
tsutils "^3.17.1"

"@typescript-eslint/[email protected]":
version "4.10.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-4.10.0.tgz#9478822329a9bc8ebcc80623d7f79a01da5ee451"
integrity sha512-hPyz5qmDMuZWFtHZkjcCpkAKHX8vdu1G3YsCLEd25ryZgnJfj6FQuJ5/O7R+dB1ueszilJmAFMtlU4CA6se3Jg==
dependencies:
"@typescript-eslint/types" "4.10.0"
eslint-visitor-keys "^2.0.0"

"@typescript-eslint/[email protected]":
version "4.11.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-4.11.0.tgz#906669a50f06aa744378bb84c7d5c4fdbc5b7d51"
Expand Down

0 comments on commit f2157a3

Please sign in to comment.