(req: Request, res: Response)
| 13 | schedulerService: ReturnType<typeof createSchedulerService>, |
| 14 | ) { |
| 15 | async function checkHandler(req: Request, res: Response) { |
| 16 | const full_name = `${req.params.owner}/${req.params.repo}`; |
| 17 | app.log.info({ full_name }, `Checking ${appConfig.configFilename}`); |
| 18 | |
| 19 | try { |
| 20 | // Get Octokit |
| 21 | const repoRecord = await RepositoryModel.findOne({ full_name }); |
| 22 | |
| 23 | if (!repoRecord) { |
| 24 | app.log.error({ full_name }, `❌ Repo record not found`); |
| 25 | throw new Error(`❌ Repo record not found`); |
| 26 | } |
| 27 | |
| 28 | const { |
| 29 | installation_id, |
| 30 | id: repository_id, |
| 31 | owner: { login: owner }, |
| 32 | name: repo, |
| 33 | } = repoRecord; |
| 34 | |
| 35 | const octokit = await app.auth(installation_id); |
| 36 | const config = await getPullConfig(octokit, app.log, { |
| 37 | installation_id, |
| 38 | owner, |
| 39 | repo, |
| 40 | repository_id, |
| 41 | metadata: { |
| 42 | cron: "", |
| 43 | job_priority: JobPriority.Normal, |
| 44 | repository_id, |
| 45 | }, |
| 46 | }); |
| 47 | |
| 48 | if (!config) { |
| 49 | return res.status(404).json({ |
| 50 | status: "error", |
| 51 | message: `Configuration file '${appConfig.configFilename}' not found`, |
| 52 | }); |
| 53 | } |
| 54 | |
| 55 | res.json(config); |
| 56 | } catch (error) { |
| 57 | app.log.error(error); |
| 58 | res.status(500).json({ |
| 59 | status: "error", |
| 60 | message: error instanceof Error |
| 61 | ? error.message |
| 62 | : "Unknown error occurred", |
| 63 | }); |
| 64 | } |
| 65 | } |
| 66 | |
| 67 | async function processHandler(req: Request, res: Response) { |
| 68 | const full_name = `${req.params.owner}/${req.params.repo}`; |
nothing calls this directly
no test coverage detected