Skip to content

Commit d7c6c76

Browse files
committed
refactor: remove client instantiation from service provider and move authentication to GithubService
1 parent ed065ab commit d7c6c76

2 files changed

Lines changed: 3 additions & 9 deletions

File tree

src/Providers/GithubProjectServiceProvider.php

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
namespace CSlant\GithubProject\Providers;
44

5-
use Github\AuthMethod;
6-
use Github\Client;
75
use Illuminate\Support\ServiceProvider;
86

97
class GithubProjectServiceProvider extends ServiceProvider
@@ -30,13 +28,6 @@ public function register(): void
3028
$this->registerConfigs();
3129

3230
$this->registerCommands();
33-
34-
$this->app->singleton(Client::class, function () {
35-
$client = new Client;
36-
$client->authenticate((string) config('github-project.github.access_token'), null, AuthMethod::ACCESS_TOKEN);
37-
38-
return $client;
39-
});
4031
}
4132

4233
/**

src/Services/GithubService.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace CSlant\GitHubProject\Services;
44

55
use CSlant\GitHubProject\Jobs\ProcessWebhookEvent;
6+
use Github\AuthMethod;
67
use Github\Client;
78

89
class GithubService
@@ -42,6 +43,8 @@ public function commentOnNode(string $contentNodeId, string $message): array
4243
],
4344
];
4445

46+
$this->client->authenticate((string) config('github-project.github.access_token'), null, AuthMethod::ACCESS_TOKEN);
47+
4548
return $this->client->graphql()->execute($query, $variables);
4649
}
4750

0 commit comments

Comments
 (0)