/
arseniy985
/
QuantaAI
Обзор
Документация
Войти
/
arseniy985
/
QuantaAI
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
main
src/internal/modules/github/services/github-account.service.ts
36 строк
1 KB
Arseniy
Add studio settings + integrations and migrate forms to shadcn
29 янв 2026, 23:48
29 янв 2026, 23:48
0653130
Код
Авторство
О чём код?
import { inject, injectable } from 'inversify'; import { GitHubAccountRepository } from '../repositories/github-account.repository'; import { GitHubTypes } from '../types'; export type GitHubConnectionStatus = { connected: boolean; scopes: string[]; hasRepoScope: boolean; }; @injectable() export class GitHubAccountService { constructor( @inject(GitHubTypes.GitHubAccountRepository) private githubAccountRepository: GitHubAccountRepository, ) {} async getConnectionStatus(userId: string): Promise<GitHubConnectionStatus> { const account = await this.githubAccountRepository.findAccountByUserId(userId); if (!account?.access_token) { return { connected: false, scopes: [], hasRepoScope: false }; } const scopes = (account.scope ?? '') .split(',') .map((scope) => scope.trim()) .filter(Boolean); return { connected: true, scopes, hasRepoScope: scopes.includes('repo'), }; } async disconnect(userId: string): Promise<void> { await this.githubAccountRepository.deleteByUserId(userId); } }