-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Get and display integrated repositories on a Jira ticket
- Loading branch information
1 parent
83259f1
commit 3cf1274
Showing
3 changed files
with
92 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,35 @@ | ||
import Resolver from '@forge/resolver'; | ||
import Resolver from "@forge/resolver"; | ||
import forge from "@forge/api"; | ||
|
||
const resolver = new Resolver(); | ||
|
||
resolver.define('getText', (req) => { | ||
console.log(req); | ||
return 'Hello, world!'; | ||
// https://developer.atlassian.com/platform/forge/runtime-reference/forge-resolver/ | ||
resolver.define("getGithubRepos", async ({ payload }) => { | ||
const { cloudId, projectId } = payload; | ||
|
||
// https://supabase.com/docs/guides/api/sql-to-rest | ||
const queryParams = new URLSearchParams({ | ||
select: "*", | ||
jira_site_id: `eq.${cloudId}`, | ||
jira_project_id: `eq.${projectId}`, | ||
}).toString(); | ||
const url = `${process.env.SUPABASE_URL}/rest/v1/jira_github_links?${queryParams}`; | ||
console.log(url); | ||
|
||
const response = await forge.fetch(url, { | ||
method: "GET", | ||
headers: { | ||
apikey: process.env.SUPABASE_API_KEY, | ||
Authorization: `Bearer ${process.env.SUPABASE_API_KEY}`, | ||
"Content-Type": "application/json", | ||
}, | ||
}); | ||
|
||
if (!response.ok) throw new Error(`Failed to fetch repositories: ${response.status}`); | ||
|
||
const data = await response.json(); | ||
console.log(data); | ||
return data; | ||
}); | ||
|
||
export const handler = resolver.getDefinitions(); |