diff --git a/main.go b/main.go index 22c6460..365ccca 100644 --- a/main.go +++ b/main.go @@ -1,28 +1,5 @@ package main -import ( - "log" - - "github.com/joho/godotenv" - "github.com/namsral/flag" -) - -var ( - SnApiToken string -) - -func init() { - err := godotenv.Load() - if err != nil { - log.Fatal("Error loading .env file") - } - flag.StringVar(&SnApiToken, "NEXT_AUTH_CSRF_TOKEN", "", "Token required for authorizing requests to stacker.news/api/graphql") - flag.Parse() - if SnApiToken == "" { - log.Fatal("NEXT_AUTH_CSRF_TOKEN not set") - } -} - func main() { stories := fetchTopStoriesFromHN() filtered := filterByRelevanceForSN(&stories) diff --git a/sn.go b/sn.go index 6498dcc..c392fe5 100644 --- a/sn.go +++ b/sn.go @@ -6,6 +6,9 @@ import ( "fmt" "log" "net/http" + + "github.com/joho/godotenv" + "github.com/namsral/flag" ) type GraphQLPayload struct { @@ -25,6 +28,22 @@ type DupesResponse struct { } `json:"data"` } +var ( + SnApiToken string +) + +func init() { + err := godotenv.Load() + if err != nil { + log.Fatal("Error loading .env file") + } + flag.StringVar(&SnApiToken, "NEXT_AUTH_CSRF_TOKEN", "", "Token required for authorizing requests to stacker.news/api/graphql") + flag.Parse() + if SnApiToken == "" { + log.Fatal("NEXT_AUTH_CSRF_TOKEN not set") + } +} + func makeGraphQLRequest(body GraphQLPayload) *http.Response { bodyJSON, err := json.Marshal(body) if err != nil {