(req: Request, res: Response)
| 136 | } |
| 137 | |
| 138 | private async experimental_addGithubRepo(req: Request, res: Response) { |
| 139 | const schema = z.object({ |
| 140 | owner: z.string(), |
| 141 | repo: z.string(), |
| 142 | }).strict(); |
| 143 | |
| 144 | const parsed = schema.safeParse(req.body); |
| 145 | if (!parsed.success) { |
| 146 | res.status(400).json({ error: parsed.error.message }); |
| 147 | return; |
| 148 | } |
| 149 | |
| 150 | const octokit = new Octokit(); |
| 151 | const response = await octokit.rest.repos.get({ |
| 152 | owner: parsed.data.owner, |
| 153 | repo: parsed.data.repo, |
| 154 | }); |
| 155 | |
| 156 | const record = createGitHubRepoRecord({ |
| 157 | repo: response.data, |
| 158 | hostUrl: 'https://github.com', |
| 159 | isAutoCleanupDisabled: true, |
| 160 | }); |
| 161 | |
| 162 | const repo = await this.prisma.repo.upsert({ |
| 163 | where: { |
| 164 | external_id_external_codeHostUrl_orgId: { |
| 165 | external_id: record.external_id, |
| 166 | external_codeHostUrl: record.external_codeHostUrl, |
| 167 | orgId: SINGLE_TENANT_ORG_ID, |
| 168 | } |
| 169 | }, |
| 170 | update: record, |
| 171 | create: record, |
| 172 | }); |
| 173 | |
| 174 | const [jobId ] = await this.repoIndexManager.createJobs([repo], RepoIndexingJobType.INDEX); |
| 175 | |
| 176 | res.status(200).json({ jobId, repoId: repo.id }); |
| 177 | } |
| 178 | |
| 179 | public async dispose() { |
| 180 | return new Promise<void>((resolve, reject) => { |
nothing calls this directly
no test coverage detected