diff --git a/common/index.ts b/common/index.ts index 21f22bbc1..cb74b37b4 100644 --- a/common/index.ts +++ b/common/index.ts @@ -28,6 +28,7 @@ import { ReviewRequestView, } from "@database/models" import AuditLogsService from "@root/services/admin/AuditLogsService" +import { RepairService } from "@root/services/admin/RepairService" import RepoManagementService from "@root/services/admin/RepoManagementService" import GitFileCommitService from "@root/services/db/GitFileCommitService" import GitFileSystemService from "@root/services/db/GitFileSystemService" @@ -248,3 +249,8 @@ export const auditLogsService = new AuditLogsService({ sitesService, usersService, }) + +export const repairService = new RepairService({ + reposService, + gitFileSystemService, +}) diff --git a/support/routes/v2/isobot/index.ts b/support/routes/v2/isobot/index.ts index 29f1113d3..c9ab2fc8f 100644 --- a/support/routes/v2/isobot/index.ts +++ b/support/routes/v2/isobot/index.ts @@ -7,10 +7,10 @@ import { import { RequestHandler } from "express" import { okAsync } from "neverthrow" +import { repairService } from "@common/index" import { Whitelist } from "@database/models" import config from "@root/config/config" import logger from "@root/logger/logger" -import { cloneRepo, lockRepo } from "@root/services/admin/RepairService" import WhitelistService from "@root/services/identity/WhitelistService" import BotService, { SlackPayload } from "./ops/botService" @@ -64,9 +64,9 @@ const cloneRepoCommmand = bot.command( text: `${payload.user_id} attempting to clone repo: ${repo} to EFS. Should lock: ${shouldLock}`, }) - const base = shouldLock ? lockRepo(tokens[0]) : okAsync("") + const base = shouldLock ? repairService.lockRepo(tokens[0]) : okAsync("") return base - .andThen(cloneRepo) + .andThen(repairService.cloneRepo) .map(() => respond(`${repo} was successfully cloned to efs!`)) .mapErr((e) => respond(`${e} occurred while cloning repo to efs`)) } @@ -101,7 +101,8 @@ const lockRepoCommand = bot.command( text: `${payload.user_id} attempting to lock repo: ${repo} for ${lockTimeMinutes}`, }) - return lockRepo(repo, lockTimeSeconds) + return repairService + .lockRepo(repo, lockTimeSeconds) .map((repo) => { respond( `${repo} was successfully locked for ${lockTimeMinutes} minutes!`