Skip to content

Commit

Permalink
refactor: move type to types file
Browse files Browse the repository at this point in the history
  • Loading branch information
wolfy1339 committed Sep 24, 2024
1 parent e2d7b3d commit c5cb5c2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
10 changes: 3 additions & 7 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import BottleneckLight from "bottleneck/light.js";
import type TBottleneck from "bottleneck";
import type { Octokit, OctokitOptions } from "@octokit/core";
import type { Groups, State, ThrottlingOptions } from "./types.js";
import type { CreateGroupsCommon, Groups, State, ThrottlingOptions } from "./types.js";
import { VERSION } from "./version.js";

import { wrapRequest } from "./wrap-request.js";
Expand All @@ -15,12 +15,8 @@ const regex = routeMatcher(triggersNotificationPaths);
const triggersNotification = regex.test.bind(regex);

const groups: Groups = {};
type Common = {
connection?: TBottleneck.RedisConnection | TBottleneck.IORedisConnection;
timeout: number;
};

const createGroups = function (Bottleneck: typeof TBottleneck, common: Common) {
const createGroups = function (Bottleneck: typeof TBottleneck, common: CreateGroupsCommon) {
groups.global = new Bottleneck.Group({
id: "octokit-global",
maxConcurrent: 10,
Expand Down Expand Up @@ -57,7 +53,7 @@ export function throttling(octokit: Octokit, octokitOptions: OctokitOptions) {
if (!enabled) {
return {};
}
const common: Common = { timeout };
const common: CreateGroupsCommon = { timeout };
if (typeof connection !== "undefined") {
common.connection = connection;
}
Expand Down
5 changes: 5 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,8 @@ export type State = {
id: string;
} & Required<Groups> &
ThrottlingOptions;

export type CreateGroupsCommon = {
connection?: Bottleneck.RedisConnection | Bottleneck.IORedisConnection;
timeout: number;
};

0 comments on commit c5cb5c2

Please sign in to comment.