mirror of
https://github.com/graphql-hive/console
synced 2026-04-21 14:37:17 +00:00
* feat: retreive stripe public key via runtime environment variable instead of a build-time environment variable * feat: retreive google and github enabled environment variable via runtime environment variable instead of a build-time environment variable * feat: retreive app base url environment variable via runtime environment variable instead of a build-time environment variable * feat: retreive mixpanel token environment variable via runtime environment variable instead of a build-time environment variable * lazy initialize app info * feat: provide ga tarcking id and crisp website id via environment variable * make docs url optional * feat: load sentry config from environment variables * document hive app environment variables * add application dockerfile * add docker build instructions * lul * set working directory * pls fix * lol this is apollo-router not graphql-hive * feat: only show sentry stuff if sentry environment variables are set * use LTS node version * No mixpanel * Fallback Co-authored-by: Kamil Kisiela <kamil.kisiela@gmail.com>
43 lines
1.1 KiB
TypeScript
43 lines
1.1 KiB
TypeScript
import { NextApiRequest, NextApiResponse } from 'next';
|
|
import { graphql } from '@/lib/api/utils';
|
|
|
|
export async function ensureGithubIntegration(
|
|
req: NextApiRequest,
|
|
input: {
|
|
installationId: string;
|
|
orgId: string;
|
|
}
|
|
) {
|
|
const { orgId, installationId } = input;
|
|
await graphql({
|
|
url: `${process.env['APP_BASE_URL'].replace(/\/$/, '')}/api/proxy`,
|
|
headers: {
|
|
...req.headers,
|
|
'content-type': 'application/json',
|
|
},
|
|
operationName: 'addGitHubIntegration',
|
|
query: /* GraphQL */ `
|
|
mutation addGitHubIntegration($input: AddGitHubIntegrationInput!) {
|
|
addGitHubIntegration(input: $input)
|
|
}
|
|
`,
|
|
variables: {
|
|
input: {
|
|
organization: orgId,
|
|
installationId: installationId,
|
|
},
|
|
},
|
|
});
|
|
}
|
|
|
|
export default async function githubCallback(req: NextApiRequest, res: NextApiResponse) {
|
|
console.log('GitHub Integration Callback');
|
|
const installationId = req.query.installation_id as string;
|
|
const orgId = req.query.state as string;
|
|
|
|
await ensureGithubIntegration(req, {
|
|
installationId,
|
|
orgId,
|
|
});
|
|
res.redirect(`/${orgId}/settings`);
|
|
}
|