diff --git a/cmd/server/probers.go b/cmd/server/probers.go index 5afd4f2..819d7a5 100644 --- a/cmd/server/probers.go +++ b/cmd/server/probers.go @@ -68,8 +68,8 @@ xmr-nodes probers list -s last_submit_ts -d asc sin1`, fmt.Fprintf(w, "%d\t| %s\t| %s\t| %s\n", prober.ID, prober.Name, - time.Unix(prober.LastSubmitTs, 0).Format(time.RFC3339), - prober.ApiKey, + time.Unix(prober.LastSubmitTS, 0).Format(time.RFC3339), + prober.APIKey, ) } w.Flush() @@ -115,7 +115,7 @@ This command will display the prober name and API key when successfully executed return } - fmt.Printf("Name: %s\nAPI Key: %s\n", prober.Name, prober.ApiKey) + fmt.Printf("Name: %s\nAPI Key: %s\n", prober.Name, prober.APIKey) }, } diff --git a/handler/middlewares.go b/handler/middlewares.go index c8c596d..b6dce2b 100644 --- a/handler/middlewares.go +++ b/handler/middlewares.go @@ -16,7 +16,7 @@ func CheckProber(c *fiber.Ctx) error { }) } - prober, err := monero.NewProber().CheckApi(key) + prober, err := monero.NewProber().CheckAPI(key) if err != nil { return c.Status(fiber.StatusUnauthorized).JSON(fiber.Map{ "status": "error", diff --git a/internal/monero/prober.go b/internal/monero/prober.go index a87f701..7d47fc5 100644 --- a/internal/monero/prober.go +++ b/internal/monero/prober.go @@ -15,7 +15,7 @@ type ProberRepository interface { Add(name string) (Prober, error) Edit(id int, name string) error Probers(QueryProbers) ([]Prober, error) - CheckApi(key string) (Prober, error) + CheckAPI(key string) (Prober, error) Delete(id int) error } @@ -26,8 +26,8 @@ type ProberRepo struct { type Prober struct { ID int64 `json:"id" db:"id"` Name string `json:"name" db:"name"` - ApiKey uuid.UUID `json:"api_key" db:"api_key"` - LastSubmitTs int64 `json:"last_submit_ts" db:"last_submit_ts"` + APIKey uuid.UUID `json:"api_key" db:"api_key"` + LastSubmitTS int64 `json:"last_submit_ts" db:"last_submit_ts"` } // Initializes a new ProberRepository @@ -54,7 +54,7 @@ func (r *ProberRepo) Add(name string) (Prober, error) { if err != nil { return Prober{}, err } - return Prober{Name: name, ApiKey: apiKey}, nil + return Prober{Name: name, APIKey: apiKey}, nil } // Edit an existing prober @@ -143,7 +143,7 @@ func (r *ProberRepo) Probers(q QueryProbers) ([]Prober, error) { for row.Next() { var p Prober - err = row.Scan(&p.ID, &p.Name, &p.ApiKey, &p.LastSubmitTs) + err = row.Scan(&p.ID, &p.Name, &p.APIKey, &p.LastSubmitTS) if err != nil { return probers, err } @@ -152,7 +152,7 @@ func (r *ProberRepo) Probers(q QueryProbers) ([]Prober, error) { return probers, nil } -func (r *ProberRepo) CheckApi(key string) (Prober, error) { +func (r *ProberRepo) CheckAPI(key string) (Prober, error) { var p Prober query := ` SELECT @@ -165,6 +165,6 @@ func (r *ProberRepo) CheckApi(key string) (Prober, error) { WHERE api_key = ? LIMIT 1` - err := r.db.QueryRow(query, key).Scan(&p.ID, &p.Name, &p.ApiKey, &p.LastSubmitTs) + err := r.db.QueryRow(query, key).Scan(&p.ID, &p.Name, &p.APIKey, &p.LastSubmitTS) return p, err } diff --git a/internal/monero/prober_test.go b/internal/monero/prober_test.go index 31be9e7..14c3c0b 100644 --- a/internal/monero/prober_test.go +++ b/internal/monero/prober_test.go @@ -128,7 +128,7 @@ func TestProberRepo_CheckApi(t *testing.T) { repo := NewProber() for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - _, err := repo.CheckApi(tt.apiKey) + _, err := repo.CheckAPI(tt.apiKey) if (err != nil) != tt.wantErr { t.Errorf("ProberRepo.CheckApi() error = %v, wantErr %v", err, tt.wantErr) return @@ -143,6 +143,6 @@ func BenchmarkProberRepo_CheckApi(b *testing.B) { } repo := NewProber() for i := 0; i < b.N; i++ { - repo.CheckApi("") + repo.CheckAPI("") } }