diff --git a/source/app/action/index.mjs b/source/app/action/index.mjs index 00b913f0..1687e8a0 100644 --- a/source/app/action/index.mjs +++ b/source/app/action/index.mjs @@ -185,7 +185,7 @@ function quit(reason) { //Test token validity and requests count else if (!/^NOT_NEEDED$/.test(token)) { //Check rate limit - const {data} = await api.rest.request("GET /rate_limit", {}).catch(() => ({data:{resources:{}}})) + const {data} = await api.rest.rateLimit.get().catch(() => ({data:{resources:{}}})) Object.assign(resources, data.resources) info("API requests (REST)", resources.core ? `${resources.core.remaining}/${resources.core.limit}` : "(unknown)") info("API requests (GraphQL)", resources.graphql ? `${resources.graphql.remaining}/${resources.graphql.limit}` : "(unknown)") @@ -600,7 +600,7 @@ function quit(reason) { info.break() info.section("Consumed API requests") info(" * provided that no other app used your quota during execution", "") - const {data:current} = await rest.request("GET /rate_limit", {}).catch(() => ({data:{resources:{}}})) + const {data:current} = await rest.rateLimit.get().catch(() => ({data:{resources:{}}})) for (const type of ["core", "graphql", "search"]) { const used = resources[type].remaining - current.resources[type].remaining info({core:"REST API", graphql:"GraphQL API", search:"Search API"}[type], (Number.isFinite(used)&&(used >= 0)) ? used : "(unknown)") diff --git a/tests/mocks/api/github/rest/activity/listEventsForAuthenticatedUser.mjs b/tests/mocks/api/github/rest/activity/listEventsForAuthenticatedUser.mjs index 08421d04..c2d988f7 100644 --- a/tests/mocks/api/github/rest/activity/listEventsForAuthenticatedUser.mjs +++ b/tests/mocks/api/github/rest/activity/listEventsForAuthenticatedUser.mjs @@ -1,5 +1,5 @@ /**Mocked data */ -export default function({ faker }, target, that, [{ username: login, page, per_page }]) { +export default async function({ faker }, target, that, [{ username: login, page, per_page }]) { console.debug("metrics/compute/mocks > mocking rest api result > rest.activity.listEventsForAuthenticatedUser") return ({ status: 200, diff --git a/tests/mocks/api/github/rest/activity/listRepoEvents.mjs b/tests/mocks/api/github/rest/activity/listRepoEvents.mjs index 139252cd..79b9fc60 100644 --- a/tests/mocks/api/github/rest/activity/listRepoEvents.mjs +++ b/tests/mocks/api/github/rest/activity/listRepoEvents.mjs @@ -2,7 +2,7 @@ import listEventsForAuthenticatedUser from "./listEventsForAuthenticatedUser.mjs" /**Mocked data */ -export default function({ faker }, target, that, [{ username: login, page, per_page }]) { +export default async function({ faker }, target, that, [{ username: login, page, per_page }]) { console.debug("metrics/compute/mocks > mocking rest api result > rest.activity.listRepoEvents") return listEventsForAuthenticatedUser(...arguments) } diff --git a/tests/mocks/api/github/rest/emojis/get.mjs b/tests/mocks/api/github/rest/emojis/get.mjs index d91dc51e..e26492cd 100644 --- a/tests/mocks/api/github/rest/emojis/get.mjs +++ b/tests/mocks/api/github/rest/emojis/get.mjs @@ -1,5 +1,5 @@ /**Mocked data */ -export default function({ faker }, target, that) { +export default async function({ faker }, target, that) { console.debug("metrics/compute/mocks > mocking rest api result > rest.emojis.get") return ({ status: 200, diff --git a/tests/mocks/api/github/rest/rateLimit/get.mjs b/tests/mocks/api/github/rest/rateLimit/get.mjs index 9a468bdb..5b8ec340 100644 --- a/tests/mocks/api/github/rest/rateLimit/get.mjs +++ b/tests/mocks/api/github/rest/rateLimit/get.mjs @@ -1,5 +1,5 @@ /**Mocked data */ -export default function({ faker }, target, that, args) { +export default async function({ faker }, target, that, args) { return ({ status: 200, url: "https://api.github.com/rate_limit", diff --git a/tests/mocks/api/github/rest/repos/getContributorsStats.mjs b/tests/mocks/api/github/rest/repos/getContributorsStats.mjs index bf6d70fa..87eef477 100644 --- a/tests/mocks/api/github/rest/repos/getContributorsStats.mjs +++ b/tests/mocks/api/github/rest/repos/getContributorsStats.mjs @@ -1,5 +1,5 @@ /**Mocked data */ -export default function({ faker }, target, that, [{ owner, repo }]) { +export default async function({ faker }, target, that, [{ owner, repo }]) { console.debug("metrics/compute/mocks > mocking rest api result > rest.repos.getContributorsStats") return ({ status: 200, diff --git a/tests/mocks/api/github/rest/repos/getViews.mjs b/tests/mocks/api/github/rest/repos/getViews.mjs index 8516271b..bce3ba9d 100644 --- a/tests/mocks/api/github/rest/repos/getViews.mjs +++ b/tests/mocks/api/github/rest/repos/getViews.mjs @@ -1,5 +1,5 @@ /**Mocked data */ -export default function({ faker }, target, that, [{ owner, repo }]) { +export default async function({ faker }, target, that, [{ owner, repo }]) { console.debug("metrics/compute/mocks > mocking rest api result > rest.repos.getViews") const count = faker.datatype.number(10000) * 2 const uniques = faker.datatype.number(count) * 2 diff --git a/tests/mocks/api/github/rest/repos/listCommits.mjs b/tests/mocks/api/github/rest/repos/listCommits.mjs index 60b15449..eaf0ab81 100644 --- a/tests/mocks/api/github/rest/repos/listCommits.mjs +++ b/tests/mocks/api/github/rest/repos/listCommits.mjs @@ -1,5 +1,5 @@ /**Mocked data */ -export default function({ faker }, target, that, [{ page, per_page, owner, repo }]) { +export default async function({ faker }, target, that, [{ page, per_page, owner, repo }]) { console.debug("metrics/compute/mocks > mocking rest api result > rest.repos.listCommits") return ({ status: 200, diff --git a/tests/mocks/api/github/rest/repos/listContributors.mjs b/tests/mocks/api/github/rest/repos/listContributors.mjs index 22117a60..45499d90 100644 --- a/tests/mocks/api/github/rest/repos/listContributors.mjs +++ b/tests/mocks/api/github/rest/repos/listContributors.mjs @@ -1,5 +1,5 @@ /**Mocked data */ -export default function({ faker }, target, that, [{ owner, repo }]) { +export default async function({ faker }, target, that, [{ owner, repo }]) { console.debug("metrics/compute/mocks > mocking rest api result > rest.repos.listContributors") return ({ status: 200, diff --git a/tests/mocks/api/github/rest/request.mjs b/tests/mocks/api/github/rest/request.mjs index e96b30aa..3ef19fef 100644 --- a/tests/mocks/api/github/rest/request.mjs +++ b/tests/mocks/api/github/rest/request.mjs @@ -1,5 +1,5 @@ /**Mocked data */ -export default function({ faker }, target, that, args) { +export default async function({ faker }, target, that, args) { //Arguments const [url] = args //Head request diff --git a/tests/mocks/api/github/rest/users/getByUsername.mjs b/tests/mocks/api/github/rest/users/getByUsername.mjs index 22d80e4f..93214e7d 100644 --- a/tests/mocks/api/github/rest/users/getByUsername.mjs +++ b/tests/mocks/api/github/rest/users/getByUsername.mjs @@ -1,5 +1,5 @@ /**Mocked data */ -export default function({ faker }, target, that, [{ username }]) { +export default async function({ faker }, target, that, [{ username }]) { console.debug("metrics/compute/mocks > mocking rest api result > rest.repos.getByUsername") return ({ status: 200, diff --git a/tests/mocks/api/github/rest/users/listGpgKeysForUser.mjs b/tests/mocks/api/github/rest/users/listGpgKeysForUser.mjs index e5329d20..2e5ed3fb 100644 --- a/tests/mocks/api/github/rest/users/listGpgKeysForUser.mjs +++ b/tests/mocks/api/github/rest/users/listGpgKeysForUser.mjs @@ -1,5 +1,5 @@ /**Mocked data */ -export default function({ faker }, target, that, [{ username }]) { +export default async function({ faker }, target, that, [{ username }]) { console.debug("metrics/compute/mocks > mocking rest api result > rest.users.listGpgKeysForUser") return ({ status: 200,