Files
outline/plugins/github/server/index.ts
Apoorv Mishra bea36f87a6 Refactor GitHub Integration (#6713)
* fix: refactor

* fix: tests

* fix: apply octokit plugin pattern
2024-03-27 17:22:06 +05:30

33 lines
737 B
TypeScript

import { Minute } from "@shared/utils/time";
import { PluginManager, Hook } from "@server/utils/PluginManager";
import config from "../plugin.json";
import router from "./api/github";
import env from "./env";
import { GitHub } from "./github";
import { uninstall } from "./uninstall";
const enabled =
!!env.GITHUB_CLIENT_ID &&
!!env.GITHUB_CLIENT_SECRET &&
!!env.GITHUB_APP_NAME &&
!!env.GITHUB_APP_ID &&
!!env.GITHUB_APP_PRIVATE_KEY;
if (enabled) {
PluginManager.add([
{
...config,
type: Hook.API,
value: router,
},
{
type: Hook.UnfurlProvider,
value: { unfurl: GitHub.unfurl, cacheExpiry: Minute },
},
{
type: Hook.Uninstall,
value: uninstall,
},
]);
}