import { NodeCG } from "nodecg-types/types/server" ; import { Result , emptySuccess , success , ServiceBundle , Logger } from "nodecg-io-core" ; import { Octokit } from "@octokit/rest" ; export interface GitHubConfig { token : string ; } export type GitHubClient = Octokit ; module . exports = ( nodecg ) => { new GitHubService ( nodecg , "github" , __dirname , "../schema.json" ) . register ( ) ; } ; class GitHubService extends ServiceBundle < GitHubConfig , GitHubClient > { async validateConfig ( config ) { const octokit = new Octokit ( { auth : config . token } ) ; await octokit . repos . listForAuthenticatedUser ( { page : 0 , per_page : 1 } ) ; return emptySuccess ( ) ; } async createClient ( config , logger ) { const client = new Octokit ( { auth : config . token } ) ; logger . info ( "Successfully created github client." ) ; return success ( client ) ; } stopClient ( _ ) { } }