Skip to content

Commit

Permalink
Update to changed datastore structure
Browse files Browse the repository at this point in the history
  • Loading branch information
dangeross committed May 18, 2022
1 parent 3e2b1c7 commit a04f46d
Show file tree
Hide file tree
Showing 51 changed files with 80 additions and 621 deletions.
2 changes: 1 addition & 1 deletion cmd/api/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (

_ "github.com/joho/godotenv/autoload"
"github.com/satimoto/go-api/internal/rest"
"github.com/satimoto/go-datastore/util"
"github.com/satimoto/go-datastore/pkg/util"
)

var (
Expand Down
2 changes: 1 addition & 1 deletion cmd/lambdaapi/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"github.com/aws/aws-lambda-go/lambda"
chiproxy "github.com/awslabs/aws-lambda-go-api-proxy/chi"
"github.com/satimoto/go-api/internal/rest"
"github.com/satimoto/go-datastore/util"
"github.com/satimoto/go-datastore/pkg/util"
)

var (
Expand Down
5 changes: 2 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ require (
github.com/golang-jwt/jwt v3.2.2+incompatible
github.com/google/uuid v1.3.0
github.com/joho/godotenv v1.4.0
github.com/satimoto/go-datastore v0.1.2-0.20220506113557-5240743992e9
github.com/satimoto/go-datastore v0.1.2-0.20220518204540-92340686583d
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e
github.com/vektah/gqlparser/v2 v2.4.0
)
Expand Down Expand Up @@ -53,7 +53,7 @@ require (
github.com/miekg/dns v1.1.43 // indirect
github.com/mitchellh/mapstructure v1.4.2 // indirect
github.com/paulmach/orb v0.5.1-0.20220406232948-69ee7e81c712 // indirect
github.com/satimoto/go-ocpi-api v0.0.3-0.20220518064509-629fe41bca23
github.com/satimoto/go-ocpi-api v0.0.3-0.20220518210005-014a687a70dc
github.com/tidwall/gjson v1.6.1 // indirect
github.com/tidwall/match v1.0.1 // indirect
github.com/tidwall/pretty v1.0.2 // indirect
Expand All @@ -79,7 +79,6 @@ require (
github.com/prometheus/client_model v0.2.0 // indirect
github.com/prometheus/common v0.32.1 // indirect
github.com/prometheus/procfs v0.7.3 // indirect
github.com/satimoto/go-datastore-mocks v0.1.2-0.20220429143239-03099fadb0a5 // indirect
google.golang.org/grpc v1.46.0 // indirect
)

Expand Down
537 changes: 8 additions & 529 deletions go.sum

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions gqlgen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ omit_slice_element_pointers: true
# gqlgen will search for any type names in the schema in these go packages
# if they match it will use them, otherwise it will generate them.
autobind:
- "github.com/satimoto/go-datastore/db"
- "github.com/satimoto/go-datastore/pkg/db"

# This section declares type mapping between the GraphQL and go type systems
#
Expand All @@ -45,4 +45,4 @@ models:
ID:
model: github.com/99designs/gqlgen/graphql.Int64
Geometry:
model: github.com/satimoto/go-datastore/geom.Geometry4326
model: github.com/satimoto/go-datastore/pkg/geom.Geometry4326
4 changes: 2 additions & 2 deletions graph/exec.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion graph/model.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion graph/resolver/authentication.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"github.com/satimoto/go-api/internal/authentication"
"github.com/satimoto/go-api/internal/lnurl"
"github.com/satimoto/go-api/internal/lnurl/auth"
"github.com/satimoto/go-datastore/db"
"github.com/satimoto/go-datastore/pkg/db"
"github.com/vektah/gqlparser/v2/gqlerror"
)

Expand Down
4 changes: 2 additions & 2 deletions graph/resolver/businessdetail.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import (
"github.com/satimoto/go-api/graph"
"github.com/satimoto/go-api/internal/businessdetail"
"github.com/satimoto/go-api/internal/util"
"github.com/satimoto/go-datastore/db"
dbUtil "github.com/satimoto/go-datastore/util"
"github.com/satimoto/go-datastore/pkg/db"
dbUtil "github.com/satimoto/go-datastore/pkg/util"
"github.com/vektah/gqlparser/v2/gqlerror"
)

Expand Down
4 changes: 2 additions & 2 deletions graph/resolver/channelrequest.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import (
"github.com/satimoto/go-api/graph"
"github.com/satimoto/go-api/internal/authentication"
"github.com/satimoto/go-api/internal/user"
"github.com/satimoto/go-datastore/db"
"github.com/satimoto/go-datastore/util"
"github.com/satimoto/go-datastore/pkg/db"
"github.com/satimoto/go-datastore/pkg/util"
"github.com/vektah/gqlparser/v2/gqlerror"
)

Expand Down
2 changes: 1 addition & 1 deletion graph/resolver/connector.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (

"github.com/satimoto/go-api/graph"
"github.com/satimoto/go-api/internal/util"
"github.com/satimoto/go-datastore/db"
"github.com/satimoto/go-datastore/pkg/db"
)

func (r *connectorResolver) Standard(ctx context.Context, obj *db.Connector) (string, error) {
Expand Down
2 changes: 1 addition & 1 deletion graph/resolver/credential.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"github.com/satimoto/go-api/graph"
"github.com/satimoto/go-api/internal/authentication"
"github.com/satimoto/go-api/internal/credential"
"github.com/satimoto/go-datastore/db"
"github.com/satimoto/go-datastore/pkg/db"
"github.com/vektah/gqlparser/v2/gqlerror"
)

Expand Down
2 changes: 1 addition & 1 deletion graph/resolver/emailsubscription.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
"github.com/satimoto/go-api/graph"
"github.com/satimoto/go-api/internal/template"
"github.com/satimoto/go-api/internal/util"
"github.com/satimoto/go-datastore/db"
"github.com/satimoto/go-datastore/pkg/db"
"github.com/vektah/gqlparser/v2/gqlerror"
)

Expand Down
2 changes: 1 addition & 1 deletion graph/resolver/energymix.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (

"github.com/satimoto/go-api/graph"
"github.com/satimoto/go-api/internal/util"
"github.com/satimoto/go-datastore/db"
"github.com/satimoto/go-datastore/pkg/db"
)

func (r *energyMixResolver) EnergySources(ctx context.Context, obj *db.EnergyMix) ([]db.EnergySource, error) {
Expand Down
2 changes: 1 addition & 1 deletion graph/resolver/energysource.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"context"

"github.com/satimoto/go-api/graph"
"github.com/satimoto/go-datastore/db"
"github.com/satimoto/go-datastore/pkg/db"
)

func (r *energySourceResolver) Source(ctx context.Context, obj *db.EnergySource) (string, error) {
Expand Down
6 changes: 4 additions & 2 deletions graph/resolver/environmentalimpact.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,16 @@ import (
"context"

"github.com/satimoto/go-api/graph"
"github.com/satimoto/go-datastore/db"
"github.com/satimoto/go-datastore/pkg/db"
)

func (r *environmentalImpactResolver) Source(ctx context.Context, obj *db.EnvironmentalImpact) (string, error) {
return string(obj.Source), nil
}

// EnvironmentalImpact returns graph.EnvironmentalImpactResolver implementation.
func (r *Resolver) EnvironmentalImpact() graph.EnvironmentalImpactResolver { return &environmentalImpactResolver{r} }
func (r *Resolver) EnvironmentalImpact() graph.EnvironmentalImpactResolver {
return &environmentalImpactResolver{r}
}

type environmentalImpactResolver struct{ *Resolver }
4 changes: 2 additions & 2 deletions graph/resolver/evse.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import (

"github.com/satimoto/go-api/graph"
"github.com/satimoto/go-api/internal/util"
"github.com/satimoto/go-datastore/db"
"github.com/satimoto/go-datastore/geom"
"github.com/satimoto/go-datastore/pkg/db"
"github.com/satimoto/go-datastore/pkg/geom"
)

func (r *evseResolver) EvseID(ctx context.Context, obj *db.Evse) (*string, error) {
Expand Down
2 changes: 1 addition & 1 deletion graph/resolver/exceptionalperiod.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"time"

"github.com/satimoto/go-api/graph"
"github.com/satimoto/go-datastore/db"
"github.com/satimoto/go-datastore/pkg/db"
)

func (r *exceptionalPeriodResolver) PeriodBegin(ctx context.Context, obj *db.ExceptionalPeriod) (string, error) {
Expand Down
2 changes: 1 addition & 1 deletion graph/resolver/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/satimoto/go-api/graph"
"github.com/satimoto/go-api/internal/image"
"github.com/satimoto/go-api/internal/util"
"github.com/satimoto/go-datastore/db"
"github.com/satimoto/go-datastore/pkg/db"
"github.com/vektah/gqlparser/v2/gqlerror"
)

Expand Down
2 changes: 1 addition & 1 deletion graph/resolver/location.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"github.com/satimoto/go-api/internal/authentication"
"github.com/satimoto/go-api/internal/location"
"github.com/satimoto/go-api/internal/util"
"github.com/satimoto/go-datastore/db"
"github.com/satimoto/go-datastore/pkg/db"
"github.com/vektah/gqlparser/v2/gqlerror"
)

Expand Down
4 changes: 2 additions & 2 deletions graph/resolver/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ import (
"context"

"github.com/satimoto/go-api/graph"
"github.com/satimoto/go-datastore/db"
"github.com/satimoto/go-datastore/pkg/db"
)

func (r *nodeResolver) Addr(ctx context.Context, obj *db.Node) (string, error) {
return obj.NodeAddr, nil
}

// Node returns graph.NodeResolver implementation.
// Node returns graph.NodeResolver implementation.
func (r *Resolver) Node() graph.NodeResolver { return &nodeResolver{r} }

type nodeResolver struct{ *Resolver }
2 changes: 1 addition & 1 deletion graph/resolver/openingtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"context"

"github.com/satimoto/go-api/graph"
"github.com/satimoto/go-datastore/db"
"github.com/satimoto/go-datastore/pkg/db"
)

func (r *openingTimeResolver) RegularHours(ctx context.Context, obj *db.OpeningTime) ([]db.RegularHour, error) {
Expand Down
2 changes: 1 addition & 1 deletion graph/resolver/regularhour.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"context"

"github.com/satimoto/go-api/graph"
"github.com/satimoto/go-datastore/db"
"github.com/satimoto/go-datastore/pkg/db"
)

func (r *regularHourResolver) Weekday(ctx context.Context, obj *db.RegularHour) (int, error) {
Expand Down
4 changes: 2 additions & 2 deletions graph/resolver/resolve.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ import (
"github.com/satimoto/go-api/internal/evse"
"github.com/satimoto/go-api/internal/image"
"github.com/satimoto/go-api/internal/location"
"github.com/satimoto/go-api/internal/node"
"github.com/satimoto/go-api/internal/openingtime"
"github.com/satimoto/go-api/internal/token"
"github.com/satimoto/go-api/internal/user"
"github.com/satimoto/go-datastore/db"
"github.com/satimoto/go-datastore/pkg/db"
"github.com/satimoto/go-datastore/pkg/node"
"github.com/satimoto/go-ocpi-api/pkg/ocpi"
)

Expand Down
2 changes: 1 addition & 1 deletion graph/resolver/statusschedule.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (

"github.com/satimoto/go-api/graph"
"github.com/satimoto/go-api/internal/util"
"github.com/satimoto/go-datastore/db"
"github.com/satimoto/go-datastore/pkg/db"
)

func (r *statusScheduleResolver) PeriodBegin(ctx context.Context, obj *db.StatusSchedule) (string, error) {
Expand Down
10 changes: 5 additions & 5 deletions graph/resolver/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import (
"github.com/satimoto/go-api/graph"
"github.com/satimoto/go-api/internal/authentication"
"github.com/satimoto/go-api/internal/user"
"github.com/satimoto/go-datastore/db"
"github.com/satimoto/go-datastore/util"
"github.com/satimoto/go-datastore/pkg/db"
"github.com/satimoto/go-datastore/pkg/util"
"github.com/vektah/gqlparser/v2/gqlerror"
)

Expand All @@ -30,9 +30,9 @@ func (r *mutationResolver) CreateUser(ctx context.Context, input graph.CreateUse

u, err := r.UserResolver.Repository.CreateUser(ctx, db.CreateUserParams{
CommissionPercent: util.GetEnvFloat64("DEFAULT_COMMISSION_PERCENT", 7),
DeviceToken: input.DeviceToken,
LinkingPubkey: auth.LinkingPubkey.String,
Pubkey: input.Pubkey,
DeviceToken: input.DeviceToken,
LinkingPubkey: auth.LinkingPubkey.String,
Pubkey: input.Pubkey,
})

if err != nil {
Expand Down
8 changes: 4 additions & 4 deletions internal/authentication/process.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ import (
"os"

"github.com/golang-jwt/jwt"
"github.com/satimoto/go-datastore/db"
"github.com/satimoto/go-datastore/pkg/db"
)

func SignToken(user db.User) (string, error) {
claims := jwt.MapClaims{}
claims["user_id"] = user.ID

jwtWithClaims := jwt.NewWithClaims(jwt.SigningMethodHS256, claims)
token, err := jwtWithClaims.SignedString([]byte(os.Getenv("JWT_SECRET")))

Expand All @@ -37,7 +37,7 @@ func VerifyToken(tokenString string) (bool, jwt.MapClaims) {

if claims, ok := token.Claims.(jwt.MapClaims); ok && token.Valid {
return true, claims
}
}

return false, jwt.MapClaims{}
}
}
2 changes: 1 addition & 1 deletion internal/authentication/resolve.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package authentication
import (
"context"

"github.com/satimoto/go-datastore/db"
"github.com/satimoto/go-datastore/pkg/db"
)

type AuthenticationRepository interface {
Expand Down
4 changes: 2 additions & 2 deletions internal/businessdetail/param.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package businessdetail

import (
"github.com/satimoto/go-api/graph"
"github.com/satimoto/go-datastore/db"
"github.com/satimoto/go-datastore/util"
"github.com/satimoto/go-datastore/pkg/db"
"github.com/satimoto/go-datastore/pkg/util"
)

func NewCreateBusinessDetailParams(input graph.CreateBusinessDetailInput) db.CreateBusinessDetailParams {
Expand Down
2 changes: 1 addition & 1 deletion internal/businessdetail/resolve.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package businessdetail
import (
"context"

"github.com/satimoto/go-datastore/db"
"github.com/satimoto/go-datastore/pkg/db"
)

type BusinessDetailRepository interface {
Expand Down
2 changes: 1 addition & 1 deletion internal/channelrequest/resolve.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package channelrequest
import (
"context"

"github.com/satimoto/go-datastore/db"
"github.com/satimoto/go-datastore/pkg/db"
)

type ChannelRequestRepository interface {
Expand Down
2 changes: 1 addition & 1 deletion internal/command/graph.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package command

import (
"github.com/satimoto/go-api/graph"
"github.com/satimoto/go-datastore/util"
"github.com/satimoto/go-datastore/pkg/util"
"github.com/satimoto/go-ocpi-api/ocpirpc"
)

Expand Down
2 changes: 1 addition & 1 deletion internal/credential/graph.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package credential

import (
"github.com/satimoto/go-datastore/db"
"github.com/satimoto/go-datastore/pkg/db"
"github.com/satimoto/go-ocpi-api/ocpirpc"
)

Expand Down
2 changes: 1 addition & 1 deletion internal/emailsubscription/resolve.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"os"

"github.com/satimoto/go-api/internal/aws/email"
"github.com/satimoto/go-datastore/db"
"github.com/satimoto/go-datastore/pkg/db"
)

type EmailSubscriptionRepository interface {
Expand Down
2 changes: 1 addition & 1 deletion internal/energymix/resolve.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package energymix
import (
"context"

"github.com/satimoto/go-datastore/db"
"github.com/satimoto/go-datastore/pkg/db"
)

type EnergyMixRepository interface {
Expand Down
Loading

0 comments on commit a04f46d

Please sign in to comment.