-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(structure): restructure codebase
Signed-off-by: Matt Gleich <[email protected]>
- Loading branch information
Showing
12 changed files
with
132 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package github | ||
|
||
import ( | ||
"context" | ||
"time" | ||
|
||
"github.com/gleich/lcp-v2/pkg/cache" | ||
"github.com/gleich/lcp-v2/pkg/secrets" | ||
"github.com/gleich/lumber/v2" | ||
"github.com/go-chi/chi/v5" | ||
"github.com/shurcooL/githubv4" | ||
"golang.org/x/oauth2" | ||
) | ||
|
||
func Setup(router *chi.Mux) { | ||
githubTokenSource := oauth2.StaticTokenSource( | ||
&oauth2.Token{AccessToken: secrets.SECRETS.GitHubAccessToken}, | ||
) | ||
githubHttpClient := oauth2.NewClient(context.Background(), githubTokenSource) | ||
githubClient := githubv4.NewClient(githubHttpClient) | ||
githubCache := cache.NewCache("github", FetchPinnedRepos(githubClient)) | ||
router.Get("/github/cache", githubCache.ServeHTTP()) | ||
go githubCache.StartPeriodicUpdate(func() []repository { return FetchPinnedRepos(githubClient) }, 2*time.Minute) | ||
lumber.Success("setup github cache") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package steam | ||
|
||
import ( | ||
"time" | ||
|
||
"github.com/gleich/lcp-v2/pkg/cache" | ||
"github.com/gleich/lumber/v2" | ||
"github.com/go-chi/chi/v5" | ||
) | ||
|
||
func Setup(router *chi.Mux) { | ||
games := fetchRecentlyPlayedGames() | ||
steamCache := cache.NewCache("steam", games) | ||
router.Get("/steam/cache", steamCache.ServeHTTP()) | ||
go steamCache.StartPeriodicUpdate(fetchRecentlyPlayedGames, 10*time.Minute) | ||
lumber.Success("setup steam cache") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package strava | ||
|
||
import ( | ||
"github.com/gleich/lcp-v2/pkg/cache" | ||
"github.com/gleich/lcp-v2/pkg/secrets" | ||
"github.com/gleich/lumber/v2" | ||
"github.com/go-chi/chi/v5" | ||
"github.com/minio/minio-go/v7" | ||
"github.com/minio/minio-go/v7/pkg/credentials" | ||
) | ||
|
||
func Setup(router *chi.Mux) { | ||
stravaTokens := loadTokens() | ||
stravaTokens.refreshIfNeeded() | ||
minioClient, err := minio.New(secrets.SECRETS.MinioEndpoint, &minio.Options{ | ||
Creds: credentials.NewStaticV4(secrets.SECRETS.MinioAccessKeyID, secrets.SECRETS.MinioSecretKey, ""), | ||
Secure: true, | ||
}) | ||
if err != nil { | ||
lumber.Fatal(err, "failed to create minio client") | ||
} | ||
stravaActivities := fetchActivities(*minioClient, stravaTokens) | ||
stravaCache := cache.NewCache("strava", stravaActivities) | ||
router.Get("/strava/cache", stravaCache.ServeHTTP()) | ||
router.Post("/strava/event", eventRoute(stravaCache, *minioClient, stravaTokens)) | ||
router.Get("/strava/event", challengeRoute) | ||
|
||
lumber.Success("setup strava cache") | ||
} |
Oops, something went wrong.