├── .gitignore ├── .tool-versions ├── .vscode └── settings.json ├── Makefile ├── auth.go ├── auth_test.go ├── cmd └── graphqlserver │ ├── main.go │ └── middleware.go ├── config └── config.go ├── context.go ├── context_test.go ├── domain ├── auth.go ├── auth_integration_test.go ├── auth_test.go ├── domain_integration_test.go ├── tweet.go ├── tweet_integration_test.go └── user.go ├── faker └── faker.go ├── go.mod ├── go.sum ├── graph ├── auth_resolver.go ├── dataloaders.go ├── generated.go ├── gqlgen.yml ├── models_gen.go ├── resolver.go ├── schema.graphql ├── tweet_resolver.go ├── user_resolver.go └── userloader_gen.go ├── jwt ├── jwt.go └── jwt_test.go ├── mocks ├── AuthService.go ├── AuthTokenService.go ├── RefreshTokenRepo.go ├── TweetRepo.go ├── TweetService.go ├── UserRepo.go ├── UserService.go └── graph │ ├── MutationResolver.go │ ├── QueryResolver.go │ ├── ResolverRoot.go │ └── TweetResolver.go ├── postgres ├── migrations │ ├── 20210508145803_create_users_table.down.sql │ ├── 20210508145803_create_users_table.up.sql │ ├── 20211027092349_create_tweets_table.down.sql │ ├── 20211027092349_create_tweets_table.up.sql │ ├── 20220117202457_add_parent_id_to_tweets_table.down.sql │ └── 20220117202457_add_parent_id_to_tweets_table.up.sql ├── postgres.go ├── tweet_repo.go └── user_repo.go ├── refresh_token.go ├── test_helpers └── test_helpers.go ├── tweet.go ├── tweet_test.go ├── twitter.go ├── user.go └── uuid └── uuid.go /.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | .env 3 | .env.test -------------------------------------------------------------------------------- /.tool-versions: -------------------------------------------------------------------------------- 1 | golang 1.17.13 -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "gopls": { 3 | "build.buildFlags": ["-tags=integration"] 4 | }, 5 | "go.testFlags": ["-tags", "integration"] 6 | } 7 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | mock: 2 | mockery --all --keeptree 3 | 4 | migrate: 5 | migrate -source file://postgres/migrations \ 6 | -database postgres://postgres:postgres@127.0.0.1:5432/twitter_clone_development?sslmode=disable up 7 | 8 | rollback: 9 | migrate -source file://postgres/migrations \ 10 | -database postgres://postgres:postgres@127.0.0.1:5432/twitter_clone_development?sslmode=disable down 1 11 | 12 | drop: 13 | migrate -source file://postgres/migrations \ 14 | -database postgres://postgres:postgres@127.0.0.1:5432/twitter_clone_development?sslmode=disable drop 15 | 16 | migration: 17 | @read -p "Enter migration name: " name; \ 18 | migrate create -ext sql -dir postgres/migrations $$name 19 | 20 | run: 21 | go run cmd/graphqlserver/*.go 22 | 23 | generate: 24 | go generate ./.. -------------------------------------------------------------------------------- /auth.go: -------------------------------------------------------------------------------- 1 | package twitter 2 | 3 | import ( 4 | "context" 5 | "fmt" 6 | "net/http" 7 | "regexp" 8 | "strings" 9 | ) 10 | 11 | var ( 12 | UsernameMinLength = 2 13 | PasswordMinLength = 6 14 | ) 15 | 16 | var emailRegexp = regexp.MustCompile("^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$") 17 | 18 | type AuthService interface { 19 | Register(ctx context.Context, input RegisterInput) (AuthResponse, error) 20 | Login(ctx context.Context, input LoginInput) (AuthResponse, error) 21 | } 22 | 23 | type AuthTokenService interface { 24 | CreateAccessToken(ctx context.Context, user User) (string, error) 25 | CreateRefreshToken(ctx context.Context, user User, tokenID string) (string, error) 26 | ParseToken(ctx context.Context, payload string) (AuthToken, error) 27 | ParseTokenFromRequest(ctx context.Context, r *http.Request) (AuthToken, error) 28 | } 29 | 30 | type AuthToken struct { 31 | ID string 32 | Sub string 33 | } 34 | 35 | type AuthResponse struct { 36 | AccessToken string 37 | User User 38 | } 39 | 40 | type RegisterInput struct { 41 | Email string 42 | Username string 43 | Password string 44 | ConfirmPassword string 45 | } 46 | 47 | func (in *RegisterInput) Sanitize() { 48 | in.Email = strings.TrimSpace(in.Email) 49 | in.Email = strings.ToLower(in.Email) 50 | 51 | in.Username = strings.TrimSpace(in.Username) 52 | } 53 | 54 | func (in RegisterInput) Validate() error { 55 | if len(in.Username) < UsernameMinLength { 56 | return fmt.Errorf("%w: username not long enough, (%d) characters at least", ErrValidation, UsernameMinLength) 57 | } 58 | 59 | if !emailRegexp.MatchString(in.Email) { 60 | return fmt.Errorf("%w: email not valid", ErrValidation) 61 | } 62 | 63 | if len(in.Password) < PasswordMinLength { 64 | return fmt.Errorf("%w: password not long enough, (%d) characters at least", ErrValidation, PasswordMinLength) 65 | } 66 | 67 | if in.Password != in.ConfirmPassword { 68 | return fmt.Errorf("%w: confirm password must match the password", ErrValidation) 69 | } 70 | 71 | return nil 72 | } 73 | 74 | type LoginInput struct { 75 | Email string 76 | Password string 77 | } 78 | 79 | func (in *LoginInput) Sanitize() { 80 | in.Email = strings.TrimSpace(in.Email) 81 | in.Email = strings.ToLower(in.Email) 82 | } 83 | 84 | func (in LoginInput) Validate() error { 85 | if !emailRegexp.MatchString(in.Email) { 86 | return fmt.Errorf("%w: email not valid", ErrValidation) 87 | } 88 | 89 | if len(in.Password) < 1 { 90 | return fmt.Errorf("%w: password required", ErrValidation) 91 | } 92 | 93 | return nil 94 | } 95 | -------------------------------------------------------------------------------- /auth_test.go: -------------------------------------------------------------------------------- 1 | package twitter 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/stretchr/testify/require" 7 | ) 8 | 9 | func TestRegisterInput_Sanitize(t *testing.T) { 10 | input := RegisterInput{ 11 | Username: " bob ", 12 | Email: " BOB@gmail.com ", 13 | Password: "password", 14 | ConfirmPassword: "password", 15 | } 16 | 17 | want := RegisterInput{ 18 | Username: "bob", 19 | Email: "bob@gmail.com", 20 | Password: "password", 21 | ConfirmPassword: "password", 22 | } 23 | 24 | input.Sanitize() 25 | 26 | require.Equal(t, want, input) 27 | } 28 | 29 | func TestRegisterInput_Validate(t *testing.T) { 30 | testCases := []struct { 31 | name string 32 | input RegisterInput 33 | err error 34 | }{ 35 | { 36 | name: "valid", 37 | input: RegisterInput{ 38 | Username: "bob", 39 | Email: "bob@gmail.com", 40 | Password: "password", 41 | ConfirmPassword: "password", 42 | }, 43 | err: nil, 44 | }, 45 | { 46 | name: "invalid email", 47 | input: RegisterInput{ 48 | Username: "bob", 49 | Email: "bob", 50 | Password: "password", 51 | ConfirmPassword: "password", 52 | }, 53 | err: ErrValidation, 54 | }, 55 | { 56 | name: "too short username", 57 | input: RegisterInput{ 58 | Username: "b", 59 | Email: "bob@gmail.com", 60 | Password: "password", 61 | ConfirmPassword: "password", 62 | }, 63 | err: ErrValidation, 64 | }, 65 | { 66 | name: "too short password", 67 | input: RegisterInput{ 68 | Username: "bob", 69 | Email: "bob@gmail.com", 70 | Password: "pass", 71 | ConfirmPassword: "pass", 72 | }, 73 | err: ErrValidation, 74 | }, 75 | { 76 | name: "confirm password doesn't match password", 77 | input: RegisterInput{ 78 | Username: "bob", 79 | Email: "bob@gmail.com", 80 | Password: "password", 81 | ConfirmPassword: "wrongpassword", 82 | }, 83 | err: ErrValidation, 84 | }, 85 | } 86 | 87 | for _, tc := range testCases { 88 | t.Run(tc.name, func(t *testing.T) { 89 | err := tc.input.Validate() 90 | 91 | if tc.err != nil { 92 | require.ErrorIs(t, err, tc.err) 93 | } else { 94 | require.NoError(t, err) 95 | } 96 | }) 97 | } 98 | } 99 | 100 | func TestLoginInput_Sanitize(t *testing.T) { 101 | input := LoginInput{ 102 | Email: " BOB@gmail.com ", 103 | Password: "password", 104 | } 105 | 106 | want := LoginInput{ 107 | Email: "bob@gmail.com", 108 | Password: "password", 109 | } 110 | 111 | input.Sanitize() 112 | 113 | require.Equal(t, want, input) 114 | } 115 | 116 | func TestLoginInput_Validate(t *testing.T) { 117 | testCases := []struct { 118 | name string 119 | input LoginInput 120 | err error 121 | }{ 122 | { 123 | name: "valid", 124 | input: LoginInput{ 125 | Email: "bob@gmail.com", 126 | Password: "password", 127 | }, 128 | err: nil, 129 | }, 130 | { 131 | name: "invalid email", 132 | input: LoginInput{ 133 | Email: "bob", 134 | Password: "password", 135 | }, 136 | err: ErrValidation, 137 | }, 138 | { 139 | name: "empty password", 140 | input: LoginInput{ 141 | Email: "bob@gmail.com", 142 | Password: "", 143 | }, 144 | err: ErrValidation, 145 | }, 146 | } 147 | 148 | for _, tc := range testCases { 149 | t.Run(tc.name, func(t *testing.T) { 150 | err := tc.input.Validate() 151 | 152 | if tc.err != nil { 153 | require.ErrorIs(t, err, tc.err) 154 | } else { 155 | require.NoError(t, err) 156 | } 157 | }) 158 | } 159 | } 160 | -------------------------------------------------------------------------------- /cmd/graphqlserver/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "context" 5 | "log" 6 | "net/http" 7 | "time" 8 | 9 | "github.com/99designs/gqlgen/graphql/handler" 10 | "github.com/99designs/gqlgen/graphql/playground" 11 | "github.com/equimper/twitter/config" 12 | "github.com/equimper/twitter/domain" 13 | "github.com/equimper/twitter/graph" 14 | "github.com/equimper/twitter/jwt" 15 | "github.com/equimper/twitter/postgres" 16 | "github.com/go-chi/chi" 17 | "github.com/go-chi/chi/middleware" 18 | ) 19 | 20 | func main() { 21 | ctx := context.Background() 22 | 23 | config.LoadEnv(".env") 24 | 25 | conf := config.New() 26 | 27 | db := postgres.New(ctx, conf) 28 | 29 | if err := db.Migrate(); err != nil { 30 | log.Fatal(err) 31 | } 32 | 33 | router := chi.NewRouter() 34 | 35 | router.Use(middleware.Logger) 36 | router.Use(middleware.RequestID) 37 | router.Use(middleware.Recoverer) 38 | router.Use(middleware.RedirectSlashes) 39 | router.Use(middleware.Timeout(time.Second * 60)) 40 | 41 | // REPOS 42 | userRepo := postgres.NewUserRepo(db) 43 | tweetRepo := postgres.NewTweetRepo(db) 44 | 45 | // SERVICES 46 | authTokenService := jwt.NewTokenService(conf) 47 | authService := domain.NewAuthService(userRepo, authTokenService) 48 | tweetService := domain.NewTweetService(tweetRepo) 49 | userService := domain.NewUserService(userRepo) 50 | 51 | router.Use(graph.DataloaderMiddleware( 52 | &graph.Repos{ 53 | UserRepo: userRepo, 54 | }, 55 | )) 56 | 57 | router.Use(authMiddleware(authTokenService)) 58 | router.Handle("/", playground.Handler("Twitter clone", "/query")) 59 | router.Handle("/query", handler.NewDefaultServer( 60 | graph.NewExecutableSchema( 61 | graph.Config{ 62 | Resolvers: &graph.Resolver{ 63 | AuthService: authService, 64 | TweetService: tweetService, 65 | UserService: userService, 66 | }, 67 | }, 68 | ), 69 | )) 70 | 71 | log.Fatal(http.ListenAndServe(":8080", router)) 72 | } 73 | -------------------------------------------------------------------------------- /cmd/graphqlserver/middleware.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "net/http" 5 | 6 | "github.com/equimper/twitter" 7 | ) 8 | 9 | func authMiddleware(authTokenService twitter.AuthTokenService) func(handler http.Handler) http.Handler { 10 | return func(next http.Handler) http.Handler { 11 | return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { 12 | ctx := r.Context() 13 | 14 | token, err := authTokenService.ParseTokenFromRequest(ctx, r) 15 | if err != nil { 16 | next.ServeHTTP(w, r) 17 | return 18 | } 19 | 20 | // add the user id to the context 21 | ctx = twitter.PutUserIDIntoContext(ctx, token.Sub) 22 | 23 | next.ServeHTTP(w, r.WithContext(ctx)) 24 | }) 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /config/config.go: -------------------------------------------------------------------------------- 1 | package config 2 | 3 | import ( 4 | "os" 5 | "regexp" 6 | 7 | "github.com/joho/godotenv" 8 | ) 9 | 10 | type database struct { 11 | URL string 12 | } 13 | 14 | type jwt struct { 15 | Secret string 16 | Issuer string 17 | } 18 | 19 | type Config struct { 20 | Database database 21 | JWT jwt 22 | } 23 | 24 | func LoadEnv(fileName string) { 25 | re := regexp.MustCompile(`^(.*` + "twitter" + `)`) 26 | cwd, _ := os.Getwd() 27 | rootPath := re.Find([]byte(cwd)) 28 | 29 | err := godotenv.Load(string(rootPath) + `/` + fileName) 30 | if err != nil { 31 | godotenv.Load() 32 | } 33 | } 34 | 35 | func New() *Config { 36 | return &Config{ 37 | Database: database{ 38 | URL: os.Getenv("DATABASE_URL"), 39 | }, 40 | JWT: jwt{ 41 | Secret: os.Getenv("JWT_SECRET"), 42 | Issuer: os.Getenv("DOMAIN"), 43 | }, 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /context.go: -------------------------------------------------------------------------------- 1 | package twitter 2 | 3 | import ( 4 | "context" 5 | ) 6 | 7 | type contextKey string 8 | 9 | var ( 10 | contextAuthIDKey contextKey = "currentUserId" 11 | ) 12 | 13 | func GetUserIDFromContext(ctx context.Context) (string, error) { 14 | if ctx.Value(contextAuthIDKey) == nil { 15 | return "", ErrNoUserIDInContext 16 | } 17 | 18 | userID, ok := ctx.Value(contextAuthIDKey).(string) 19 | if !ok { 20 | return "", ErrNoUserIDInContext 21 | } 22 | 23 | return userID, nil 24 | } 25 | 26 | func PutUserIDIntoContext(ctx context.Context, id string) context.Context { 27 | return context.WithValue(ctx, contextAuthIDKey, id) 28 | } 29 | -------------------------------------------------------------------------------- /context_test.go: -------------------------------------------------------------------------------- 1 | package twitter 2 | 3 | import ( 4 | "context" 5 | "testing" 6 | 7 | "github.com/stretchr/testify/require" 8 | ) 9 | 10 | func TestGetUserIDFromContext(t *testing.T) { 11 | t.Run("get user id from context", func(t *testing.T) { 12 | ctx := context.Background() 13 | 14 | ctx = context.WithValue(ctx, contextAuthIDKey, "123") 15 | 16 | userID, err := GetUserIDFromContext(ctx) 17 | require.NoError(t, err) 18 | require.Equal(t, "123", userID) 19 | }) 20 | 21 | t.Run("return error if no id", func(t *testing.T) { 22 | ctx := context.Background() 23 | 24 | _, err := GetUserIDFromContext(ctx) 25 | require.ErrorIs(t, err, ErrNoUserIDInContext) 26 | }) 27 | 28 | t.Run("return error if value is not a string", func(t *testing.T) { 29 | ctx := context.Background() 30 | 31 | ctx = context.WithValue(ctx, contextAuthIDKey, 123) 32 | 33 | _, err := GetUserIDFromContext(ctx) 34 | require.ErrorIs(t, err, ErrNoUserIDInContext) 35 | 36 | }) 37 | } 38 | 39 | func TestPutUserIDIntoContext(t *testing.T) { 40 | t.Run("add user id into context", func(t *testing.T) { 41 | ctx := context.Background() 42 | 43 | ctx = PutUserIDIntoContext(ctx, "123") 44 | 45 | userID, err := GetUserIDFromContext(ctx) 46 | require.NoError(t, err) 47 | require.Equal(t, "123", userID) 48 | }) 49 | } 50 | -------------------------------------------------------------------------------- /domain/auth.go: -------------------------------------------------------------------------------- 1 | package domain 2 | 3 | import ( 4 | "context" 5 | "errors" 6 | "fmt" 7 | 8 | "github.com/equimper/twitter" 9 | "golang.org/x/crypto/bcrypt" 10 | ) 11 | 12 | var passwordCost = bcrypt.DefaultCost 13 | 14 | type AuthService struct { 15 | AuthTokenService twitter.AuthTokenService 16 | UserRepo twitter.UserRepo 17 | } 18 | 19 | func NewAuthService(ur twitter.UserRepo, ats twitter.AuthTokenService) *AuthService { 20 | return &AuthService{ 21 | AuthTokenService: ats, 22 | UserRepo: ur, 23 | } 24 | } 25 | 26 | func (as *AuthService) Register(ctx context.Context, input twitter.RegisterInput) (twitter.AuthResponse, error) { 27 | input.Sanitize() 28 | 29 | if err := input.Validate(); err != nil { 30 | return twitter.AuthResponse{}, err 31 | } 32 | 33 | // check if username is already taken 34 | if _, err := as.UserRepo.GetByUsername(ctx, input.Username); !errors.Is(err, twitter.ErrNotFound) { 35 | return twitter.AuthResponse{}, twitter.ErrUsernameTaken 36 | } 37 | 38 | // check if email is already taken 39 | if _, err := as.UserRepo.GetByEmail(ctx, input.Email); !errors.Is(err, twitter.ErrNotFound) { 40 | return twitter.AuthResponse{}, twitter.ErrEmailTaken 41 | } 42 | 43 | user := twitter.User{ 44 | Email: input.Email, 45 | Username: input.Username, 46 | } 47 | 48 | // hash the password 49 | hashPassword, err := bcrypt.GenerateFromPassword([]byte(input.Password), passwordCost) 50 | if err != nil { 51 | return twitter.AuthResponse{}, fmt.Errorf("error hashing password: %v", err) 52 | } 53 | 54 | user.Password = string(hashPassword) 55 | 56 | // create the user 57 | user, err = as.UserRepo.Create(ctx, user) 58 | if err != nil { 59 | return twitter.AuthResponse{}, fmt.Errorf("error creating user: %v", err) 60 | } 61 | 62 | accessToken, err := as.AuthTokenService.CreateAccessToken(ctx, user) 63 | if err != nil { 64 | return twitter.AuthResponse{}, twitter.ErrGenAccessToken 65 | } 66 | 67 | // return accessToken and user 68 | return twitter.AuthResponse{ 69 | AccessToken: accessToken, 70 | User: user, 71 | }, nil 72 | } 73 | 74 | func (as *AuthService) Login(ctx context.Context, input twitter.LoginInput) (twitter.AuthResponse, error) { 75 | input.Sanitize() 76 | 77 | if err := input.Validate(); err != nil { 78 | return twitter.AuthResponse{}, err 79 | } 80 | 81 | user, err := as.UserRepo.GetByEmail(ctx, input.Email) 82 | if err != nil { 83 | switch { 84 | case errors.Is(err, twitter.ErrNotFound): 85 | return twitter.AuthResponse{}, twitter.ErrBadCredentials 86 | default: 87 | return twitter.AuthResponse{}, err 88 | } 89 | } 90 | 91 | if err := bcrypt.CompareHashAndPassword([]byte(user.Password), []byte(input.Password)); err != nil { 92 | return twitter.AuthResponse{}, twitter.ErrBadCredentials 93 | } 94 | 95 | accessToken, err := as.AuthTokenService.CreateAccessToken(ctx, user) 96 | if err != nil { 97 | return twitter.AuthResponse{}, twitter.ErrGenAccessToken 98 | } 99 | 100 | return twitter.AuthResponse{ 101 | AccessToken: accessToken, 102 | User: user, 103 | }, nil 104 | } 105 | -------------------------------------------------------------------------------- /domain/auth_integration_test.go: -------------------------------------------------------------------------------- 1 | // +build integration 2 | 3 | package domain 4 | 5 | import ( 6 | "context" 7 | "testing" 8 | 9 | "github.com/equimper/twitter" 10 | "github.com/equimper/twitter/faker" 11 | "github.com/equimper/twitter/test_helpers" 12 | "github.com/stretchr/testify/require" 13 | ) 14 | 15 | func TestIntegrationAuthService_Register(t *testing.T) { 16 | validInput := twitter.RegisterInput{ 17 | Username: faker.Username(), 18 | Email: faker.Email(), 19 | Password: "password", 20 | ConfirmPassword: "password", 21 | } 22 | 23 | t.Run("can register a user", func(t *testing.T) { 24 | ctx := context.Background() 25 | 26 | defer test_helpers.TeardownDB(ctx, t, db) 27 | 28 | res, err := authService.Register(ctx, validInput) 29 | require.NoError(t, err) 30 | 31 | require.NotEmpty(t, res.User.ID) 32 | require.Equal(t, validInput.Email, res.User.Email) 33 | require.Equal(t, validInput.Username, res.User.Username) 34 | require.NotEqual(t, validInput.Password, res.User.Password) 35 | }) 36 | 37 | t.Run("existing username", func(t *testing.T) { 38 | ctx := context.Background() 39 | 40 | defer test_helpers.TeardownDB(ctx, t, db) 41 | 42 | _, err := authService.Register(ctx, validInput) 43 | require.NoError(t, err) 44 | 45 | _, err = authService.Register(ctx, twitter.RegisterInput{ 46 | Username: validInput.Username, 47 | Email: faker.Email(), 48 | Password: "password", 49 | ConfirmPassword: "password", 50 | }) 51 | require.ErrorIs(t, err, twitter.ErrUsernameTaken) 52 | }) 53 | 54 | t.Run("existing email", func(t *testing.T) { 55 | ctx := context.Background() 56 | 57 | defer test_helpers.TeardownDB(ctx, t, db) 58 | 59 | _, err := authService.Register(ctx, validInput) 60 | require.NoError(t, err) 61 | 62 | _, err = authService.Register(ctx, twitter.RegisterInput{ 63 | Username: faker.Username(), 64 | Email: validInput.Email, 65 | Password: "password", 66 | ConfirmPassword: "password", 67 | }) 68 | require.ErrorIs(t, err, twitter.ErrEmailTaken) 69 | }) 70 | } 71 | -------------------------------------------------------------------------------- /domain/auth_test.go: -------------------------------------------------------------------------------- 1 | package domain 2 | 3 | import ( 4 | "context" 5 | "errors" 6 | "testing" 7 | 8 | "github.com/equimper/twitter" 9 | "github.com/equimper/twitter/faker" 10 | "github.com/equimper/twitter/mocks" 11 | "github.com/stretchr/testify/mock" 12 | "github.com/stretchr/testify/require" 13 | ) 14 | 15 | func TestAuthService_Register(t *testing.T) { 16 | validInput := twitter.RegisterInput{ 17 | Username: "bob", 18 | Email: "bob@example.com", 19 | Password: "password", 20 | ConfirmPassword: "password", 21 | } 22 | 23 | t.Run("can register", func(t *testing.T) { 24 | ctx := context.Background() 25 | 26 | userRepo := &mocks.UserRepo{} 27 | 28 | userRepo.On("GetByUsername", mock.Anything, mock.Anything). 29 | Return(twitter.User{}, twitter.ErrNotFound) 30 | 31 | userRepo.On("GetByEmail", mock.Anything, mock.Anything). 32 | Return(twitter.User{}, twitter.ErrNotFound) 33 | 34 | userRepo.On("Create", mock.Anything, mock.Anything). 35 | Return(twitter.User{ 36 | ID: "123", 37 | Username: validInput.Username, 38 | Email: validInput.Email, 39 | }, nil) 40 | 41 | authTokenService := &mocks.AuthTokenService{} 42 | 43 | authTokenService.On("CreateAccessToken", mock.Anything, mock.Anything). 44 | Return("a token", nil) 45 | 46 | service := NewAuthService(userRepo, authTokenService) 47 | 48 | res, err := service.Register(ctx, validInput) 49 | require.NoError(t, err) 50 | 51 | require.NotEmpty(t, res.AccessToken) 52 | require.NotEmpty(t, res.User.ID) 53 | require.NotEmpty(t, res.User.Email) 54 | require.NotEmpty(t, res.User.Username) 55 | 56 | userRepo.AssertExpectations(t) 57 | authTokenService.AssertExpectations(t) 58 | authTokenService.AssertExpectations(t) 59 | }) 60 | 61 | t.Run("username taken", func(t *testing.T) { 62 | ctx := context.Background() 63 | 64 | userRepo := &mocks.UserRepo{} 65 | 66 | userRepo.On("GetByUsername", mock.Anything, mock.Anything). 67 | Return(twitter.User{}, nil) 68 | 69 | authTokenService := &mocks.AuthTokenService{} 70 | 71 | service := NewAuthService(userRepo, authTokenService) 72 | 73 | _, err := service.Register(ctx, validInput) 74 | require.ErrorIs(t, err, twitter.ErrUsernameTaken) 75 | 76 | userRepo.AssertNotCalled(t, "Create") 77 | 78 | userRepo.AssertExpectations(t) 79 | authTokenService.AssertExpectations(t) 80 | }) 81 | 82 | t.Run("email taken", func(t *testing.T) { 83 | ctx := context.Background() 84 | 85 | userRepo := &mocks.UserRepo{} 86 | 87 | userRepo.On("GetByUsername", mock.Anything, mock.Anything). 88 | Return(twitter.User{}, twitter.ErrNotFound) 89 | 90 | userRepo.On("GetByEmail", mock.Anything, mock.Anything). 91 | Return(twitter.User{}, nil) 92 | 93 | authTokenService := &mocks.AuthTokenService{} 94 | 95 | service := NewAuthService(userRepo, authTokenService) 96 | 97 | _, err := service.Register(ctx, validInput) 98 | require.ErrorIs(t, err, twitter.ErrEmailTaken) 99 | 100 | userRepo.AssertNotCalled(t, "Create") 101 | 102 | userRepo.AssertExpectations(t) 103 | authTokenService.AssertExpectations(t) 104 | }) 105 | 106 | t.Run("create error", func(t *testing.T) { 107 | ctx := context.Background() 108 | 109 | userRepo := &mocks.UserRepo{} 110 | 111 | userRepo.On("GetByUsername", mock.Anything, mock.Anything). 112 | Return(twitter.User{}, twitter.ErrNotFound) 113 | 114 | userRepo.On("GetByEmail", mock.Anything, mock.Anything). 115 | Return(twitter.User{}, twitter.ErrNotFound) 116 | 117 | userRepo.On("Create", mock.Anything, mock.Anything). 118 | Return(twitter.User{}, errors.New("something")) 119 | 120 | authTokenService := &mocks.AuthTokenService{} 121 | 122 | service := NewAuthService(userRepo, authTokenService) 123 | 124 | _, err := service.Register(ctx, validInput) 125 | require.Error(t, err) 126 | 127 | userRepo.AssertExpectations(t) 128 | authTokenService.AssertExpectations(t) 129 | }) 130 | 131 | t.Run("invalid input", func(t *testing.T) { 132 | ctx := context.Background() 133 | 134 | userRepo := &mocks.UserRepo{} 135 | 136 | authTokenService := &mocks.AuthTokenService{} 137 | 138 | service := NewAuthService(userRepo, authTokenService) 139 | 140 | _, err := service.Register(ctx, twitter.RegisterInput{}) 141 | require.ErrorIs(t, err, twitter.ErrValidation) 142 | 143 | userRepo.AssertNotCalled(t, "GetByUsername") 144 | userRepo.AssertNotCalled(t, "GetByEmail") 145 | userRepo.AssertNotCalled(t, "Create") 146 | 147 | userRepo.AssertExpectations(t) 148 | authTokenService.AssertExpectations(t) 149 | }) 150 | 151 | t.Run("can't generate access token", func(t *testing.T) { 152 | ctx := context.Background() 153 | 154 | userRepo := &mocks.UserRepo{} 155 | 156 | userRepo.On("GetByUsername", mock.Anything, mock.Anything). 157 | Return(twitter.User{}, twitter.ErrNotFound) 158 | 159 | userRepo.On("GetByEmail", mock.Anything, mock.Anything). 160 | Return(twitter.User{}, twitter.ErrNotFound) 161 | 162 | userRepo.On("Create", mock.Anything, mock.Anything). 163 | Return(twitter.User{ 164 | ID: "123", 165 | Username: validInput.Username, 166 | Email: validInput.Email, 167 | }, nil) 168 | 169 | authTokenService := &mocks.AuthTokenService{} 170 | 171 | authTokenService.On("CreateAccessToken", mock.Anything, mock.Anything). 172 | Return("", errors.New("error")) 173 | 174 | service := NewAuthService(userRepo, authTokenService) 175 | 176 | _, err := service.Register(ctx, validInput) 177 | require.ErrorIs(t, err, twitter.ErrGenAccessToken) 178 | 179 | userRepo.AssertExpectations(t) 180 | authTokenService.AssertExpectations(t) 181 | }) 182 | } 183 | 184 | func TestAuthService_Login(t *testing.T) { 185 | validInput := twitter.LoginInput{ 186 | Email: "bob@gmail.com", 187 | Password: "password", 188 | } 189 | 190 | t.Run("can login", func(t *testing.T) { 191 | ctx := context.Background() 192 | 193 | userRepo := &mocks.UserRepo{} 194 | 195 | userRepo.On("GetByEmail", mock.Anything, mock.Anything). 196 | Return(twitter.User{ 197 | Email: validInput.Email, 198 | Password: faker.Password, 199 | }, nil) 200 | 201 | authTokenService := &mocks.AuthTokenService{} 202 | 203 | authTokenService.On("CreateAccessToken", mock.Anything, mock.Anything). 204 | Return("a token", nil) 205 | 206 | service := NewAuthService(userRepo, authTokenService) 207 | 208 | _, err := service.Login(ctx, validInput) 209 | require.NoError(t, err) 210 | 211 | userRepo.AssertExpectations(t) 212 | authTokenService.AssertExpectations(t) 213 | }) 214 | 215 | t.Run("wrong password", func(t *testing.T) { 216 | ctx := context.Background() 217 | 218 | userRepo := &mocks.UserRepo{} 219 | 220 | userRepo.On("GetByEmail", mock.Anything, mock.Anything). 221 | Return(twitter.User{ 222 | Email: validInput.Email, 223 | Password: faker.Password, 224 | }, nil) 225 | 226 | authTokenService := &mocks.AuthTokenService{} 227 | 228 | service := NewAuthService(userRepo, authTokenService) 229 | 230 | input := twitter.LoginInput{ 231 | Email: validInput.Email, 232 | Password: "somethingelse", 233 | } 234 | 235 | _, err := service.Login(ctx, input) 236 | require.ErrorIs(t, err, twitter.ErrBadCredentials) 237 | 238 | userRepo.AssertExpectations(t) 239 | authTokenService.AssertExpectations(t) 240 | }) 241 | 242 | t.Run("email not found", func(t *testing.T) { 243 | ctx := context.Background() 244 | 245 | userRepo := &mocks.UserRepo{} 246 | 247 | userRepo.On("GetByEmail", mock.Anything, mock.Anything). 248 | Return(twitter.User{}, twitter.ErrNotFound) 249 | 250 | authTokenService := &mocks.AuthTokenService{} 251 | 252 | service := NewAuthService(userRepo, authTokenService) 253 | 254 | _, err := service.Login(ctx, validInput) 255 | require.ErrorIs(t, err, twitter.ErrBadCredentials) 256 | 257 | userRepo.AssertExpectations(t) 258 | authTokenService.AssertExpectations(t) 259 | }) 260 | 261 | t.Run("get user by email error", func(t *testing.T) { 262 | ctx := context.Background() 263 | 264 | userRepo := &mocks.UserRepo{} 265 | 266 | userRepo.On("GetByEmail", mock.Anything, mock.Anything). 267 | Return(twitter.User{}, errors.New("something")) 268 | 269 | authTokenService := &mocks.AuthTokenService{} 270 | 271 | service := NewAuthService(userRepo, authTokenService) 272 | 273 | _, err := service.Login(ctx, validInput) 274 | require.Error(t, err) 275 | 276 | userRepo.AssertExpectations(t) 277 | authTokenService.AssertExpectations(t) 278 | }) 279 | 280 | t.Run("invalid input", func(t *testing.T) { 281 | ctx := context.Background() 282 | 283 | userRepo := &mocks.UserRepo{} 284 | 285 | authTokenService := &mocks.AuthTokenService{} 286 | 287 | service := NewAuthService(userRepo, authTokenService) 288 | 289 | _, err := service.Login(ctx, twitter.LoginInput{ 290 | Email: "bob", 291 | Password: "", 292 | }) 293 | require.ErrorIs(t, err, twitter.ErrValidation) 294 | 295 | userRepo.AssertExpectations(t) 296 | authTokenService.AssertExpectations(t) 297 | }) 298 | 299 | t.Run("can't generate access token", func(t *testing.T) { 300 | ctx := context.Background() 301 | 302 | userRepo := &mocks.UserRepo{} 303 | 304 | userRepo.On("GetByEmail", mock.Anything, mock.Anything). 305 | Return(twitter.User{ 306 | Email: validInput.Email, 307 | Password: faker.Password, 308 | }, nil) 309 | 310 | authTokenService := &mocks.AuthTokenService{} 311 | 312 | authTokenService.On("CreateAccessToken", mock.Anything, mock.Anything). 313 | Return("", errors.New("error")) 314 | 315 | service := NewAuthService(userRepo, authTokenService) 316 | 317 | _, err := service.Login(ctx, validInput) 318 | require.ErrorIs(t, err, twitter.ErrGenAccessToken) 319 | 320 | userRepo.AssertExpectations(t) 321 | authTokenService.AssertExpectations(t) 322 | }) 323 | } 324 | -------------------------------------------------------------------------------- /domain/domain_integration_test.go: -------------------------------------------------------------------------------- 1 | // +build integration 2 | 3 | package domain 4 | 5 | import ( 6 | "context" 7 | "log" 8 | "os" 9 | "testing" 10 | 11 | "github.com/equimper/twitter" 12 | "github.com/equimper/twitter/config" 13 | "github.com/equimper/twitter/jwt" 14 | "github.com/equimper/twitter/postgres" 15 | "golang.org/x/crypto/bcrypt" 16 | ) 17 | 18 | var ( 19 | conf *config.Config 20 | db *postgres.DB 21 | authTokenService twitter.AuthTokenService 22 | authService twitter.AuthService 23 | tweetService twitter.TweetService 24 | userRepo twitter.UserRepo 25 | tweetRepo twitter.TweetRepo 26 | ) 27 | 28 | func TestMain(m *testing.M) { 29 | ctx := context.Background() 30 | 31 | config.LoadEnv(".env.test") 32 | 33 | passwordCost = bcrypt.MinCost 34 | 35 | conf = config.New() 36 | 37 | db = postgres.New(ctx, conf) 38 | defer db.Close() 39 | 40 | if err := db.Drop(); err != nil { 41 | log.Fatal(err) 42 | } 43 | 44 | if err := db.Migrate(); err != nil { 45 | log.Fatal(err) 46 | } 47 | 48 | userRepo = postgres.NewUserRepo(db) 49 | tweetRepo = postgres.NewTweetRepo(db) 50 | 51 | authTokenService = jwt.NewTokenService(conf) 52 | 53 | authService = NewAuthService(userRepo, authTokenService) 54 | tweetService = NewTweetService(tweetRepo) 55 | 56 | os.Exit(m.Run()) 57 | } 58 | -------------------------------------------------------------------------------- /domain/tweet.go: -------------------------------------------------------------------------------- 1 | package domain 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/equimper/twitter" 7 | "github.com/equimper/twitter/uuid" 8 | ) 9 | 10 | type TweetService struct { 11 | TweetRepo twitter.TweetRepo 12 | } 13 | 14 | func NewTweetService(tr twitter.TweetRepo) *TweetService { 15 | return &TweetService{ 16 | TweetRepo: tr, 17 | } 18 | } 19 | 20 | func (ts *TweetService) All(ctx context.Context) ([]twitter.Tweet, error) { 21 | return ts.TweetRepo.All(ctx) 22 | } 23 | 24 | func (ts *TweetService) GetByParentID(ctx context.Context, id string) ([]twitter.Tweet, error) { 25 | return ts.TweetRepo.GetByParentID(ctx, id) 26 | } 27 | 28 | func (ts *TweetService) Create(ctx context.Context, input twitter.CreateTweetInput) (twitter.Tweet, error) { 29 | currentUserID, err := twitter.GetUserIDFromContext(ctx) 30 | if err != nil { 31 | return twitter.Tweet{}, twitter.ErrUnauthenticated 32 | } 33 | 34 | input.Sanitize() 35 | 36 | if err := input.Validate(); err != nil { 37 | return twitter.Tweet{}, err 38 | } 39 | 40 | tweet, err := ts.TweetRepo.Create(ctx, twitter.Tweet{ 41 | Body: input.Body, 42 | UserID: currentUserID, 43 | }) 44 | if err != nil { 45 | return twitter.Tweet{}, err 46 | } 47 | 48 | return tweet, nil 49 | } 50 | 51 | func (ts *TweetService) GetByID(ctx context.Context, id string) (twitter.Tweet, error) { 52 | if !uuid.Validate(id) { 53 | return twitter.Tweet{}, twitter.ErrInvalidUUID 54 | } 55 | 56 | return ts.TweetRepo.GetByID(ctx, id) 57 | } 58 | 59 | func (ts *TweetService) Delete(ctx context.Context, id string) error { 60 | currentUserID, err := twitter.GetUserIDFromContext(ctx) 61 | if err != nil { 62 | return twitter.ErrUnauthenticated 63 | } 64 | 65 | if !uuid.Validate(id) { 66 | return twitter.ErrInvalidUUID 67 | } 68 | 69 | tweet, err := ts.TweetRepo.GetByID(ctx, id) 70 | if err != nil { 71 | return err 72 | } 73 | 74 | if !tweet.CanDelete(twitter.User{ID: currentUserID}) { 75 | return twitter.ErrForbidden 76 | } 77 | 78 | return ts.TweetRepo.Delete(ctx, id) 79 | } 80 | 81 | func (ts *TweetService) CreateReply(ctx context.Context, parentID string, input twitter.CreateTweetInput) (twitter.Tweet, error) { 82 | currentUserID, err := twitter.GetUserIDFromContext(ctx) 83 | if err != nil { 84 | return twitter.Tweet{}, twitter.ErrUnauthenticated 85 | } 86 | 87 | input.Sanitize() 88 | 89 | if err := input.Validate(); err != nil { 90 | return twitter.Tweet{}, err 91 | } 92 | 93 | if !uuid.Validate(parentID) { 94 | return twitter.Tweet{}, twitter.ErrInvalidUUID 95 | } 96 | 97 | if _, err := ts.TweetRepo.GetByID(ctx, parentID); err != nil { 98 | return twitter.Tweet{}, twitter.ErrNotFound 99 | } 100 | 101 | tweet, err := ts.TweetRepo.Create(ctx, twitter.Tweet{ 102 | Body: input.Body, 103 | UserID: currentUserID, 104 | ParentID: &parentID, 105 | }) 106 | if err != nil { 107 | return twitter.Tweet{}, err 108 | } 109 | 110 | return tweet, nil 111 | } 112 | -------------------------------------------------------------------------------- /domain/tweet_integration_test.go: -------------------------------------------------------------------------------- 1 | //go:build integration 2 | // +build integration 3 | 4 | package domain 5 | 6 | import ( 7 | "context" 8 | "testing" 9 | 10 | "github.com/equimper/twitter" 11 | "github.com/equimper/twitter/faker" 12 | "github.com/equimper/twitter/test_helpers" 13 | "github.com/stretchr/testify/require" 14 | ) 15 | 16 | func TestIntegrationTweetService_Create(t *testing.T) { 17 | t.Run("not auth user cannot create a tweet", func(t *testing.T) { 18 | ctx := context.Background() 19 | 20 | _, err := tweetService.Create(ctx, twitter.CreateTweetInput{ 21 | Body: "hello", 22 | }) 23 | 24 | require.ErrorIs(t, err, twitter.ErrUnauthenticated) 25 | }) 26 | 27 | t.Run("can create a tweet", func(t *testing.T) { 28 | ctx := context.Background() 29 | 30 | defer test_helpers.TeardownDB(ctx, t, db) 31 | 32 | currentUser := test_helpers.CreateUser(ctx, t, userRepo) 33 | 34 | ctx = test_helpers.LoginUser(ctx, t, currentUser) 35 | 36 | input := twitter.CreateTweetInput{ 37 | Body: faker.RandStr(100), 38 | } 39 | 40 | tweet, err := tweetService.Create(ctx, input) 41 | require.NoError(t, err) 42 | 43 | require.NotEmpty(t, tweet.ID, "tweet.ID") 44 | require.Equal(t, input.Body, tweet.Body, "tweet.Body") 45 | require.Equal(t, currentUser.ID, tweet.UserID, "tweet.UserID") 46 | require.NotEmpty(t, tweet.CreatedAt, "tweet.CreatedAt") 47 | }) 48 | } 49 | 50 | func TestIntegrationTweetService_All(t *testing.T) { 51 | t.Run("return all tweets", func(t *testing.T) { 52 | ctx := context.Background() 53 | 54 | defer test_helpers.TeardownDB(ctx, t, db) 55 | 56 | user := test_helpers.CreateUser(ctx, t, userRepo) 57 | 58 | test_helpers.CreateTweet(ctx, t, tweetRepo, user.ID) 59 | test_helpers.CreateTweet(ctx, t, tweetRepo, user.ID) 60 | test_helpers.CreateTweet(ctx, t, tweetRepo, user.ID) 61 | 62 | tweets, err := tweetService.All(ctx) 63 | require.NoError(t, err) 64 | 65 | require.Len(t, tweets, 3) 66 | }) 67 | } 68 | 69 | func TestIntegrationTweetService_GetByID(t *testing.T) { 70 | t.Run("can get a tweet by id", func(t *testing.T) { 71 | ctx := context.Background() 72 | 73 | defer test_helpers.TeardownDB(ctx, t, db) 74 | 75 | user := test_helpers.CreateUser(ctx, t, userRepo) 76 | existingTweet := test_helpers.CreateTweet(ctx, t, tweetRepo, user.ID) 77 | 78 | tweet, err := tweetService.GetByID(ctx, existingTweet.ID) 79 | require.NoError(t, err) 80 | 81 | require.Equal(t, existingTweet.ID, tweet.ID, "tweet.ID") 82 | require.Equal(t, existingTweet.Body, tweet.Body, "tweet.Body") 83 | }) 84 | 85 | t.Run("return error not found if the tweet doesn't exist", func(t *testing.T) { 86 | ctx := context.Background() 87 | 88 | defer test_helpers.TeardownDB(ctx, t, db) 89 | 90 | _, err := tweetService.GetByID(ctx, faker.UUID()) 91 | require.ErrorIs(t, err, twitter.ErrNotFound) 92 | }) 93 | 94 | t.Run("return error invalid uuid", func(t *testing.T) { 95 | ctx := context.Background() 96 | 97 | defer test_helpers.TeardownDB(ctx, t, db) 98 | 99 | _, err := tweetService.GetByID(ctx, "123") 100 | require.ErrorIs(t, err, twitter.ErrInvalidUUID) 101 | }) 102 | } 103 | 104 | func TestIntegrationTweetService_Delete(t *testing.T) { 105 | t.Run("not auth user cannot delete a tweet", func(t *testing.T) { 106 | ctx := context.Background() 107 | 108 | err := tweetService.Delete(ctx, faker.UUID()) 109 | require.ErrorIs(t, err, twitter.ErrUnauthenticated) 110 | }) 111 | 112 | t.Run("cannot delete a tweet if not the owner", func(t *testing.T) { 113 | ctx := context.Background() 114 | 115 | defer test_helpers.TeardownDB(ctx, t, db) 116 | 117 | otherUser := test_helpers.CreateUser(ctx, t, userRepo) 118 | currentUser := test_helpers.CreateUser(ctx, t, userRepo) 119 | 120 | tweet := test_helpers.CreateTweet(ctx, t, tweetRepo, otherUser.ID) 121 | 122 | ctx = test_helpers.LoginUser(ctx, t, currentUser) 123 | 124 | // check exist 125 | _, err := tweetRepo.GetByID(ctx, tweet.ID) 126 | require.NoError(t, err) 127 | 128 | err = tweetService.Delete(ctx, tweet.ID) 129 | require.ErrorIs(t, err, twitter.ErrForbidden) 130 | 131 | // check exist 132 | _, err = tweetRepo.GetByID(ctx, tweet.ID) 133 | require.NoError(t, err) 134 | }) 135 | 136 | t.Run("can delete a tweet", func(t *testing.T) { 137 | ctx := context.Background() 138 | 139 | defer test_helpers.TeardownDB(ctx, t, db) 140 | 141 | currentUser := test_helpers.CreateUser(ctx, t, userRepo) 142 | 143 | tweet := test_helpers.CreateTweet(ctx, t, tweetRepo, currentUser.ID) 144 | 145 | ctx = test_helpers.LoginUser(ctx, t, currentUser) 146 | 147 | // check exist 148 | _, err := tweetRepo.GetByID(ctx, tweet.ID) 149 | require.NoError(t, err) 150 | 151 | err = tweetService.Delete(ctx, tweet.ID) 152 | require.NoError(t, err) 153 | 154 | // check not exist 155 | _, err = tweetRepo.GetByID(ctx, tweet.ID) 156 | require.ErrorIs(t, err, twitter.ErrNotFound) 157 | }) 158 | } 159 | 160 | func TestIntegrationTweetService_CreateReply(t *testing.T) { 161 | t.Run("not auth user cannot create a reply to a tweet", func(t *testing.T) { 162 | ctx := context.Background() 163 | 164 | _, err := tweetService.CreateReply(ctx, faker.UUID(), twitter.CreateTweetInput{ 165 | Body: faker.RandStr(20), 166 | }) 167 | require.ErrorIs(t, err, twitter.ErrUnauthenticated) 168 | }) 169 | 170 | t.Run("cannot create a reply to a not found tweet", func(t *testing.T) { 171 | ctx := context.Background() 172 | 173 | defer test_helpers.TeardownDB(ctx, t, db) 174 | 175 | currentUser := test_helpers.CreateUser(ctx, t, userRepo) 176 | 177 | ctx = test_helpers.LoginUser(ctx, t, currentUser) 178 | 179 | _, err := tweetService.CreateReply(ctx, faker.UUID(), twitter.CreateTweetInput{ 180 | Body: faker.RandStr(20), 181 | }) 182 | require.ErrorIs(t, err, twitter.ErrNotFound) 183 | }) 184 | 185 | t.Run("can create a reply to a tweet", func(t *testing.T) { 186 | ctx := context.Background() 187 | 188 | defer test_helpers.TeardownDB(ctx, t, db) 189 | 190 | currentUser := test_helpers.CreateUser(ctx, t, userRepo) 191 | 192 | ctx = test_helpers.LoginUser(ctx, t, currentUser) 193 | 194 | tweet := test_helpers.CreateTweet(ctx, t, tweetRepo, currentUser.ID) 195 | 196 | input := twitter.CreateTweetInput{ 197 | Body: faker.RandStr(20), 198 | } 199 | 200 | reply, err := tweetService.CreateReply(ctx, tweet.ID, input) 201 | require.NoError(t, err) 202 | 203 | require.NotEmpty(t, reply.ID, "reply.ID") 204 | require.Equal(t, input.Body, reply.Body, "reply.Body") 205 | require.Equal(t, currentUser.ID, reply.UserID, "reply.UserID") 206 | require.Equal(t, tweet.ID, *reply.ParentID, "reply.ParentID") 207 | require.NotEmpty(t, reply.CreatedAt, "reply.CreatedAt") 208 | }) 209 | } 210 | -------------------------------------------------------------------------------- /domain/user.go: -------------------------------------------------------------------------------- 1 | package domain 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/equimper/twitter" 7 | "github.com/equimper/twitter/uuid" 8 | ) 9 | 10 | type UserService struct { 11 | UserRepo twitter.UserRepo 12 | } 13 | 14 | func NewUserService(ur twitter.UserRepo) *UserService { 15 | return &UserService{ 16 | UserRepo: ur, 17 | } 18 | } 19 | 20 | func (u *UserService) GetByID(ctx context.Context, id string) (twitter.User, error) { 21 | if !uuid.Validate(id) { 22 | return twitter.User{}, twitter.ErrInvalidUUID 23 | } 24 | 25 | return u.UserRepo.GetByID(ctx, id) 26 | } 27 | -------------------------------------------------------------------------------- /faker/faker.go: -------------------------------------------------------------------------------- 1 | package faker 2 | 3 | import ( 4 | "fmt" 5 | "math/rand" 6 | "time" 7 | 8 | "github.com/equimper/twitter/uuid" 9 | ) 10 | 11 | func init() { 12 | rand.Seed(time.Now().UnixNano()) 13 | } 14 | 15 | // Password equal password 16 | var Password = "$2a$04$5vcLELOMsTLvXsUM9Nd.FegPIrNRT3s1mjEyH3rk2mh/b9iQGHLzG" 17 | 18 | var letterRunes = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ") 19 | 20 | func randStringRunes(n int) string { 21 | b := make([]rune, n) 22 | for i := range b { 23 | b[i] = letterRunes[rand.Intn(len(letterRunes))] 24 | } 25 | 26 | return string(b) 27 | } 28 | 29 | func randStringLowerRunes(n int) string { 30 | b := make([]rune, n) 31 | for i := range b { 32 | b[i] = letterRunes[rand.Intn(len(letterRunes)/2)] 33 | } 34 | 35 | return string(b) 36 | } 37 | 38 | func RandInt(min, max int) int { 39 | return rand.Intn(max-min+1) + min 40 | } 41 | 42 | func Username() string { 43 | return randStringRunes(RandInt(2, 10)) 44 | } 45 | 46 | func ID() string { 47 | return fmt.Sprintf("%s-%s-%s-%s", randStringRunes(4), randStringRunes(4), randStringRunes(4), randStringRunes(4)) 48 | } 49 | 50 | func UUID() string { 51 | return uuid.Generate() 52 | } 53 | 54 | func Email() string { 55 | return fmt.Sprintf("%s@example.com", randStringLowerRunes(RandInt(5, 10))) 56 | } 57 | 58 | func RandStr(n int) string { 59 | return randStringRunes(n) 60 | } 61 | -------------------------------------------------------------------------------- /go.mod: -------------------------------------------------------------------------------- 1 | module github.com/equimper/twitter 2 | 3 | go 1.16 4 | 5 | require ( 6 | github.com/99designs/gqlgen v0.13.0 7 | github.com/georgysavva/scany v0.2.8 8 | github.com/go-chi/chi v3.3.2+incompatible 9 | github.com/golang-migrate/migrate/v4 v4.14.1 10 | github.com/google/uuid v1.3.0 11 | github.com/jackc/pgx/v4 v4.11.0 12 | github.com/joho/godotenv v1.3.0 13 | github.com/lestrrat-go/jwx v1.2.1 14 | github.com/sirupsen/logrus v1.8.1 15 | github.com/stretchr/testify v1.7.0 16 | github.com/vektah/gqlparser/v2 v2.1.0 17 | golang.org/x/crypto v0.0.0-20210506145944-38f3c27a63bf 18 | golang.org/x/sys v0.13.0 // indirect 19 | golang.org/x/text v0.3.6 // indirect 20 | ) 21 | -------------------------------------------------------------------------------- /go.sum: -------------------------------------------------------------------------------- 1 | cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= 2 | cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= 3 | cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU= 4 | cloud.google.com/go v0.44.1/go.mod h1:iSa0KzasP4Uvy3f1mN/7PiObzGgflwredwwASm/v6AU= 5 | cloud.google.com/go v0.44.2/go.mod h1:60680Gw3Yr4ikxnPRS/oxxkBccT6SA1yMk63TGekxKY= 6 | cloud.google.com/go v0.45.1/go.mod h1:RpBamKRgapWJb87xiFSdk4g1CME7QZg3uwTez+TSTjc= 7 | cloud.google.com/go v0.46.3/go.mod h1:a6bKKbmY7er1mI7TEI4lsAkts/mkhTSZK8w33B4RAg0= 8 | cloud.google.com/go v0.50.0/go.mod h1:r9sluTvynVuxRIOHXQEHMFffphuXHOMZMycpNR5e6To= 9 | cloud.google.com/go v0.52.0/go.mod h1:pXajvRH/6o3+F9jDHZWQ5PbGhn+o8w9qiu/CffaVdO4= 10 | cloud.google.com/go v0.53.0/go.mod h1:fp/UouUEsRkN6ryDKNW/Upv/JBKnv6WDthjR6+vze6M= 11 | cloud.google.com/go v0.54.0/go.mod h1:1rq2OEkV3YMf6n/9ZvGWI3GWw0VoqH/1x2nd8Is/bPc= 12 | cloud.google.com/go v0.56.0/go.mod h1:jr7tqZxxKOVYizybht9+26Z/gUq7tiRzu+ACVAMbKVk= 13 | cloud.google.com/go v0.57.0/go.mod h1:oXiQ6Rzq3RAkkY7N6t3TcE6jE+CIBBbA36lwQ1JyzZs= 14 | cloud.google.com/go v0.62.0/go.mod h1:jmCYTdRCQuc1PHIIJ/maLInMho30T/Y0M4hTdTShOYc= 15 | cloud.google.com/go v0.63.0/go.mod h1:GmezbQc7T2snqkEXWfZ0sy0VfkB/ivI2DdtJL2DEmlg= 16 | cloud.google.com/go v0.64.0/go.mod h1:xfORb36jGvE+6EexW71nMEtL025s3x6xvuYUKM4JLv4= 17 | cloud.google.com/go/bigquery v1.0.1/go.mod h1:i/xbL2UlR5RvWAURpBYZTtm/cXjCha9lbfbpx4poX+o= 18 | cloud.google.com/go/bigquery v1.3.0/go.mod h1:PjpwJnslEMmckchkHFfq+HTD2DmtT67aNFKH1/VBDHE= 19 | cloud.google.com/go/bigquery v1.4.0/go.mod h1:S8dzgnTigyfTmLBfrtrhyYhwRxG72rYxvftPBK2Dvzc= 20 | cloud.google.com/go/bigquery v1.5.0/go.mod h1:snEHRnqQbz117VIFhE8bmtwIDY80NLUZUMb4Nv6dBIg= 21 | cloud.google.com/go/bigquery v1.7.0/go.mod h1://okPTzCYNXSlb24MZs83e2Do+h+VXtc4gLoIoXIAPc= 22 | cloud.google.com/go/bigquery v1.8.0/go.mod h1:J5hqkt3O0uAFnINi6JXValWIb1v0goeZM77hZzJN/fQ= 23 | cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE= 24 | cloud.google.com/go/datastore v1.1.0/go.mod h1:umbIZjpQpHh4hmRpGhH4tLFup+FVzqBi1b3c64qFpCk= 25 | cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2kNxGRt3I= 26 | cloud.google.com/go/pubsub v1.1.0/go.mod h1:EwwdRX2sKPjnvnqCa270oGRyludottCI76h+R3AArQw= 27 | cloud.google.com/go/pubsub v1.2.0/go.mod h1:jhfEVHT8odbXTkndysNHCcx0awwzvfOlguIAii9o8iA= 28 | cloud.google.com/go/pubsub v1.3.1/go.mod h1:i+ucay31+CNRpDW4Lu78I4xXG+O1r/MAHgjpRVR+TSU= 29 | cloud.google.com/go/spanner v1.9.0/go.mod h1:xvlEn0NZ5v1iJPYsBnUVRDNvccDxsBTEi16pJRKQVws= 30 | cloud.google.com/go/storage v1.0.0/go.mod h1:IhtSnM/ZTZV8YYJWCY8RULGVqBDmpoyjwiyrjsg+URw= 31 | cloud.google.com/go/storage v1.5.0/go.mod h1:tpKbwo567HUNpVclU5sGELwQWBDZ8gh0ZeosJ0Rtdos= 32 | cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohlUTyfDhBk= 33 | cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs= 34 | cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0= 35 | dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= 36 | github.com/99designs/gqlgen v0.13.0 h1:haLTcUp3Vwp80xMVEg5KRNwzfUrgFdRmtBY8fuB8scA= 37 | github.com/99designs/gqlgen v0.13.0/go.mod h1:NV130r6f4tpRWuAI+zsrSdooO/eWUv+Gyyoi3rEfXIk= 38 | github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78 h1:w+iIsaOQNcT7OZ575w+acHgRric5iCyQh+xv+KJ4HB8= 39 | github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78/go.mod h1:LmzpDX56iTiv29bbRTIsUNlaFfuhWRQBWjQdVyAevI8= 40 | github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= 41 | github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= 42 | github.com/ClickHouse/clickhouse-go v1.3.12/go.mod h1:EaI/sW7Azgz9UATzd5ZdZHRUhHgv5+JMS9NSr2smCJI= 43 | github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0= 44 | github.com/Masterminds/semver/v3 v3.1.1/go.mod h1:VPu/7SZ7ePZ3QOrcuXROw5FAcLl4a0cBrbBpGY/8hQs= 45 | github.com/Microsoft/go-winio v0.4.15-0.20190919025122-fc70bd9a86b5 h1:ygIc8M6trr62pF5DucadTWGdEB4mEyvzi0e2nbcmcyA= 46 | github.com/Microsoft/go-winio v0.4.15-0.20190919025122-fc70bd9a86b5/go.mod h1:tTuCMEN+UleMWgg9dVx4Hu52b1bJo+59jBh3ajtinzw= 47 | github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWXgklEdEo= 48 | github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI= 49 | github.com/VividCortex/gohistogram v1.0.0/go.mod h1:Pf5mBqqDxYaXu3hDrrU+w6nw50o/4+TcAqDqk/vUH7g= 50 | github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5/go.mod h1:SkGFH1ia65gfNATL8TAiHDNxPzPdmEL5uirI2Uyuz6c= 51 | github.com/agnivade/levenshtein v1.0.1/go.mod h1:CURSv5d9Uaml+FovSIICkLbAUZ9S4RqaHDIsdSBg7lM= 52 | github.com/agnivade/levenshtein v1.0.3 h1:M5ZnqLOoZR8ygVq0FfkXsNOKzMCk0xRiow0R5+5VkQ0= 53 | github.com/agnivade/levenshtein v1.0.3/go.mod h1:4SFRZbbXWLF4MU1T9Qg0pGgH3Pjs+t6ie5efyrwRJXs= 54 | github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= 55 | github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= 56 | github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= 57 | github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= 58 | github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883 h1:bvNMNQO63//z+xNgfBlViaCIJKLlCJ6/fmUseuG0wVQ= 59 | github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883/go.mod h1:rCTlJbsFo29Kk6CurOXKm700vrz8f0KW0JNfpkRJY/8= 60 | github.com/apache/arrow/go/arrow v0.0.0-20200601151325-b2287a20f230/go.mod h1:QNYViu/X0HXDHw7m3KXzWSVXIbfUvJqBFe6Gj8/pYA0= 61 | github.com/apache/thrift v0.12.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ= 62 | github.com/apache/thrift v0.13.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ= 63 | github.com/arbovm/levenshtein v0.0.0-20160628152529-48b4e1c0c4d0 h1:jfIu9sQUG6Ig+0+Ap1h4unLjW6YQJpKZVmUzxsD4E/Q= 64 | github.com/arbovm/levenshtein v0.0.0-20160628152529-48b4e1c0c4d0/go.mod h1:t2tdKJDJF9BV14lnkjHmOQgcvEKgtqs5a1N3LNdJhGE= 65 | github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o= 66 | github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY= 67 | github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= 68 | github.com/aryann/difflib v0.0.0-20170710044230-e206f873d14a/go.mod h1:DAHtR1m6lCRdSC2Tm3DSWRPvIPr6xNKyeHdqDQSQT+A= 69 | github.com/aws/aws-lambda-go v1.13.3/go.mod h1:4UKl9IzQMoD+QF79YdCuzCwp8VbmG4VAQwij/eHl5CU= 70 | github.com/aws/aws-sdk-go v1.17.7/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo= 71 | github.com/aws/aws-sdk-go v1.27.0/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo= 72 | github.com/aws/aws-sdk-go-v2 v0.18.0/go.mod h1:JWVYvqSMppoMJC0x5wdwiImzgXTI9FuZwxzkQq9wy+g= 73 | github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= 74 | github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= 75 | github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= 76 | github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= 77 | github.com/bitly/go-hostpool v0.0.0-20171023180738-a3a6125de932/go.mod h1:NOuUCSz6Q9T7+igc/hlvDOUdtWKryOrtFyIVABv/p7k= 78 | github.com/bkaradzic/go-lz4 v1.0.0/go.mod h1:0YdlkowM3VswSROI7qDxhRvJ3sLhlFrRRwjwegp5jy4= 79 | github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869/go.mod h1:Ekp36dRnpXw/yCqJaO+ZrUyxD+3VXMFFr56k5XYrpB4= 80 | github.com/casbin/casbin/v2 v2.1.2/go.mod h1:YcPU1XXisHhLzuxH9coDNf2FbKpjGlbCg3n9yuLkIJQ= 81 | github.com/cenkalti/backoff v2.2.1+incompatible/go.mod h1:90ReRw6GdpyfrHakVjL/QHaoyV4aDUVVkXQJJJ3NXXM= 82 | github.com/cenkalti/backoff/v4 v4.0.2/go.mod h1:eEew/i+1Q6OrCDZh3WiXYv3+nJwBASZ8Bog/87DQnVg= 83 | github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= 84 | github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= 85 | github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= 86 | github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= 87 | github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= 88 | github.com/clbanning/x2j v0.0.0-20191024224557-825249438eec/go.mod h1:jMjuTZXRI4dUb/I5gc9Hdhagfvm9+RyrPryS/auMzxE= 89 | github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= 90 | github.com/cloudflare/golz4 v0.0.0-20150217214814-ef862a3cdc58/go.mod h1:EOBUe0h4xcZ5GoxqC5SDxFQ8gwyZPKQoEzownBlhI80= 91 | github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= 92 | github.com/cockroachdb/apd v1.1.0 h1:3LFP3629v+1aKXU5Q37mxmRxX/pIu1nijXydLShEq5I= 93 | github.com/cockroachdb/apd v1.1.0/go.mod h1:8Sl8LxpKi29FqWXR16WEFZRNSz3SoPzUzeMeY4+DwBQ= 94 | github.com/cockroachdb/cockroach-go v0.0.0-20190925194419-606b3d062051 h1:eApuUG8W2EtBVwxqLlY2wgoqDYOg3WvIHGvW4fUbbow= 95 | github.com/cockroachdb/cockroach-go v0.0.0-20190925194419-606b3d062051/go.mod h1:XGLbWH/ujMcbPbhZq52Nv6UrCghb1yGn//133kEsvDk= 96 | github.com/cockroachdb/cockroach-go/v2 v2.0.3 h1:ZA346ACHIZctef6trOTwBAEvPVm1k0uLm/bb2Atc+S8= 97 | github.com/cockroachdb/cockroach-go/v2 v2.0.3/go.mod h1:hAuDgiVgDVkfirP9JnhXEfcXEPRKBpYdGz+l7mvYSzw= 98 | github.com/cockroachdb/datadriven v0.0.0-20190809214429-80d97fb3cbaa/go.mod h1:zn76sxSg3SzpJ0PPJaLDCu+Bu0Lg3sKTORVIj19EIF8= 99 | github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd/go.mod h1:sE/e/2PUdi/liOCUjSTXgM1o87ZssimdTWN964YiIeI= 100 | github.com/containerd/containerd v1.4.0/go.mod h1:bC6axHOhabU15QhwfG7w5PipXdVtMXFTttgp+kVtyUA= 101 | github.com/containerd/containerd v1.4.1 h1:pASeJT3R3YyVn+94qEPk0SnU1OQ20Jd/T+SPKy9xehY= 102 | github.com/containerd/containerd v1.4.1/go.mod h1:bC6axHOhabU15QhwfG7w5PipXdVtMXFTttgp+kVtyUA= 103 | github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= 104 | github.com/coreos/go-systemd v0.0.0-20180511133405-39ca1b05acc7/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= 105 | github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= 106 | github.com/coreos/go-systemd v0.0.0-20190719114852-fd7a80b32e1f/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= 107 | github.com/coreos/pkg v0.0.0-20160727233714-3ac0863d7acf/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= 108 | github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d h1:U+s90UTSYgptZMwQh2aRr3LuazLJIa+Pg3Kc1ylSYVY= 109 | github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= 110 | github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY= 111 | github.com/cznic/mathutil v0.0.0-20180504122225-ca4c9f2c1369/go.mod h1:e6NPNENfs9mPDVNRekM7lKScauxd5kXTr1Mfyig6TDM= 112 | github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 113 | github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= 114 | github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 115 | github.com/decred/dcrd/chaincfg/chainhash v1.0.2/go.mod h1:BpbrGgrPTr3YJYRN3Bm+D9NuaFd+zGyNeIKgrhCXK60= 116 | github.com/decred/dcrd/crypto/blake256 v1.0.0/go.mod h1:sQl2p6Y26YV+ZOcSTP6thNdn47hh8kt6rqSlvmrXFAc= 117 | github.com/decred/dcrd/dcrec/secp256k1/v3 v3.0.0 h1:sgNeV1VRMDzs6rzyPpxyM0jp317hnwiq58Filgag2xw= 118 | github.com/decred/dcrd/dcrec/secp256k1/v3 v3.0.0/go.mod h1:J70FGZSbzsjecRTiTzER+3f1KZLNaXkuv+yeFTKoxM8= 119 | github.com/denisenkom/go-mssqldb v0.0.0-20191124224453-732737034ffd/go.mod h1:xbL0rPBG9cCiLr28tMa8zpbdarY27NDyej4t/EjAShU= 120 | github.com/denisenkom/go-mssqldb v0.0.0-20200620013148-b91950f658ec/go.mod h1:xbL0rPBG9cCiLr28tMa8zpbdarY27NDyej4t/EjAShU= 121 | github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= 122 | github.com/dgryski/trifles v0.0.0-20190318185328-a8d75aae118c h1:TUuUh0Xgj97tLMNtWtNvI9mIV6isjEb9lBMNv+77IGM= 123 | github.com/dgryski/trifles v0.0.0-20190318185328-a8d75aae118c/go.mod h1:if7Fbed8SFyPtHLHbg49SI7NAdJiC5WIA09pe59rfAA= 124 | github.com/dhui/dktest v0.3.3 h1:DBuH/9GFaWbDRa42qsut/hbQu+srAQ0rPWnUoiGX7CA= 125 | github.com/dhui/dktest v0.3.3/go.mod h1:EML9sP4sqJELHn4jV7B0TY8oF6077nk83/tz7M56jcQ= 126 | github.com/docker/distribution v2.7.1+incompatible h1:a5mlkVzth6W5A4fOsS3D2EO5BUmsJpcB+cRlLU7cSug= 127 | github.com/docker/distribution v2.7.1+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= 128 | github.com/docker/docker v17.12.0-ce-rc1.0.20200618181300-9dc6525e6118+incompatible h1:iWPIG7pWIsCwT6ZtHnTUpoVMnete7O/pzd9HFE3+tn8= 129 | github.com/docker/docker v17.12.0-ce-rc1.0.20200618181300-9dc6525e6118+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= 130 | github.com/docker/go-connections v0.4.0 h1:El9xVISelRB7BuFusrZozjnkIM5YnzCViNKohAFqRJQ= 131 | github.com/docker/go-connections v0.4.0/go.mod h1:Gbd7IOopHjR8Iph03tsViu4nIes5XhDvyHbTtUxmeec= 132 | github.com/docker/go-units v0.4.0 h1:3uh0PgVws3nIA0Q+MwDC8yjEPf9zjRfZZWXZYDct3Tw= 133 | github.com/docker/go-units v0.4.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= 134 | github.com/dustin/go-humanize v0.0.0-20171111073723-bb3d318650d4/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= 135 | github.com/eapache/go-resiliency v1.1.0/go.mod h1:kFI+JgMyC7bLPUVY133qvEBtVayf5mFgVsvEsIPBvNs= 136 | github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1:+020luEh2TKB4/GOp8oxxtq0Daoen/Cii55CzbTV6DU= 137 | github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I= 138 | github.com/edsrzf/mmap-go v0.0.0-20170320065105-0bce6a688712/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaBNrHW5M= 139 | github.com/edsrzf/mmap-go v1.0.0/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaBNrHW5M= 140 | github.com/envoyproxy/go-control-plane v0.6.9/go.mod h1:SBwIajubJHhxtWwsL9s8ss4safvEdbitLhGGK48rN6g= 141 | github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= 142 | github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= 143 | github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= 144 | github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= 145 | github.com/erikstmartin/go-testdb v0.0.0-20160219214506-8d10e4a1bae5/go.mod h1:a2zkGnVExMxdzMo3M0Hi/3sEU+cWnZpSni0O6/Yb/P0= 146 | github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= 147 | github.com/franela/goblin v0.0.0-20200105215937-c9ffbefa60db/go.mod h1:7dvUGVsVBjqR7JHJk0brhHOZYGmfBYOrK0ZhYMEtBr4= 148 | github.com/franela/goreq v0.0.0-20171204163338-bcd34c9993f8/go.mod h1:ZhphrRTfi2rbfLwlschooIH4+wKKDR4Pdxhh+TRoA20= 149 | github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= 150 | github.com/fsouza/fake-gcs-server v1.17.0/go.mod h1:D1rTE4YCyHFNa99oyJJ5HyclvN/0uQR+pM/VdlL83bw= 151 | github.com/georgysavva/scany v0.2.8 h1:rhLWqLvQM9RPh5CjM3eOOFe429uSHd6Bfvfeoo+UANc= 152 | github.com/georgysavva/scany v0.2.8/go.mod h1:guwpGaqxmVRdQK+th2eQxXKUwzd9bkCAWHfxx/MEaWU= 153 | github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= 154 | github.com/go-chi/chi v3.3.2+incompatible h1:uQNcQN3NsV1j4ANsPh42P4ew4t6rnRbJb8frvpp31qQ= 155 | github.com/go-chi/chi v3.3.2+incompatible/go.mod h1:eB3wogJHnLi3x/kFX2A+IbTBlXxmMeXJVKy9tTv1XzQ= 156 | github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= 157 | github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= 158 | github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= 159 | github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= 160 | github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= 161 | github.com/go-kit/kit v0.10.0/go.mod h1:xUsJbQ/Fp4kEt7AFgCuvyX4a71u8h9jB8tj/ORgOZ7o= 162 | github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= 163 | github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= 164 | github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A= 165 | github.com/go-sql-driver/mysql v1.4.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w= 166 | github.com/go-sql-driver/mysql v1.4.1/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w= 167 | github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= 168 | github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= 169 | github.com/gobuffalo/here v0.6.0/go.mod h1:wAG085dHOYqUpf+Ap+WOdrPTp5IYcDAs/x7PLa8Y5fM= 170 | github.com/goccy/go-json v0.4.8 h1:TfwOxfSp8hXH+ivoOk36RyDNmXATUETRdaNWDaZglf8= 171 | github.com/goccy/go-json v0.4.8/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= 172 | github.com/gocql/gocql v0.0.0-20190301043612-f6df8288f9b4/go.mod h1:4Fw1eo5iaEhDUs8XyuhSVCVy52Jq3L+/3GJgYkwc+/0= 173 | github.com/gofrs/uuid v3.2.0+incompatible h1:y12jRkkFxsd7GpqdSZ+/KCs/fJbqpEXSGd4+jfEaewE= 174 | github.com/gofrs/uuid v3.2.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM= 175 | github.com/gogo/googleapis v1.1.0/go.mod h1:gf4bu3Q80BeJ6H1S1vYPm8/ELATdvryBaNFGgqEef3s= 176 | github.com/gogo/protobuf v1.0.0/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= 177 | github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= 178 | github.com/gogo/protobuf v1.2.0/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= 179 | github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4= 180 | github.com/gogo/protobuf v1.3.1 h1:DqDEcV5aeaTmdFBePNpYsp3FlcVH/2ISVVM9Qf8PSls= 181 | github.com/gogo/protobuf v1.3.1/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o= 182 | github.com/golang-migrate/migrate/v4 v4.14.1 h1:qmRd/rNGjM1r3Ve5gHd5ZplytrD02UcItYNxJ3iUHHE= 183 | github.com/golang-migrate/migrate/v4 v4.14.1/go.mod h1:l7Ks0Au6fYHuUIxUhQ0rcVX1uLlJg54C/VvW7tvxSz0= 184 | github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe/go.mod h1:8vg3r2VgvsThLBIFL93Qb5yWzgyZWhEmBwUJWevAkK0= 185 | github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= 186 | github.com/golang/groupcache v0.0.0-20160516000752-02826c3e7903/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= 187 | github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= 188 | github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= 189 | github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= 190 | github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= 191 | github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= 192 | github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y= 193 | github.com/golang/mock v1.4.0/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= 194 | github.com/golang/mock v1.4.1/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= 195 | github.com/golang/mock v1.4.3/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= 196 | github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4= 197 | github.com/golang/protobuf v1.0.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= 198 | github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= 199 | github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= 200 | github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= 201 | github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= 202 | github.com/golang/protobuf v1.3.4/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= 203 | github.com/golang/protobuf v1.3.5/go.mod h1:6O5/vntMXwX2lRkT1hjjk0nAC1IDOTvTlVgjlRvqsdk= 204 | github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= 205 | github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= 206 | github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= 207 | github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= 208 | github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= 209 | github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= 210 | github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= 211 | github.com/golang/protobuf v1.4.3 h1:JjCZWpVbqXDqFVmTfYWEVTMIYrL/NPdPSCHPJ0T/raM= 212 | github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= 213 | github.com/golang/snappy v0.0.0-20170215233205-553a64147049/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= 214 | github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= 215 | github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= 216 | github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= 217 | github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= 218 | github.com/google/flatbuffers v1.11.0/go.mod h1:1AeVuKshWv4vARoZatz6mlQ0JxURH0Kv5+zNeJKJCa8= 219 | github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= 220 | github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= 221 | github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= 222 | github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= 223 | github.com/google/go-cmp v0.4.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= 224 | github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= 225 | github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= 226 | github.com/google/go-github v17.0.0+incompatible/go.mod h1:zLgOLi98H3fifZn+44m+umXrS52loVEgC2AApnigrVQ= 227 | github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck= 228 | github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= 229 | github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= 230 | github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= 231 | github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= 232 | github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= 233 | github.com/google/pprof v0.0.0-20191218002539-d4f498aebedc/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= 234 | github.com/google/pprof v0.0.0-20200212024743-f11f1df84d12/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= 235 | github.com/google/pprof v0.0.0-20200229191704-1ebb73c60ed3/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= 236 | github.com/google/pprof v0.0.0-20200430221834-fc25d7d30c6d/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= 237 | github.com/google/pprof v0.0.0-20200708004538-1a94d8640e99/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= 238 | github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= 239 | github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= 240 | github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= 241 | github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= 242 | github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= 243 | github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= 244 | github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= 245 | github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= 246 | github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= 247 | github.com/gorilla/context v0.0.0-20160226214623-1ea25387ff6f/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg= 248 | github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg= 249 | github.com/gorilla/handlers v1.4.2/go.mod h1:Qkdc/uu4tH4g6mTK6auzZ766c4CA0Ng8+o/OAirnOIQ= 250 | github.com/gorilla/mux v1.6.1/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= 251 | github.com/gorilla/mux v1.6.2/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= 252 | github.com/gorilla/mux v1.7.3/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= 253 | github.com/gorilla/mux v1.7.4/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So= 254 | github.com/gorilla/websocket v0.0.0-20170926233335-4201258b820c/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= 255 | github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc= 256 | github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= 257 | github.com/grpc-ecosystem/go-grpc-middleware v1.0.1-0.20190118093823-f849b5445de4/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= 258 | github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk= 259 | github.com/grpc-ecosystem/grpc-gateway v1.9.5/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= 260 | github.com/hailocab/go-hostpool v0.0.0-20160125115350-e80d13ce29ed/go.mod h1:tMWxXQ9wFIaZeTI9F+hmhFiGpFmhOHzyShyFUhRm0H4= 261 | github.com/hashicorp/consul/api v1.3.0/go.mod h1:MmDNSzIMUjNpY/mQ398R4bk2FnqQLoPndWW5VkKPlCE= 262 | github.com/hashicorp/consul/sdk v0.3.0/go.mod h1:VKf9jXwCTEY1QZP2MOLRhb5i/I/ssyNV1vwHyQBF0x8= 263 | github.com/hashicorp/errwrap v1.0.0 h1:hLrqtEDnRye3+sgx6z4qVLNuviH3MR5aQ0ykNJa/UYA= 264 | github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= 265 | github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= 266 | github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= 267 | github.com/hashicorp/go-msgpack v0.5.3/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM= 268 | github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk= 269 | github.com/hashicorp/go-multierror v1.1.0 h1:B9UzwGQJehnUY1yNrnwREHc3fGbC2xefo8g4TbElacI= 270 | github.com/hashicorp/go-multierror v1.1.0/go.mod h1:spPvp8C1qA32ftKqdAHm4hHTbPw+vmowP0z+KUhOZdA= 271 | github.com/hashicorp/go-rootcerts v1.0.0/go.mod h1:K6zTfqpRlCUIjkwsN4Z+hiSfzSTQa6eBIzfwKfwNnHU= 272 | github.com/hashicorp/go-sockaddr v1.0.0/go.mod h1:7Xibr9yA9JjQq1JpNB2Vw7kxv8xerXegt+ozgdvDeDU= 273 | github.com/hashicorp/go-syslog v1.0.0/go.mod h1:qPfqrKkXGihmCqbJM2mZgkZGvKG1dFdvsLplgctolz4= 274 | github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= 275 | github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= 276 | github.com/hashicorp/go-version v1.2.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= 277 | github.com/hashicorp/go.net v0.0.1/go.mod h1:hjKkEWcCURg++eb33jQU7oqQcI9XDCnUzHA0oac0k90= 278 | github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= 279 | github.com/hashicorp/golang-lru v0.5.1 h1:0hERBMJE1eitiLkihrMvRVBYAkpHzc/J3QdDN+dAcgU= 280 | github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= 281 | github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64= 282 | github.com/hashicorp/mdns v1.0.0/go.mod h1:tL+uN++7HEJ6SQLQ2/p+z2pH24WQKWjBPkE0mNTz8vQ= 283 | github.com/hashicorp/memberlist v0.1.3/go.mod h1:ajVTdAv/9Im8oMAAj5G31PhhMCZJV2pPBoIllUwCN7I= 284 | github.com/hashicorp/serf v0.8.2/go.mod h1:6hOLApaqBFA1NXqRQAsxw9QxuDEvNxSQRwA/JwenrHc= 285 | github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= 286 | github.com/hudl/fargo v1.3.0/go.mod h1:y3CKSmjA+wD2gak7sUSXTAoopbhU08POFhmITJgmKTg= 287 | github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= 288 | github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= 289 | github.com/influxdata/influxdb1-client v0.0.0-20191209144304-8bf82d3c094d/go.mod h1:qj24IKcXYK6Iy9ceXlo3Tc+vtHo9lIhSX5JddghvEPo= 290 | github.com/jackc/chunkreader v1.0.0 h1:4s39bBR8ByfqH+DKm8rQA3E1LHZWB9XWcrz8fqaZbe0= 291 | github.com/jackc/chunkreader v1.0.0/go.mod h1:RT6O25fNZIuasFJRyZ4R/Y2BbhasbmZXF9QQ7T3kePo= 292 | github.com/jackc/chunkreader/v2 v2.0.0/go.mod h1:odVSm741yZoC3dpHEUXIqA9tQRhFrgOHwnPIn9lDKlk= 293 | github.com/jackc/chunkreader/v2 v2.0.1 h1:i+RDz65UE+mmpjTfyz0MoVTnzeYxroil2G82ki7MGG8= 294 | github.com/jackc/chunkreader/v2 v2.0.1/go.mod h1:odVSm741yZoC3dpHEUXIqA9tQRhFrgOHwnPIn9lDKlk= 295 | github.com/jackc/pgconn v0.0.0-20190420214824-7e0022ef6ba3/go.mod h1:jkELnwuX+w9qN5YIfX0fl88Ehu4XC3keFuOJJk9pcnA= 296 | github.com/jackc/pgconn v0.0.0-20190824142844-760dd75542eb/go.mod h1:lLjNuW/+OfW9/pnVKPazfWOgNfH2aPem8YQ7ilXGvJE= 297 | github.com/jackc/pgconn v0.0.0-20190831204454-2fabfa3c18b7/go.mod h1:ZJKsE/KZfsUgOEh9hBm+xYTstcNHg7UPMVJqRfQxq4s= 298 | github.com/jackc/pgconn v1.3.2/go.mod h1:LvCquS3HbBKwgl7KbX9KyqEIumJAbm1UMcTvGaIf3bM= 299 | github.com/jackc/pgconn v1.4.0/go.mod h1:Y2O3ZDF0q4mMacyWV3AstPJpeHXWGEetiFttmq5lahk= 300 | github.com/jackc/pgconn v1.5.0/go.mod h1:QeD3lBfpTFe8WUnPZWN5KY/mB8FGMIYRdd8P8Jr0fAI= 301 | github.com/jackc/pgconn v1.5.1-0.20200601181101-fa742c524853/go.mod h1:QeD3lBfpTFe8WUnPZWN5KY/mB8FGMIYRdd8P8Jr0fAI= 302 | github.com/jackc/pgconn v1.6.4/go.mod h1:w2pne1C2tZgP+TvjqLpOigGzNqjBgQW9dUw/4Chex78= 303 | github.com/jackc/pgconn v1.7.0/go.mod h1:sF/lPpNEMEOp+IYhyQGdAvrG20gWf6A1tKlr0v7JMeA= 304 | github.com/jackc/pgconn v1.8.1 h1:ySBX7Q87vOMqKU2bbmKbUvtYhauDFclYbNDYIE1/h6s= 305 | github.com/jackc/pgconn v1.8.1/go.mod h1:JV6m6b6jhjdmzchES0drzCcYcAHS1OPD5xu3OZ/lE2g= 306 | github.com/jackc/pgio v1.0.0 h1:g12B9UwVnzGhueNavwioyEEpAmqMe1E/BN9ES+8ovkE= 307 | github.com/jackc/pgio v1.0.0/go.mod h1:oP+2QK2wFfUWgr+gxjoBH9KGBb31Eio69xUb0w5bYf8= 308 | github.com/jackc/pgmock v0.0.0-20190831213851-13a1b77aafa2 h1:JVX6jT/XfzNqIjye4717ITLaNwV9mWbJx0dLCpcRzdA= 309 | github.com/jackc/pgmock v0.0.0-20190831213851-13a1b77aafa2/go.mod h1:fGZlG77KXmcq05nJLRkk0+p82V8B8Dw8KN2/V9c/OAE= 310 | github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsIM= 311 | github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg= 312 | github.com/jackc/pgproto3 v1.1.0 h1:FYYE4yRw+AgI8wXIinMlNjBbp/UitDJwfj5LqqewP1A= 313 | github.com/jackc/pgproto3 v1.1.0/go.mod h1:eR5FA3leWg7p9aeAqi37XOTgTIbkABlvcPB3E5rlc78= 314 | github.com/jackc/pgproto3/v2 v2.0.0-alpha1.0.20190420180111-c116219b62db/go.mod h1:bhq50y+xrl9n5mRYyCBFKkpRVTLYJVWeCc+mEAI3yXA= 315 | github.com/jackc/pgproto3/v2 v2.0.0-alpha1.0.20190609003834-432c2951c711/go.mod h1:uH0AWtUmuShn0bcesswc4aBTWGvw0cAxIJp+6OB//Wg= 316 | github.com/jackc/pgproto3/v2 v2.0.0-rc3/go.mod h1:ryONWYqW6dqSg1Lw6vXNMXoBJhpzvWKnT95C46ckYeM= 317 | github.com/jackc/pgproto3/v2 v2.0.0-rc3.0.20190831210041-4c03ce451f29/go.mod h1:ryONWYqW6dqSg1Lw6vXNMXoBJhpzvWKnT95C46ckYeM= 318 | github.com/jackc/pgproto3/v2 v2.0.1/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA= 319 | github.com/jackc/pgproto3/v2 v2.0.2/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA= 320 | github.com/jackc/pgproto3/v2 v2.0.5/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA= 321 | github.com/jackc/pgproto3/v2 v2.0.6 h1:b1105ZGEMFe7aCvrT1Cca3VoVb4ZFMaFJLJcg/3zD+8= 322 | github.com/jackc/pgproto3/v2 v2.0.6/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA= 323 | github.com/jackc/pgservicefile v0.0.0-20200307190119-3430c5407db8/go.mod h1:vsD4gTJCa9TptPL8sPkXrLZ+hDuNrZCnj29CQpr4X1E= 324 | github.com/jackc/pgservicefile v0.0.0-20200714003250-2b9c44734f2b h1:C8S2+VttkHFdOOCXJe+YGfa4vHYwlt4Zx+IVXQ97jYg= 325 | github.com/jackc/pgservicefile v0.0.0-20200714003250-2b9c44734f2b/go.mod h1:vsD4gTJCa9TptPL8sPkXrLZ+hDuNrZCnj29CQpr4X1E= 326 | github.com/jackc/pgtype v0.0.0-20190421001408-4ed0de4755e0/go.mod h1:hdSHsc1V01CGwFsrv11mJRHWJ6aifDLfdV3aVjFF0zg= 327 | github.com/jackc/pgtype v0.0.0-20190824184912-ab885b375b90/go.mod h1:KcahbBH1nCMSo2DXpzsoWOAfFkdEtEJpPbVLq8eE+mc= 328 | github.com/jackc/pgtype v0.0.0-20190828014616-a8802b16cc59/go.mod h1:MWlu30kVJrUS8lot6TQqcg7mtthZ9T0EoIBFiJcmcyw= 329 | github.com/jackc/pgtype v1.2.0/go.mod h1:5m2OfMh1wTK7x+Fk952IDmI4nw3nPrvtQdM0ZT4WpC0= 330 | github.com/jackc/pgtype v1.3.0/go.mod h1:b0JqxHvPmljG+HQ5IsvQ0yqeSi4nGcDTVjFoiLDb0Ik= 331 | github.com/jackc/pgtype v1.3.1-0.20200510190516-8cd94a14c75a/go.mod h1:vaogEUkALtxZMCH411K+tKzNpwzCKU+AnPzBKZ+I+Po= 332 | github.com/jackc/pgtype v1.3.1-0.20200606141011-f6355165a91c/go.mod h1:cvk9Bgu/VzJ9/lxTO5R5sf80p0DiucVtN7ZxvaC4GmQ= 333 | github.com/jackc/pgtype v1.4.2/go.mod h1:JCULISAZBFGrHaOXIIFiyfzW5VY0GRitRr8NeJsrdig= 334 | github.com/jackc/pgtype v1.7.0 h1:6f4kVsW01QftE38ufBYxKciO6gyioXSC0ABIRLcZrGs= 335 | github.com/jackc/pgtype v1.7.0/go.mod h1:ZnHF+rMePVqDKaOfJVI4Q8IVvAQMryDlDkZnKOI75BE= 336 | github.com/jackc/pgx v3.6.2+incompatible h1:2zP5OD7kiyR3xzRYMhOcXVvkDZsImVXfj+yIyTQf3/o= 337 | github.com/jackc/pgx v3.6.2+incompatible/go.mod h1:0ZGrqGqkRlliWnWB4zKnWtjbSWbGkVEFm4TeybAXq+I= 338 | github.com/jackc/pgx/v4 v4.0.0-20190420224344-cc3461e65d96/go.mod h1:mdxmSJJuR08CZQyj1PVQBHy9XOp5p8/SHH6a0psbY9Y= 339 | github.com/jackc/pgx/v4 v4.0.0-20190421002000-1b8f0016e912/go.mod h1:no/Y67Jkk/9WuGR0JG/JseM9irFbnEPbuWV2EELPNuM= 340 | github.com/jackc/pgx/v4 v4.0.0-pre1.0.20190824185557-6972a5742186/go.mod h1:X+GQnOEnf1dqHGpw7JmHqHc1NxDoalibchSk9/RWuDc= 341 | github.com/jackc/pgx/v4 v4.5.0/go.mod h1:EpAKPLdnTorwmPUUsqrPxy5fphV18j9q3wrfRXgo+kA= 342 | github.com/jackc/pgx/v4 v4.6.0/go.mod h1:vPh43ZzxijXUVJ+t/EmXBtFmbFVO72cuneCT9oAlxAg= 343 | github.com/jackc/pgx/v4 v4.6.1-0.20200510190926-94ba730bb1e9/go.mod h1:t3/cdRQl6fOLDxqtlyhe9UWgfIi9R8+8v8GKV5TRA/o= 344 | github.com/jackc/pgx/v4 v4.6.1-0.20200606145419-4e5062306904/go.mod h1:ZDaNWkt9sW1JMiNn0kdYBaLelIhw7Pg4qd+Vk6tw7Hg= 345 | github.com/jackc/pgx/v4 v4.8.1/go.mod h1:4HOLxrl8wToZJReD04/yB20GDwf4KBYETvlHciCnwW0= 346 | github.com/jackc/pgx/v4 v4.11.0 h1:J86tSWd3Y7nKjwT/43xZBvpi04keQWx8gNC2YkdJhZI= 347 | github.com/jackc/pgx/v4 v4.11.0/go.mod h1:i62xJgdrtVDsnL3U8ekyrQXEwGNTRoG7/8r+CIdYfcc= 348 | github.com/jackc/puddle v0.0.0-20190413234325-e4ced69a3a2b/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk= 349 | github.com/jackc/puddle v0.0.0-20190608224051-11cab39313c9/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk= 350 | github.com/jackc/puddle v1.1.0/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk= 351 | github.com/jackc/puddle v1.1.1/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk= 352 | github.com/jackc/puddle v1.1.2/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk= 353 | github.com/jackc/puddle v1.1.3 h1:JnPg/5Q9xVJGfjsO5CPUOjnJps1JaRUm8I9FXVCFK94= 354 | github.com/jackc/puddle v1.1.3/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk= 355 | github.com/jinzhu/gorm v1.9.12/go.mod h1:vhTjlKSJUTWNtcbQtrMBFCxy7eXTzeCAzfL5fBZT/Qs= 356 | github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc= 357 | github.com/jinzhu/now v1.0.1/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8= 358 | github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= 359 | github.com/jmoiron/sqlx v1.2.0/go.mod h1:1FEQNm3xlJgrMD+FBdI9+xvCksHtbpVBBw5dYhBSsks= 360 | github.com/joho/godotenv v1.3.0 h1:Zjp+RcGpHhGlrMbJzXTrZZPrWj+1vfm90La1wgB6Bhc= 361 | github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg= 362 | github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo= 363 | github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= 364 | github.com/json-iterator/go v1.1.7/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= 365 | github.com/json-iterator/go v1.1.8/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= 366 | github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= 367 | github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= 368 | github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= 369 | github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= 370 | github.com/k0kubun/colorstring v0.0.0-20150214042306-9440f1994b88/go.mod h1:3w7q1U84EfirKl04SVQ/s7nPm1ZPhiXd34z40TNz36k= 371 | github.com/k0kubun/pp v2.3.0+incompatible/go.mod h1:GWse8YhT0p8pT4ir3ZgBbfZild3tgzSScAn6HmfYukg= 372 | github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0/go.mod h1:1NbS8ALrpOvjt0rHPNLyCIeMtbizbir8U//inJ+zuB8= 373 | github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q= 374 | github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00= 375 | github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= 376 | github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= 377 | github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= 378 | github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= 379 | github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= 380 | github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= 381 | github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= 382 | github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= 383 | github.com/kr/pty v1.1.8/go.mod h1:O1sed60cT9XZ5uDucP5qwvh+TE3NnUj51EiZO/lmSfw= 384 | github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= 385 | github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= 386 | github.com/ktrysmt/go-bitbucket v0.6.4/go.mod h1:9u0v3hsd2rqCHRIpbir1oP7F58uo5dq19sBYvuMoyQ4= 387 | github.com/lestrrat-go/backoff/v2 v2.0.7 h1:i2SeK33aOFJlUNJZzf2IpXRBvqBBnaGXfY5Xaop/GsE= 388 | github.com/lestrrat-go/backoff/v2 v2.0.7/go.mod h1:rHP/q/r9aT27n24JQLa7JhSQZCKBBOiM/uP402WwN8Y= 389 | github.com/lestrrat-go/blackmagic v1.0.0 h1:XzdxDbuQTz0RZZEmdU7cnQxUtFUzgCSPq8RCz4BxIi4= 390 | github.com/lestrrat-go/blackmagic v1.0.0/go.mod h1:TNgH//0vYSs8VXDCfkZLgIrVTTXQELZffUV0tz3MtdQ= 391 | github.com/lestrrat-go/codegen v1.0.0/go.mod h1:JhJw6OQAuPEfVKUCLItpaVLumDGWQznd1VaXrBk9TdM= 392 | github.com/lestrrat-go/httpcc v1.0.0 h1:FszVC6cKfDvBKcJv646+lkh4GydQg2Z29scgUfkOpYc= 393 | github.com/lestrrat-go/httpcc v1.0.0/go.mod h1:tGS/u00Vh5N6FHNkExqGGNId8e0Big+++0Gf8MBnAvE= 394 | github.com/lestrrat-go/iter v1.0.1 h1:q8faalr2dY6o8bV45uwrxq12bRa1ezKrB6oM9FUgN4A= 395 | github.com/lestrrat-go/iter v1.0.1/go.mod h1:zIdgO1mRKhn8l9vrZJZz9TUMMFbQbLeTsbqPDrJ/OJc= 396 | github.com/lestrrat-go/jwx v1.2.1 h1:WJ/3tiPUz1wV24KiwMEanbENwHnYub9UqzCbQ82mv9c= 397 | github.com/lestrrat-go/jwx v1.2.1/go.mod h1:Tg2uP7bpxEHUDtuWjap/PxroJ4okxGzkQznXiG+a5Dc= 398 | github.com/lestrrat-go/option v0.0.0-20210103042652-6f1ecfceda35/go.mod h1:5ZHFbivi4xwXxhxY9XHDe2FHo6/Z7WWmtT7T5nBBp3I= 399 | github.com/lestrrat-go/option v1.0.0 h1:WqAWL8kh8VcSoD6xjSH34/1m8yxluXQbDeKNfvFeEO4= 400 | github.com/lestrrat-go/option v1.0.0/go.mod h1:5ZHFbivi4xwXxhxY9XHDe2FHo6/Z7WWmtT7T5nBBp3I= 401 | github.com/lestrrat-go/pdebug/v3 v3.0.1 h1:3G5sX/aw/TbMTtVc9U7IHBWRZtMvwvBziF1e4HoQtv8= 402 | github.com/lestrrat-go/pdebug/v3 v3.0.1/go.mod h1:za+m+Ve24yCxTEhR59N7UlnJomWwCiIqbJRmKeiADU4= 403 | github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= 404 | github.com/lib/pq v1.1.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= 405 | github.com/lib/pq v1.1.1/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= 406 | github.com/lib/pq v1.2.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= 407 | github.com/lib/pq v1.3.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= 408 | github.com/lib/pq v1.4.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= 409 | github.com/lib/pq v1.8.0 h1:9xohqzkUwzR4Ga4ivdTcawVS89YSDVxXMa3xJX3cGzg= 410 | github.com/lib/pq v1.8.0/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= 411 | github.com/lightstep/lightstep-tracer-common/golang/gogo v0.0.0-20190605223551-bc2310a04743/go.mod h1:qklhhLq1aX+mtWk9cPHPzaBjWImj5ULL6C7HFJtXQMM= 412 | github.com/lightstep/lightstep-tracer-go v0.18.1/go.mod h1:jlF1pusYV4pidLvZ+XD0UBX0ZE6WURAspgAczcDHrL4= 413 | github.com/logrusorgru/aurora v0.0.0-20200102142835-e9ef32dff381/go.mod h1:7rIyQOR62GCctdiQpZ/zOJlFyk6y+94wXzv6RNZgaR4= 414 | github.com/lyft/protoc-gen-validate v0.0.13/go.mod h1:XbGvPuh87YZc5TdIa2/I4pLk0QoUACkjt2znoq26NVQ= 415 | github.com/markbates/pkger v0.15.1/go.mod h1:0JoVlrol20BSywW79rN3kdFFsE5xYM+rSCQDXbLhiuI= 416 | github.com/matryer/moq v0.0.0-20200106131100-75d0ddfc0007/go.mod h1:9ELz6aaclSIGnZBoaSLZ3NAl1VTufbOrXBPvtcy6WiQ= 417 | github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= 418 | github.com/mattn/go-colorable v0.1.1/go.mod h1:FuOcm+DKB9mbwrcAfNl7/TZVBZ6rcnceauSikq3lYCQ= 419 | github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= 420 | github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= 421 | github.com/mattn/go-colorable v0.1.6/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= 422 | github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= 423 | github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= 424 | github.com/mattn/go-isatty v0.0.5/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= 425 | github.com/mattn/go-isatty v0.0.7/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= 426 | github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= 427 | github.com/mattn/go-isatty v0.0.9/go.mod h1:YNRxwqDuOph6SZLI9vUUz6OYw3QyUt7WiY2yME+cCiQ= 428 | github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= 429 | github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= 430 | github.com/mattn/go-sqlite3 v1.9.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc= 431 | github.com/mattn/go-sqlite3 v1.10.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc= 432 | github.com/mattn/go-sqlite3 v2.0.1+incompatible/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc= 433 | github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= 434 | github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg= 435 | github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc= 436 | github.com/mitchellh/go-homedir v1.0.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= 437 | github.com/mitchellh/go-testing-interface v1.0.0/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI= 438 | github.com/mitchellh/gox v0.4.0/go.mod h1:Sd9lOJ0+aimLBi73mGofS1ycjY8lL3uZM3JPS42BGNg= 439 | github.com/mitchellh/iochan v1.0.0/go.mod h1:JwYml1nuB7xOzsp52dPpHFffvOCDupsG0QubkSMEySY= 440 | github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= 441 | github.com/mitchellh/mapstructure v0.0.0-20180203102830-a4e142e9c047/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= 442 | github.com/mitchellh/mapstructure v0.0.0-20180220230111-00c29f56e238/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= 443 | github.com/mitchellh/mapstructure v1.1.2 h1:fmNYVwqnSfB9mZU6OS2O6GsXM+wcskZDuKQzvN1EDeE= 444 | github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= 445 | github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= 446 | github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= 447 | github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= 448 | github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= 449 | github.com/morikuni/aec v1.0.0 h1:nP9CBfwrvYnBRgY6qfDQkygYDmYwOilePFkwzv4dU8A= 450 | github.com/morikuni/aec v1.0.0/go.mod h1:BbKIizmSmc5MMPqRYbxO4ZU0S0+P200+tUnFx7PXmsc= 451 | github.com/mutecomm/go-sqlcipher/v4 v4.4.0/go.mod h1:PyN04SaWalavxRGH9E8ZftG6Ju7rsPrGmQRjrEaVpiY= 452 | github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= 453 | github.com/nakagami/firebirdsql v0.0.0-20190310045651-3c02a58cfed8/go.mod h1:86wM1zFnC6/uDBfZGNwB65O+pR2OFi5q/YQaEUid1qA= 454 | github.com/nats-io/jwt v0.3.0/go.mod h1:fRYCDE99xlTsqUzISS1Bi75UBJ6ljOJQOAAu5VglpSg= 455 | github.com/nats-io/jwt v0.3.2/go.mod h1:/euKqTS1ZD+zzjYrY7pseZrTtWQSjujC7xjPc8wL6eU= 456 | github.com/nats-io/nats-server/v2 v2.1.2/go.mod h1:Afk+wRZqkMQs/p45uXdrVLuab3gwv3Z8C4HTBu8GD/k= 457 | github.com/nats-io/nats.go v1.9.1/go.mod h1:ZjDU1L/7fJ09jvUSRVBR2e7+RnLiiIQyqyzEE/Zbp4w= 458 | github.com/nats-io/nkeys v0.1.0/go.mod h1:xpnFELMwJABBLVhffcfd1MZx6VsNRFpEugbxziKVo7w= 459 | github.com/nats-io/nkeys v0.1.3/go.mod h1:xpnFELMwJABBLVhffcfd1MZx6VsNRFpEugbxziKVo7w= 460 | github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c= 461 | github.com/neo4j/neo4j-go-driver v1.8.1-0.20200803113522-b626aa943eba/go.mod h1:ncO5VaFWh0Nrt+4KT4mOZboaczBZcLuHrG+/sUeP8gI= 462 | github.com/oklog/oklog v0.3.2/go.mod h1:FCV+B7mhrz4o+ueLpx+KqkyXRGMWOYEvfiXtdGtbWGs= 463 | github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA= 464 | github.com/olekukonko/tablewriter v0.0.0-20170122224234-a0225b3f23b5/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo= 465 | github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= 466 | github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= 467 | github.com/onsi/ginkgo v1.12.0/go.mod h1:oUhWkIvk5aDxtKvDDuw8gItl8pKl42LzjC9KZE0HfGg= 468 | github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= 469 | github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= 470 | github.com/onsi/gomega v1.9.0/go.mod h1:Ho0h+IUsWyvy1OpqCwxlQ/21gkhVunqlU8fDGcoTdcA= 471 | github.com/op/go-logging v0.0.0-20160315200505-970db520ece7/go.mod h1:HzydrMdWErDVzsI23lYNej1Htcns9BCg93Dk0bBINWk= 472 | github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U= 473 | github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM= 474 | github.com/opencontainers/image-spec v1.0.1 h1:JMemWkRwHx4Zj+fVxWoMCFm/8sYGGrUVojFA6h/TRcI= 475 | github.com/opencontainers/image-spec v1.0.1/go.mod h1:BtxoFyWECRxE4U/7sNtV5W15zMzWCbyJoFRP3s7yZA0= 476 | github.com/opentracing-contrib/go-observer v0.0.0-20170622124052-a52f23424492/go.mod h1:Ngi6UdF0k5OKD5t5wlmGhe/EDKPoUM3BXZSSfIuJbis= 477 | github.com/opentracing/basictracer-go v1.0.0/go.mod h1:QfBfYuafItcjQuMwinw9GhYKwFXS9KnPs5lxoYwgW74= 478 | github.com/opentracing/opentracing-go v1.0.2/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= 479 | github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= 480 | github.com/openzipkin-contrib/zipkin-go-opentracing v0.4.5/go.mod h1:/wsWhb9smxSfWAKL3wpBW7V8scJMt8N8gnaMCS9E/cA= 481 | github.com/openzipkin/zipkin-go v0.1.6/go.mod h1:QgAqvLzwWbR/WpD4A3cGpPtJrZXNIiJc5AZX7/PBEpw= 482 | github.com/openzipkin/zipkin-go v0.2.1/go.mod h1:NaW6tEwdmWMaCDZzg8sh+IBNOxHMPnhQw8ySjnjRyN4= 483 | github.com/openzipkin/zipkin-go v0.2.2/go.mod h1:NaW6tEwdmWMaCDZzg8sh+IBNOxHMPnhQw8ySjnjRyN4= 484 | github.com/pact-foundation/pact-go v1.0.4/go.mod h1:uExwJY4kCzNPcHRj+hCR/HBbOOIwwtUjcrb0b5/5kLM= 485 | github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= 486 | github.com/pborman/uuid v1.2.0/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k= 487 | github.com/performancecopilot/speed v3.0.0+incompatible/go.mod h1:/CLtqpZ5gBg1M9iaPbIdPPGyKcA8hKdoy6hAWba7Yac= 488 | github.com/pierrec/lz4 v1.0.2-0.20190131084431-473cd7ce01a1/go.mod h1:3/3N9NVKO0jef7pBehbT1qWhCMrIgbYNnFAZCqQ5LRc= 489 | github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= 490 | github.com/pkg/browser v0.0.0-20180916011732-0a3d74bf9ce4/go.mod h1:4OwLy04Bl9Ef3GJJCoec+30X3LQs/0/m4HFRt/2LUSA= 491 | github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= 492 | github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= 493 | github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= 494 | github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= 495 | github.com/pkg/profile v1.2.1/go.mod h1:hJw3o1OdXxsrSjjVksARp5W95eeEaEfptyVZyv6JUPA= 496 | github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= 497 | github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= 498 | github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI= 499 | github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= 500 | github.com/prometheus/client_golang v0.9.3-0.20190127221311-3c4408c8b829/go.mod h1:p2iRAGwDERtqlqzRXnrOVns+ignqQo//hLXqYxZYVNs= 501 | github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo= 502 | github.com/prometheus/client_golang v1.3.0/go.mod h1:hJaj2vgQTGQmVCsAACORcieXFeDPbaTKGT+JTgUa3og= 503 | github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= 504 | github.com/prometheus/client_model v0.0.0-20190115171406-56726106282f/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= 505 | github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= 506 | github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= 507 | github.com/prometheus/client_model v0.1.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= 508 | github.com/prometheus/common v0.2.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= 509 | github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= 510 | github.com/prometheus/common v0.7.0/go.mod h1:DjGbpBbp5NYNiECxcL/VnbXCCaQpKd3tt26CguLLsqA= 511 | github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= 512 | github.com/prometheus/procfs v0.0.0-20190117184657-bf6a532e95b1/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= 513 | github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= 514 | github.com/prometheus/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+GxbHq6oeK9A= 515 | github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= 516 | github.com/remyoudompheng/bigfft v0.0.0-20190728182440-6a916e37a237/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo= 517 | github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= 518 | github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= 519 | github.com/rs/cors v1.6.0/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU= 520 | github.com/rs/xid v1.2.1/go.mod h1:+uKXf+4Djp6Md1KODXJxgGQPKngRmWyn10oCKFzNHOQ= 521 | github.com/rs/zerolog v1.13.0/go.mod h1:YbFCdg8HfsridGWAh22vktObvhZbQsZXe4/zB0OKkWU= 522 | github.com/rs/zerolog v1.15.0/go.mod h1:xYTKnLHcpfU2225ny5qZjxnj9NvkumZYjJHlAThCjNc= 523 | github.com/russross/blackfriday/v2 v2.0.1 h1:lPqVAte+HuHNfhJ/0LC98ESWRz8afy9tM/0RK8m9o+Q= 524 | github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= 525 | github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= 526 | github.com/samuel/go-zookeeper v0.0.0-20190923202752-2cc03de413da/go.mod h1:gi+0XIa01GRL2eRQVjQkKGqKF3SF9vZR/HnPullcV2E= 527 | github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0= 528 | github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= 529 | github.com/sergi/go-diff v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0= 530 | github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= 531 | github.com/shopspring/decimal v0.0.0-20180709203117-cd690d0c9e24/go.mod h1:M+9NzErvs504Cn4c5DxATwIqPbtswREoFCre64PpcG4= 532 | github.com/shopspring/decimal v0.0.0-20200227202807-02e2044944cc/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o= 533 | github.com/shopspring/decimal v0.0.0-20200419222939-1884f454f8ea h1:jaXWVFZ98/ihXniiDzqNXQgMSgklX4kjfDWZTE3ZtdU= 534 | github.com/shopspring/decimal v0.0.0-20200419222939-1884f454f8ea/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o= 535 | github.com/shurcooL/httpfs v0.0.0-20171119174359-809beceb2371/go.mod h1:ZY1cvUeJuFPAdZ/B6v7RHavJWZn2YPVFQ1OSXhCGOkg= 536 | github.com/shurcooL/sanitized_anchor_name v1.0.0 h1:PdmoCO6wvbs+7yrJyMORt4/BmY5IYyJwS/kOiWx8mHo= 537 | github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= 538 | github.com/shurcooL/vfsgen v0.0.0-20180121065927-ffb13db8def0/go.mod h1:TrYk7fJVaAttu97ZZKrO9UbRa8izdowaMIZcxYMbVaw= 539 | github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= 540 | github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q= 541 | github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= 542 | github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88= 543 | github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= 544 | github.com/sirupsen/logrus v1.8.1 h1:dJKuHgqk1NNQlqoA6BTlM1Wf9DOH3NBjQyu0h9+AZZE= 545 | github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= 546 | github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= 547 | github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= 548 | github.com/snowflakedb/glog v0.0.0-20180824191149-f5055e6f21ce/go.mod h1:EB/w24pR5VKI60ecFnKqXzxX3dOorz1rnVicQTQrGM0= 549 | github.com/snowflakedb/gosnowflake v1.3.5/go.mod h1:13Ky+lxzIm3VqNDZJdyvu9MCGy+WgRdYFdXp96UcLZU= 550 | github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM= 551 | github.com/sony/gobreaker v0.4.1/go.mod h1:ZKptC7FHNvhBz7dN2LGjPVBz2sZJmc0/PkyDJOjmxWY= 552 | github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ= 553 | github.com/spf13/pflag v1.0.1/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= 554 | github.com/streadway/amqp v0.0.0-20190404075320-75d898a42a94/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw= 555 | github.com/streadway/amqp v0.0.0-20190827072141-edfb9018d271/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw= 556 | github.com/streadway/handy v0.0.0-20190108123426-d5acb3125c2a/go.mod h1:qNTQ5P5JnDBl6z3cMAg/SywNDC5ABu5ApDIw6lUbRmI= 557 | github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= 558 | github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= 559 | github.com/stretchr/objx v0.2.0 h1:Hbg2NidpLE8veEBkEZTL3CvlkUIVzuU9jDplZO54c48= 560 | github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE= 561 | github.com/stretchr/testify v1.2.0/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= 562 | github.com/stretchr/testify v1.2.1/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= 563 | github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= 564 | github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= 565 | github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= 566 | github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= 567 | github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= 568 | github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= 569 | github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= 570 | github.com/tidwall/pretty v0.0.0-20180105212114-65a9db5fad51/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk= 571 | github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= 572 | github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA= 573 | github.com/urfave/cli v1.22.1 h1:+mkCCcOFKPnCmVYVcURKps1Xe+3zP90gSYGNfRkjoIY= 574 | github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= 575 | github.com/urfave/cli/v2 v2.1.1 h1:Qt8FeAtxE/vfdrLmR3rxR6JRE0RoVmbXu8+6kZtYU4k= 576 | github.com/urfave/cli/v2 v2.1.1/go.mod h1:SE9GqnLQmjVa0iPEY0f1w3ygNIYcIJ0OKPMoW2caLfQ= 577 | github.com/vektah/dataloaden v0.2.1-0.20190515034641-a19b9a6e7c9e/go.mod h1:/HUdMve7rvxZma+2ZELQeNh88+003LL7Pf/CZ089j8U= 578 | github.com/vektah/gqlparser/v2 v2.1.0 h1:uiKJ+T5HMGGQM2kRKQ8Pxw8+Zq9qhhZhz/lieYvCMns= 579 | github.com/vektah/gqlparser/v2 v2.1.0/go.mod h1:SyUiHgLATUR8BiYURfTirrTcGpcE+4XkV2se04Px1Ms= 580 | github.com/xanzy/go-gitlab v0.15.0/go.mod h1:8zdQa/ri1dfn8eS3Ir1SyfvOKlw7WBJ8DVThkpGiXrs= 581 | github.com/xdg/scram v0.0.0-20180814205039-7eeb5667e42c/go.mod h1:lB8K/P019DLNhemzwFU4jHLhdvlE6uDZjXFejJXr49I= 582 | github.com/xdg/stringprep v1.0.0/go.mod h1:Jhud4/sHMO4oL310DaZAKk9ZaJ08SJfe+sJh0HrGL1Y= 583 | github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= 584 | github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= 585 | github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= 586 | github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= 587 | github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= 588 | github.com/zenazn/goji v0.9.0/go.mod h1:7S9M489iMyHBNxwZnk9/EHS098H4/F6TATF2mIxtB1Q= 589 | gitlab.com/nyarla/go-crypt v0.0.0-20160106005555-d9a5dc2b789b/go.mod h1:T3BPAOm2cqquPa0MKWeNkmOM5RQsRhkrwMWonFMN7fE= 590 | go.etcd.io/bbolt v1.3.3/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= 591 | go.etcd.io/etcd v0.0.0-20191023171146-3cf2f69b5738/go.mod h1:dnLIgRNXwCJa5e+c6mIZCrds/GIG4ncV9HhK5PX7jPg= 592 | go.mongodb.org/mongo-driver v1.1.0/go.mod h1:u7ryQJ+DOzQmeO7zB6MHyr8jkEQvC8vH7qLUO4lqsUM= 593 | go.opencensus.io v0.20.1/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk= 594 | go.opencensus.io v0.20.2/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk= 595 | go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= 596 | go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= 597 | go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= 598 | go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= 599 | go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= 600 | go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= 601 | go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= 602 | go.uber.org/atomic v1.5.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= 603 | go.uber.org/atomic v1.6.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= 604 | go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= 605 | go.uber.org/multierr v1.3.0/go.mod h1:VgVr7evmIr6uPjLBxg28wmKNXyqE9akIJ5XnfpiKl+4= 606 | go.uber.org/multierr v1.5.0/go.mod h1:FeouvMocqHpRaaGuG9EjoKcStLC43Zu/fmqdUMPcKYU= 607 | go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee/go.mod h1:vJERXedbb3MVM5f9Ejo0C68/HhF8uaILCdgjnY+goOA= 608 | go.uber.org/zap v1.9.1/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= 609 | go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= 610 | go.uber.org/zap v1.13.0/go.mod h1:zwrFLgMcdUuIBviXEYEH1YKNaOBnKXsx2IPda5bBwHM= 611 | golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= 612 | golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= 613 | golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= 614 | golang.org/x/crypto v0.0.0-20190325154230-a5d413f7728c/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= 615 | golang.org/x/crypto v0.0.0-20190411191339-88737f569e3a/go.mod h1:WFFai1msRO1wXaEeE5yQxYXgSfI8pQAWXbQop6sCtWE= 616 | golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= 617 | golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= 618 | golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= 619 | golang.org/x/crypto v0.0.0-20190820162420-60c769a6c586/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= 620 | golang.org/x/crypto v0.0.0-20190911031432-227b76d455e7/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= 621 | golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= 622 | golang.org/x/crypto v0.0.0-20191205180655-e7c4368fe9dd/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= 623 | golang.org/x/crypto v0.0.0-20200323165209-0ec3e9974c59/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= 624 | golang.org/x/crypto v0.0.0-20200510223506-06a226fb4e37/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= 625 | golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= 626 | golang.org/x/crypto v0.0.0-20200709230013-948cd5f35899/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= 627 | golang.org/x/crypto v0.0.0-20201217014255-9d1352758620/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I= 628 | golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= 629 | golang.org/x/crypto v0.0.0-20210506145944-38f3c27a63bf h1:B2n+Zi5QeYRDAEodEu72OS36gmTWjgpXr2+cWcBW90o= 630 | golang.org/x/crypto v0.0.0-20210506145944-38f3c27a63bf/go.mod h1:P+XmwS30IXTQdn5tA2iutPOUgjI07+tq3H3K9MVA1s8= 631 | golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= 632 | golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= 633 | golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= 634 | golang.org/x/exp v0.0.0-20190829153037-c13cbed26979/go.mod h1:86+5VVa7VpoJ4kLfm080zCjGlMRFzhUhsZKEZO7MGek= 635 | golang.org/x/exp v0.0.0-20191030013958-a1ab85dbe136/go.mod h1:JXzH8nQsPlswgeRAPE3MuO9GYsAcnJvJ4vnMwN/5qkY= 636 | golang.org/x/exp v0.0.0-20191129062945-2f5052295587/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= 637 | golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= 638 | golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= 639 | golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM= 640 | golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= 641 | golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= 642 | golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= 643 | golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= 644 | golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= 645 | golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= 646 | golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= 647 | golang.org/x/lint v0.0.0-20190409202823-959b441ac422/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= 648 | golang.org/x/lint v0.0.0-20190909230951-414d861bb4ac/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= 649 | golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= 650 | golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f/go.mod h1:5qLYkcX4OjUUV8bRuDixDT3tpyyb+LUpUlRWLxfhWrs= 651 | golang.org/x/lint v0.0.0-20200130185559-910be7a94367/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= 652 | golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= 653 | golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE= 654 | golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o= 655 | golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= 656 | golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY= 657 | golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= 658 | golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= 659 | golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= 660 | golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= 661 | golang.org/x/mod v0.4.1 h1:Kvvh58BN8Y9/lBi7hTekvtMpm07eUZ0ck5pRHpsMWrY= 662 | golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= 663 | golang.org/x/net v0.0.0-20180218175443-cbe0f9307d01/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= 664 | golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= 665 | golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= 666 | golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= 667 | golang.org/x/net v0.0.0-20181023162649-9b4f9f5ad519/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= 668 | golang.org/x/net v0.0.0-20181108082009-03003ca0c849/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= 669 | golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= 670 | golang.org/x/net v0.0.0-20181201002055-351d144fa1fc/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= 671 | golang.org/x/net v0.0.0-20181220203305-927f97764cc3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= 672 | golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= 673 | golang.org/x/net v0.0.0-20190125091013-d26f9f9a57f3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= 674 | golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= 675 | golang.org/x/net v0.0.0-20190225153610-fe579d43d832/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= 676 | golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= 677 | golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= 678 | golang.org/x/net v0.0.0-20190501004415-9ce7a6920f09/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= 679 | golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= 680 | golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= 681 | golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= 682 | golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= 683 | golang.org/x/net v0.0.0-20190628185345-da137c7871d7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= 684 | golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= 685 | golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= 686 | golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= 687 | golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= 688 | golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= 689 | golang.org/x/net v0.0.0-20200222125558-5a598a2470a0/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= 690 | golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= 691 | golang.org/x/net v0.0.0-20200301022130-244492dfa37a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= 692 | golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= 693 | golang.org/x/net v0.0.0-20200501053045-e0ff5e5a1de5/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= 694 | golang.org/x/net v0.0.0-20200506145744-7e3656a0809f/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= 695 | golang.org/x/net v0.0.0-20200513185701-a91f0712d120/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= 696 | golang.org/x/net v0.0.0-20200520182314-0ba52f642ac2/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= 697 | golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= 698 | golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= 699 | golang.org/x/net v0.0.0-20200813134508-3edf25e44fcc/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= 700 | golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= 701 | golang.org/x/net v0.0.0-20200904194848-62affa334b73/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= 702 | golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= 703 | golang.org/x/net v0.0.0-20201029221708-28c70e62bb1d/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= 704 | golang.org/x/net v0.0.0-20210226172049-e18ecbb05110 h1:qWPm9rbaAMKs8Bq/9LRpbMqxWRVUAQwMI9fVrssnTfw= 705 | golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= 706 | golang.org/x/oauth2 v0.0.0-20180227000427-d7d64896b5ff/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= 707 | golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= 708 | golang.org/x/oauth2 v0.0.0-20181106182150-f42d05182288/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= 709 | golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= 710 | golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= 711 | golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= 712 | golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= 713 | golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 714 | golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 715 | golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 716 | golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 717 | golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 718 | golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 719 | golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 720 | golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 721 | golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 722 | golang.org/x/sys v0.0.0-20180224232135-f6cff0780e54/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 723 | golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 724 | golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 725 | golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 726 | golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 727 | golang.org/x/sys v0.0.0-20181026203630-95b1ffbd15a5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 728 | golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 729 | golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 730 | golang.org/x/sys v0.0.0-20181122145206-62eef0e2fa9b/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 731 | golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 732 | golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 733 | golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 734 | golang.org/x/sys v0.0.0-20190403152447-81d4e9dc473e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 735 | golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 736 | golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 737 | golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 738 | golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 739 | golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 740 | golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 741 | golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 742 | golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 743 | golang.org/x/sys v0.0.0-20190826190057-c7b8b68b1456/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 744 | golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 745 | golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 746 | golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 747 | golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 748 | golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 749 | golang.org/x/sys v0.0.0-20191220142924-d4481acd189f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 750 | golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 751 | golang.org/x/sys v0.0.0-20200113162924-86b910548bc1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 752 | golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 753 | golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 754 | golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 755 | golang.org/x/sys v0.0.0-20200212091648-12a6c2dcc1e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 756 | golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 757 | golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 758 | golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 759 | golang.org/x/sys v0.0.0-20200331124033-c3d80250170d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 760 | golang.org/x/sys v0.0.0-20200501052902-10377860bb8e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 761 | golang.org/x/sys v0.0.0-20200511232937-7e40ca221e25/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 762 | golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 763 | golang.org/x/sys v0.0.0-20200523222454-059865788121/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 764 | golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 765 | golang.org/x/sys v0.0.0-20200826173525-f9321e4c35a6/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 766 | golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 767 | golang.org/x/sys v0.0.0-20201029080932-201ba4db2418/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 768 | golang.org/x/sys v0.0.0-20201119102817-f84b799fce68 h1:nxC68pudNYkKU6jWhgrqdreuFiOQWj1Fs7T3VrH4Pjw= 769 | golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 770 | golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE= 771 | golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 772 | golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= 773 | golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= 774 | golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= 775 | golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= 776 | golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= 777 | golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= 778 | golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= 779 | golang.org/x/text v0.3.6 h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M= 780 | golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= 781 | golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= 782 | golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= 783 | golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= 784 | golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= 785 | golang.org/x/time v0.0.0-20200630173020-3af7569d3a1e/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= 786 | golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= 787 | golang.org/x/tools v0.0.0-20180828015842-6cd1fcedba52/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= 788 | golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= 789 | golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= 790 | golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= 791 | golang.org/x/tools v0.0.0-20190125232054-d66bd3c5d5a6/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= 792 | golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= 793 | golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= 794 | golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= 795 | golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= 796 | golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= 797 | golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= 798 | golang.org/x/tools v0.0.0-20190425163242-31fd60d6bfdc/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= 799 | golang.org/x/tools v0.0.0-20190506145303-2d16b83fe98c/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= 800 | golang.org/x/tools v0.0.0-20190515012406-7d7faa4812bd/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= 801 | golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= 802 | golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= 803 | golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= 804 | golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= 805 | golang.org/x/tools v0.0.0-20190816200558-6889da9d5479/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= 806 | golang.org/x/tools v0.0.0-20190823170909-c4a336ef6a2f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= 807 | golang.org/x/tools v0.0.0-20190911174233-4f2ddba30aff/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= 808 | golang.org/x/tools v0.0.0-20191012152004-8de300cfc20a/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= 809 | golang.org/x/tools v0.0.0-20191029041327-9cc4af7d6b2c/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= 810 | golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= 811 | golang.org/x/tools v0.0.0-20191113191852-77e3bb0ad9e7/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= 812 | golang.org/x/tools v0.0.0-20191115202509-3a792d9c32b2/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= 813 | golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= 814 | golang.org/x/tools v0.0.0-20191125144606-a911d9008d1f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= 815 | golang.org/x/tools v0.0.0-20191130070609-6e064ea0cf2d/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= 816 | golang.org/x/tools v0.0.0-20191216173652-a0e659d51361/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= 817 | golang.org/x/tools v0.0.0-20191227053925-7b8e75db28f4/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= 818 | golang.org/x/tools v0.0.0-20200103221440-774c71fcf114/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= 819 | golang.org/x/tools v0.0.0-20200114235610-7ae403b6b589/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= 820 | golang.org/x/tools v0.0.0-20200117161641-43d50277825c/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= 821 | golang.org/x/tools v0.0.0-20200122220014-bf1340f18c4a/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= 822 | golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= 823 | golang.org/x/tools v0.0.0-20200204074204-1cc6d1ef6c74/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= 824 | golang.org/x/tools v0.0.0-20200207183749-b753a1ba74fa/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= 825 | golang.org/x/tools v0.0.0-20200212150539-ea181f53ac56/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= 826 | golang.org/x/tools v0.0.0-20200224181240-023911ca70b2/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= 827 | golang.org/x/tools v0.0.0-20200227222343-706bc42d1f0d/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= 828 | golang.org/x/tools v0.0.0-20200304193943-95d2e580d8eb/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw= 829 | golang.org/x/tools v0.0.0-20200312045724-11d5b4c81c7d/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw= 830 | golang.org/x/tools v0.0.0-20200331025713-a30bf2db82d4/go.mod h1:Sl4aGygMT6LrqrWclx+PTx3U+LnKx/seiNR+3G19Ar8= 831 | golang.org/x/tools v0.0.0-20200501065659-ab2804fb9c9d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= 832 | golang.org/x/tools v0.0.0-20200512131952-2bc93b1c0c88/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= 833 | golang.org/x/tools v0.0.0-20200515010526-7d3b6ebf133d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= 834 | golang.org/x/tools v0.0.0-20200618134242-20370b0cb4b2/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= 835 | golang.org/x/tools v0.0.0-20200729194436-6467de6f59a7/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= 836 | golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= 837 | golang.org/x/tools v0.0.0-20200806022845-90696ccdc692/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= 838 | golang.org/x/tools v0.0.0-20200814230902-9882f1d1823d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= 839 | golang.org/x/tools v0.0.0-20200817023811-d00afeaade8f/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= 840 | golang.org/x/tools v0.0.0-20200818005847-188abfa75333/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= 841 | golang.org/x/tools v0.0.0-20200918232735-d647fc253266/go.mod h1:z6u4i615ZeAfBE4XtMziQW1fSVJXACjjbWkB/mvPzlU= 842 | golang.org/x/tools v0.0.0-20210114065538-d78b04bdf963 h1:K+NlvTLy0oONtRtkl1jRD9xIhnItbG2PiE7YOdjPb+k= 843 | golang.org/x/tools v0.0.0-20210114065538-d78b04bdf963/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= 844 | golang.org/x/xerrors v0.0.0-20190410155217-1f06c39b4373/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= 845 | golang.org/x/xerrors v0.0.0-20190513163551-3ee3066db522/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= 846 | golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= 847 | golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= 848 | golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= 849 | golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= 850 | golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= 851 | google.golang.org/api v0.3.1/go.mod h1:6wY9I6uQWHQ8EM57III9mq/AjF+i8G65rmVagqKMtkk= 852 | google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE= 853 | google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M= 854 | google.golang.org/api v0.8.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= 855 | google.golang.org/api v0.9.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= 856 | google.golang.org/api v0.13.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= 857 | google.golang.org/api v0.14.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= 858 | google.golang.org/api v0.15.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= 859 | google.golang.org/api v0.17.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= 860 | google.golang.org/api v0.18.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= 861 | google.golang.org/api v0.19.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= 862 | google.golang.org/api v0.20.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= 863 | google.golang.org/api v0.22.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= 864 | google.golang.org/api v0.24.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE= 865 | google.golang.org/api v0.28.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE= 866 | google.golang.org/api v0.29.0/go.mod h1:Lcubydp8VUV7KeIHD9z2Bys/sm/vGKnG1UHuDBSrHWM= 867 | google.golang.org/api v0.30.0/go.mod h1:QGmEvQ87FHZNiUVJkT14jQNYJ4ZJjdRF23ZXz5138Fc= 868 | google.golang.org/appengine v1.0.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= 869 | google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= 870 | google.golang.org/appengine v1.2.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= 871 | google.golang.org/appengine v1.3.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= 872 | google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= 873 | google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= 874 | google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0= 875 | google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= 876 | google.golang.org/appengine v1.6.6/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= 877 | google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= 878 | google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= 879 | google.golang.org/genproto v0.0.0-20190418145605-e7d98fc518a7/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= 880 | google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= 881 | google.golang.org/genproto v0.0.0-20190502173448-54afdca5d873/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= 882 | google.golang.org/genproto v0.0.0-20190530194941-fb225487d101/go.mod h1:z3L6/3dTEVtUr6QSP8miRzeRqwQOioJ9I66odjN4I7s= 883 | google.golang.org/genproto v0.0.0-20190801165951-fa694d86fc64/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= 884 | google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= 885 | google.golang.org/genproto v0.0.0-20190911173649-1774047e7e51/go.mod h1:IbNlFCBrqXvoKpeg0TB2l7cyZUmoaFKYIwrEpbDKLA8= 886 | google.golang.org/genproto v0.0.0-20191108220845-16a3f7862a1a/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= 887 | google.golang.org/genproto v0.0.0-20191115194625-c23dd37a84c9/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= 888 | google.golang.org/genproto v0.0.0-20191216164720-4f79533eabd1/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= 889 | google.golang.org/genproto v0.0.0-20191230161307-f3c370f40bfb/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= 890 | google.golang.org/genproto v0.0.0-20200115191322-ca5a22157cba/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= 891 | google.golang.org/genproto v0.0.0-20200122232147-0452cf42e150/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= 892 | google.golang.org/genproto v0.0.0-20200204135345-fa8e72b47b90/go.mod h1:GmwEX6Z4W5gMy59cAlVYjN9JhxgbQH6Gn+gFDQe2lzA= 893 | google.golang.org/genproto v0.0.0-20200212174721-66ed5ce911ce/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= 894 | google.golang.org/genproto v0.0.0-20200224152610-e50cd9704f63/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= 895 | google.golang.org/genproto v0.0.0-20200228133532-8c2c7df3a383/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= 896 | google.golang.org/genproto v0.0.0-20200305110556-506484158171/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= 897 | google.golang.org/genproto v0.0.0-20200312145019-da6875a35672/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= 898 | google.golang.org/genproto v0.0.0-20200331122359-1ee6d9798940/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= 899 | google.golang.org/genproto v0.0.0-20200430143042-b979b6f78d84/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= 900 | google.golang.org/genproto v0.0.0-20200511104702-f5ebc3bea380/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= 901 | google.golang.org/genproto v0.0.0-20200515170657-fc4c6c6a6587/go.mod h1:YsZOwe1myG/8QRHRsmBRE1LrgQY60beZKjly0O1fX9U= 902 | google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= 903 | google.golang.org/genproto v0.0.0-20200618031413-b414f8b61790/go.mod h1:jDfRM7FcilCzHH/e9qn6dsT145K34l5v+OpcnNgKAAA= 904 | google.golang.org/genproto v0.0.0-20200729003335-053ba62fc06f/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= 905 | google.golang.org/genproto v0.0.0-20200804131852-c06518451d9c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= 906 | google.golang.org/genproto v0.0.0-20200806141610-86f49bd18e98/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= 907 | google.golang.org/genproto v0.0.0-20200815001618-f69a88009b70/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= 908 | google.golang.org/genproto v0.0.0-20200911024640-645f7a48b24f/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= 909 | google.golang.org/genproto v0.0.0-20201030142918-24207fddd1c3 h1:sg8vLDNIxFPHTchfhH1E3AI32BL3f23oie38xUWnJM8= 910 | google.golang.org/genproto v0.0.0-20201030142918-24207fddd1c3/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= 911 | google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs= 912 | google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= 913 | google.golang.org/grpc v1.20.0/go.mod h1:chYK+tFQF0nDUGJgXMSgLCQk3phJEuONr2DCgLDdAQM= 914 | google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= 915 | google.golang.org/grpc v1.21.0/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= 916 | google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= 917 | google.golang.org/grpc v1.22.1/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= 918 | google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= 919 | google.golang.org/grpc v1.23.1/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= 920 | google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= 921 | google.golang.org/grpc v1.26.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= 922 | google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= 923 | google.golang.org/grpc v1.27.1/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= 924 | google.golang.org/grpc v1.28.0/go.mod h1:rpkK4SK4GF4Ach/+MFLZUBavHOvF2JJB5uozKKal+60= 925 | google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk= 926 | google.golang.org/grpc v1.30.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= 927 | google.golang.org/grpc v1.31.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= 928 | google.golang.org/grpc v1.32.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= 929 | google.golang.org/grpc v1.33.1 h1:DGeFlSan2f+WEtCERJ4J9GJWk15TxUi8QGagfI87Xyc= 930 | google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTpR3n0= 931 | google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= 932 | google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= 933 | google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= 934 | google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= 935 | google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= 936 | google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= 937 | google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= 938 | google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= 939 | google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGjtUeSXeh4= 940 | google.golang.org/protobuf v1.25.0 h1:Ejskq+SyPohKW+1uil0JJMtmHCgJPJ/qWTxr8qp+R4c= 941 | google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= 942 | gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= 943 | gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= 944 | gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= 945 | gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= 946 | gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= 947 | gopkg.in/cheggaaa/pb.v1 v1.0.25/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qStrOgw= 948 | gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= 949 | gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= 950 | gopkg.in/gcfg.v1 v1.2.3/go.mod h1:yesOnuUOFQAhST5vPY4nbZsb/huCgGGXlipJsBn0b3o= 951 | gopkg.in/inconshreveable/log15.v2 v2.0.0-20180818164646-67afb5ed74ec/go.mod h1:aPpfJ7XW+gOuirDoZ8gHhLh3kZ1B08FtV2bbmy7Jv3s= 952 | gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw= 953 | gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo= 954 | gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= 955 | gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI= 956 | gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74= 957 | gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= 958 | gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= 959 | gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= 960 | gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= 961 | gopkg.in/yaml.v2 v2.2.7/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= 962 | gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10= 963 | gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= 964 | gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= 965 | gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= 966 | gotest.tools v2.2.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81HFBacw= 967 | honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= 968 | honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= 969 | honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= 970 | honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= 971 | honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= 972 | honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= 973 | honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= 974 | honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= 975 | modernc.org/b v1.0.0/go.mod h1:uZWcZfRj1BpYzfN9JTerzlNUnnPsV9O2ZA8JsRcubNg= 976 | modernc.org/db v1.0.0/go.mod h1:kYD/cO29L/29RM0hXYl4i3+Q5VojL31kTUVpVJDw0s8= 977 | modernc.org/file v1.0.0/go.mod h1:uqEokAEn1u6e+J45e54dsEA/pw4o7zLrA2GwyntZzjw= 978 | modernc.org/fileutil v1.0.0/go.mod h1:JHsWpkrk/CnVV1H/eGlFf85BEpfkrp56ro8nojIq9Q8= 979 | modernc.org/golex v1.0.0/go.mod h1:b/QX9oBD/LhixY6NDh+IdGv17hgB+51fET1i2kPSmvk= 980 | modernc.org/internal v1.0.0/go.mod h1:VUD/+JAkhCpvkUitlEOnhpVxCgsBI90oTzSCRcqQVSM= 981 | modernc.org/lldb v1.0.0/go.mod h1:jcRvJGWfCGodDZz8BPwiKMJxGJngQ/5DrRapkQnLob8= 982 | modernc.org/mathutil v1.0.0/go.mod h1:wU0vUrJsVWBZ4P6e7xtFJEhFSNsfRLJ8H458uRjg03k= 983 | modernc.org/ql v1.0.0/go.mod h1:xGVyrLIatPcO2C1JvI/Co8c0sr6y91HKFNy4pt9JXEY= 984 | modernc.org/sortutil v1.1.0/go.mod h1:ZyL98OQHJgH9IEfN71VsamvJgrtRX9Dj2gX+vH86L1k= 985 | modernc.org/strutil v1.1.0/go.mod h1:lstksw84oURvj9y3tn8lGvRxyRC1S2+g5uuIzNfIOBs= 986 | modernc.org/zappy v1.0.0/go.mod h1:hHe+oGahLVII/aTTyWK/b53VDHMAGCBYYeZ9sn83HC4= 987 | rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= 988 | rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= 989 | rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= 990 | sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o= 991 | sourcegraph.com/sourcegraph/appdash v0.0.0-20180110180208-2cc67fd64755/go.mod h1:hI742Nqp5OhwiqlzhgfbWU4mW4yO10fP+LoT9WOswdU= 992 | sourcegraph.com/sourcegraph/appdash v0.0.0-20190731080439-ebfcffb1b5c0/go.mod h1:hI742Nqp5OhwiqlzhgfbWU4mW4yO10fP+LoT9WOswdU= 993 | sourcegraph.com/sourcegraph/appdash-data v0.0.0-20151005221446-73f23eafcf67/go.mod h1:L5q+DGLGOQFpo1snNEkLOJT2d1YTW66rWNzatr3He1k= 994 | -------------------------------------------------------------------------------- /graph/auth_resolver.go: -------------------------------------------------------------------------------- 1 | package graph 2 | 3 | import ( 4 | "context" 5 | "errors" 6 | 7 | "github.com/equimper/twitter" 8 | ) 9 | 10 | func mapAuthResponse(a twitter.AuthResponse) *AuthResponse { 11 | return &AuthResponse{ 12 | AccessToken: a.AccessToken, 13 | User: mapUser(a.User), 14 | } 15 | } 16 | 17 | func (m *mutationResolver) Register(ctx context.Context, input RegisterInput) (*AuthResponse, error) { 18 | res, err := m.AuthService.Register(ctx, twitter.RegisterInput{ 19 | Email: input.Email, 20 | Username: input.Username, 21 | Password: input.Password, 22 | ConfirmPassword: input.ConfirmPassword, 23 | }) 24 | if err != nil { 25 | switch { 26 | case errors.Is(err, twitter.ErrValidation) || 27 | errors.Is(err, twitter.ErrEmailTaken) || 28 | errors.Is(err, twitter.ErrUsernameTaken): 29 | return nil, buildBadRequestError(ctx, err) 30 | default: 31 | return nil, err 32 | } 33 | } 34 | 35 | return mapAuthResponse(res), nil 36 | } 37 | 38 | func (m *mutationResolver) Login(ctx context.Context, input LoginInput) (*AuthResponse, error) { 39 | res, err := m.AuthService.Login(ctx, twitter.LoginInput{ 40 | Email: input.Email, 41 | Password: input.Password, 42 | }) 43 | if err != nil { 44 | switch { 45 | case errors.Is(err, twitter.ErrValidation) || 46 | errors.Is(err, twitter.ErrBadCredentials): 47 | return nil, buildBadRequestError(ctx, err) 48 | default: 49 | return nil, err 50 | } 51 | } 52 | 53 | return mapAuthResponse(res), nil 54 | } 55 | -------------------------------------------------------------------------------- /graph/dataloaders.go: -------------------------------------------------------------------------------- 1 | //go:generate go run github.com/vektah/dataloaden UserLoader string *twitter/graph.User 2 | 3 | package graph 4 | 5 | import ( 6 | "context" 7 | "fmt" 8 | "net/http" 9 | "time" 10 | 11 | "github.com/equimper/twitter" 12 | ) 13 | 14 | const loadersKey = "dataloaders" 15 | 16 | type Loaders struct { 17 | UserByID UserLoader 18 | } 19 | 20 | type Repos struct { 21 | UserRepo twitter.UserRepo 22 | } 23 | 24 | func DataloaderMiddleware(repos *Repos) func(handler http.Handler) http.Handler { 25 | return func(next http.Handler) http.Handler { 26 | return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { 27 | ctx := context.WithValue(r.Context(), loadersKey, &Loaders{ 28 | UserByID: UserLoader{ 29 | wait: 1 * time.Millisecond, 30 | maxBatch: 100, 31 | fetch: func(ids []string) ([]*User, []error) { 32 | // []twitter.User 33 | users, err := repos.UserRepo.GetByIds(r.Context(), ids) 34 | if err != nil { 35 | return nil, []error{err} 36 | } 37 | 38 | userByID := map[string]*User{} 39 | 40 | for _, u := range users { 41 | userByID[u.ID] = mapUser(u) 42 | } 43 | 44 | result := make([]*User, len(ids)) 45 | 46 | for i, id := range ids { 47 | user, ok := userByID[id] 48 | if !ok { 49 | return nil, []error{fmt.Errorf("user with id: %s is missing", id)} 50 | } 51 | 52 | result[i] = user 53 | } 54 | 55 | return result, nil 56 | }, 57 | }, 58 | }) 59 | 60 | r = r.WithContext(ctx) 61 | 62 | next.ServeHTTP(w, r) 63 | }) 64 | } 65 | } 66 | 67 | func DataloaderFor(ctx context.Context) *Loaders { 68 | return ctx.Value(loadersKey).(*Loaders) 69 | } 70 | -------------------------------------------------------------------------------- /graph/gqlgen.yml: -------------------------------------------------------------------------------- 1 | skip_validation: true 2 | 3 | models: 4 | Tweet: 5 | fields: 6 | user: 7 | resolver: true 8 | replies: 9 | resolver: true 10 | -------------------------------------------------------------------------------- /graph/models_gen.go: -------------------------------------------------------------------------------- 1 | // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. 2 | 3 | package graph 4 | 5 | import ( 6 | "time" 7 | ) 8 | 9 | type AuthResponse struct { 10 | AccessToken string `json:"accessToken"` 11 | User *User `json:"user"` 12 | } 13 | 14 | type CreateTweetInput struct { 15 | Body string `json:"body"` 16 | } 17 | 18 | type LoginInput struct { 19 | Email string `json:"email"` 20 | Password string `json:"password"` 21 | } 22 | 23 | type RegisterInput struct { 24 | Email string `json:"email"` 25 | Username string `json:"username"` 26 | Password string `json:"password"` 27 | ConfirmPassword string `json:"confirmPassword"` 28 | } 29 | 30 | type Tweet struct { 31 | ID string `json:"id"` 32 | Body string `json:"body"` 33 | User *User `json:"user"` 34 | UserID string `json:"userId"` 35 | ParentID *string `json:"parentId"` 36 | Replies []*Tweet `json:"replies"` 37 | CreatedAt time.Time `json:"createdAt"` 38 | } 39 | 40 | type User struct { 41 | ID string `json:"id"` 42 | Username string `json:"username"` 43 | Email string `json:"email"` 44 | CreatedAt time.Time `json:"createdAt"` 45 | } 46 | -------------------------------------------------------------------------------- /graph/resolver.go: -------------------------------------------------------------------------------- 1 | package graph 2 | 3 | import ( 4 | "context" 5 | "errors" 6 | "net/http" 7 | 8 | "github.com/99designs/gqlgen/graphql" 9 | "github.com/equimper/twitter" 10 | "github.com/vektah/gqlparser/v2/gqlerror" 11 | ) 12 | 13 | //go:generate go run github.com/99designs/gqlgen 14 | 15 | type Resolver struct { 16 | AuthService twitter.AuthService 17 | TweetService twitter.TweetService 18 | UserService twitter.UserService 19 | } 20 | 21 | type queryResolver struct { 22 | *Resolver 23 | } 24 | 25 | func (r *Resolver) Query() QueryResolver { 26 | return &queryResolver{r} 27 | } 28 | 29 | type mutationResolver struct { 30 | *Resolver 31 | } 32 | 33 | func (r *Resolver) Mutation() MutationResolver { 34 | return &mutationResolver{r} 35 | } 36 | 37 | type tweetResolver struct { 38 | *Resolver 39 | } 40 | 41 | func (r *Resolver) Tweet() TweetResolver { 42 | return &tweetResolver{r} 43 | } 44 | 45 | func buildBadRequestError(ctx context.Context, err error) error { 46 | return &gqlerror.Error{ 47 | Message: err.Error(), 48 | Path: graphql.GetPath(ctx), 49 | Extensions: map[string]interface{}{ 50 | "code": http.StatusBadRequest, 51 | }, 52 | } 53 | } 54 | 55 | func buildUnauthenticatedError(ctx context.Context, err error) error { 56 | return &gqlerror.Error{ 57 | Message: err.Error(), 58 | Path: graphql.GetPath(ctx), 59 | Extensions: map[string]interface{}{ 60 | "code": http.StatusUnauthorized, 61 | }, 62 | } 63 | } 64 | 65 | func buildForbiddenError(ctx context.Context, err error) error { 66 | return &gqlerror.Error{ 67 | Message: err.Error(), 68 | Path: graphql.GetPath(ctx), 69 | Extensions: map[string]interface{}{ 70 | "code": http.StatusForbidden, 71 | }, 72 | } 73 | } 74 | 75 | func buildNotFoundError(ctx context.Context, err error) error { 76 | return &gqlerror.Error{ 77 | Message: err.Error(), 78 | Path: graphql.GetPath(ctx), 79 | Extensions: map[string]interface{}{ 80 | "code": http.StatusForbidden, 81 | }, 82 | } 83 | } 84 | 85 | func buildError(ctx context.Context, err error) error { 86 | switch { 87 | case errors.Is(err, twitter.ErrForbidden): 88 | return buildForbiddenError(ctx, err) 89 | case errors.Is(err, twitter.ErrUnauthenticated): 90 | return buildUnauthenticatedError(ctx, err) 91 | case errors.Is(err, twitter.ErrValidation): 92 | return buildBadRequestError(ctx, err) 93 | case errors.Is(err, twitter.ErrNotFound): 94 | return buildNotFoundError(ctx, err) 95 | default: 96 | return err 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /graph/schema.graphql: -------------------------------------------------------------------------------- 1 | scalar Time 2 | 3 | type User { 4 | id: ID! 5 | username: String! 6 | email: String! 7 | createdAt: Time! 8 | } 9 | 10 | type Tweet { 11 | id: ID! 12 | body: String! 13 | user: User! 14 | userId: ID! 15 | parentId: ID 16 | replies: [Tweet!]! 17 | createdAt: Time! 18 | } 19 | 20 | type AuthResponse { 21 | accessToken: String! 22 | user: User! 23 | } 24 | 25 | input RegisterInput { 26 | email: String! 27 | username: String! 28 | password: String! 29 | confirmPassword: String! 30 | } 31 | 32 | input LoginInput { 33 | email: String! 34 | password: String! 35 | } 36 | 37 | input CreateTweetInput { 38 | body: String! 39 | } 40 | 41 | type Query { 42 | me: User 43 | tweets: [Tweet!]! 44 | } 45 | 46 | type Mutation { 47 | register(input: RegisterInput!): AuthResponse! 48 | login(input: LoginInput!): AuthResponse! 49 | createTweet(input: CreateTweetInput!): Tweet! 50 | createReply(parentId: ID!, input: CreateTweetInput!): Tweet! 51 | deleteTweet(id: ID!): Boolean! 52 | } 53 | -------------------------------------------------------------------------------- /graph/tweet_resolver.go: -------------------------------------------------------------------------------- 1 | package graph 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/equimper/twitter" 7 | ) 8 | 9 | func mapTweet(t twitter.Tweet) *Tweet { 10 | return &Tweet{ 11 | ID: t.ID, 12 | Body: t.Body, 13 | UserID: t.UserID, 14 | CreatedAt: t.CreatedAt, 15 | } 16 | } 17 | 18 | func mapTweets(tweets []twitter.Tweet) []*Tweet { 19 | tt := make([]*Tweet, len(tweets)) 20 | 21 | for i, t := range tweets { 22 | tt[i] = mapTweet(t) 23 | } 24 | 25 | return tt 26 | } 27 | 28 | func (q *queryResolver) Tweets(ctx context.Context) ([]*Tweet, error) { 29 | tweets, err := q.TweetService.All(ctx) 30 | if err != nil { 31 | return nil, err 32 | } 33 | 34 | return mapTweets(tweets), nil 35 | } 36 | 37 | func (m *mutationResolver) CreateTweet(ctx context.Context, input CreateTweetInput) (*Tweet, error) { 38 | tweet, err := m.TweetService.Create(ctx, twitter.CreateTweetInput{ 39 | Body: input.Body, 40 | }) 41 | if err != nil { 42 | return nil, buildError(ctx, err) 43 | } 44 | 45 | return mapTweet(tweet), nil 46 | } 47 | 48 | func (m *mutationResolver) DeleteTweet(ctx context.Context, id string) (bool, error) { 49 | if err := m.TweetService.Delete(ctx, id); err != nil { 50 | return false, buildError(ctx, err) 51 | } 52 | 53 | return true, nil 54 | } 55 | 56 | func (t *tweetResolver) User(ctx context.Context, obj *Tweet) (*User, error) { 57 | return DataloaderFor(ctx).UserByID.Load(obj.UserID) 58 | } 59 | 60 | func (m *mutationResolver) CreateReply(ctx context.Context, parentID string, input CreateTweetInput) (*Tweet, error) { 61 | tweet, err := m.TweetService.CreateReply(ctx, parentID, twitter.CreateTweetInput{ 62 | Body: input.Body, 63 | }) 64 | if err != nil { 65 | return nil, buildError(ctx, err) 66 | } 67 | 68 | return mapTweet(tweet), nil 69 | } 70 | 71 | func (t *tweetResolver) Replies(ctx context.Context, obj *Tweet) ([]*Tweet, error) { 72 | tweets, err := t.TweetService.GetByParentID(ctx, obj.ID) 73 | if err != nil { 74 | return nil, buildError(ctx, err) 75 | } 76 | 77 | return mapTweets(tweets), nil 78 | } 79 | -------------------------------------------------------------------------------- /graph/user_resolver.go: -------------------------------------------------------------------------------- 1 | package graph 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/equimper/twitter" 7 | ) 8 | 9 | func mapUser(u twitter.User) *User { 10 | return &User{ 11 | ID: u.ID, 12 | Email: u.Email, 13 | Username: u.Username, 14 | CreatedAt: u.CreatedAt, 15 | } 16 | } 17 | 18 | func (q *queryResolver) Me(ctx context.Context) (*User, error) { 19 | userID, err := twitter.GetUserIDFromContext(ctx) 20 | if err != nil { 21 | return nil, twitter.ErrUnauthenticated 22 | } 23 | 24 | return mapUser(twitter.User{ 25 | ID: userID, 26 | }), nil 27 | } 28 | -------------------------------------------------------------------------------- /graph/userloader_gen.go: -------------------------------------------------------------------------------- 1 | // Code generated by github.com/vektah/dataloaden, DO NOT EDIT. 2 | 3 | package graph 4 | 5 | import ( 6 | "sync" 7 | "time" 8 | ) 9 | 10 | // UserLoaderConfig captures the config to create a new UserLoader 11 | type UserLoaderConfig struct { 12 | // Fetch is a method that provides the data for the loader 13 | Fetch func(keys []string) ([]*User, []error) 14 | 15 | // Wait is how long wait before sending a batch 16 | Wait time.Duration 17 | 18 | // MaxBatch will limit the maximum number of keys to send in one batch, 0 = not limit 19 | MaxBatch int 20 | } 21 | 22 | // NewUserLoader creates a new UserLoader given a fetch, wait, and maxBatch 23 | func NewUserLoader(config UserLoaderConfig) *UserLoader { 24 | return &UserLoader{ 25 | fetch: config.Fetch, 26 | wait: config.Wait, 27 | maxBatch: config.MaxBatch, 28 | } 29 | } 30 | 31 | // UserLoader batches and caches requests 32 | type UserLoader struct { 33 | // this method provides the data for the loader 34 | fetch func(keys []string) ([]*User, []error) 35 | 36 | // how long to done before sending a batch 37 | wait time.Duration 38 | 39 | // this will limit the maximum number of keys to send in one batch, 0 = no limit 40 | maxBatch int 41 | 42 | // INTERNAL 43 | 44 | // lazily created cache 45 | cache map[string]*User 46 | 47 | // the current batch. keys will continue to be collected until timeout is hit, 48 | // then everything will be sent to the fetch method and out to the listeners 49 | batch *userLoaderBatch 50 | 51 | // mutex to prevent races 52 | mu sync.Mutex 53 | } 54 | 55 | type userLoaderBatch struct { 56 | keys []string 57 | data []*User 58 | error []error 59 | closing bool 60 | done chan struct{} 61 | } 62 | 63 | // Load a User by key, batching and caching will be applied automatically 64 | func (l *UserLoader) Load(key string) (*User, error) { 65 | return l.LoadThunk(key)() 66 | } 67 | 68 | // LoadThunk returns a function that when called will block waiting for a User. 69 | // This method should be used if you want one goroutine to make requests to many 70 | // different data loaders without blocking until the thunk is called. 71 | func (l *UserLoader) LoadThunk(key string) func() (*User, error) { 72 | l.mu.Lock() 73 | if it, ok := l.cache[key]; ok { 74 | l.mu.Unlock() 75 | return func() (*User, error) { 76 | return it, nil 77 | } 78 | } 79 | if l.batch == nil { 80 | l.batch = &userLoaderBatch{done: make(chan struct{})} 81 | } 82 | batch := l.batch 83 | pos := batch.keyIndex(l, key) 84 | l.mu.Unlock() 85 | 86 | return func() (*User, error) { 87 | <-batch.done 88 | 89 | var data *User 90 | if pos < len(batch.data) { 91 | data = batch.data[pos] 92 | } 93 | 94 | var err error 95 | // its convenient to be able to return a single error for everything 96 | if len(batch.error) == 1 { 97 | err = batch.error[0] 98 | } else if batch.error != nil { 99 | err = batch.error[pos] 100 | } 101 | 102 | if err == nil { 103 | l.mu.Lock() 104 | l.unsafeSet(key, data) 105 | l.mu.Unlock() 106 | } 107 | 108 | return data, err 109 | } 110 | } 111 | 112 | // LoadAll fetches many keys at once. It will be broken into appropriate sized 113 | // sub batches depending on how the loader is configured 114 | func (l *UserLoader) LoadAll(keys []string) ([]*User, []error) { 115 | results := make([]func() (*User, error), len(keys)) 116 | 117 | for i, key := range keys { 118 | results[i] = l.LoadThunk(key) 119 | } 120 | 121 | users := make([]*User, len(keys)) 122 | errors := make([]error, len(keys)) 123 | for i, thunk := range results { 124 | users[i], errors[i] = thunk() 125 | } 126 | return users, errors 127 | } 128 | 129 | // LoadAllThunk returns a function that when called will block waiting for a Users. 130 | // This method should be used if you want one goroutine to make requests to many 131 | // different data loaders without blocking until the thunk is called. 132 | func (l *UserLoader) LoadAllThunk(keys []string) func() ([]*User, []error) { 133 | results := make([]func() (*User, error), len(keys)) 134 | for i, key := range keys { 135 | results[i] = l.LoadThunk(key) 136 | } 137 | return func() ([]*User, []error) { 138 | users := make([]*User, len(keys)) 139 | errors := make([]error, len(keys)) 140 | for i, thunk := range results { 141 | users[i], errors[i] = thunk() 142 | } 143 | return users, errors 144 | } 145 | } 146 | 147 | // Prime the cache with the provided key and value. If the key already exists, no change is made 148 | // and false is returned. 149 | // (To forcefully prime the cache, clear the key first with loader.clear(key).prime(key, value).) 150 | func (l *UserLoader) Prime(key string, value *User) bool { 151 | l.mu.Lock() 152 | var found bool 153 | if _, found = l.cache[key]; !found { 154 | // make a copy when writing to the cache, its easy to pass a pointer in from a loop var 155 | // and end up with the whole cache pointing to the same value. 156 | cpy := *value 157 | l.unsafeSet(key, &cpy) 158 | } 159 | l.mu.Unlock() 160 | return !found 161 | } 162 | 163 | // Clear the value at key from the cache, if it exists 164 | func (l *UserLoader) Clear(key string) { 165 | l.mu.Lock() 166 | delete(l.cache, key) 167 | l.mu.Unlock() 168 | } 169 | 170 | func (l *UserLoader) unsafeSet(key string, value *User) { 171 | if l.cache == nil { 172 | l.cache = map[string]*User{} 173 | } 174 | l.cache[key] = value 175 | } 176 | 177 | // keyIndex will return the location of the key in the batch, if its not found 178 | // it will add the key to the batch 179 | func (b *userLoaderBatch) keyIndex(l *UserLoader, key string) int { 180 | for i, existingKey := range b.keys { 181 | if key == existingKey { 182 | return i 183 | } 184 | } 185 | 186 | pos := len(b.keys) 187 | b.keys = append(b.keys, key) 188 | if pos == 0 { 189 | go b.startTimer(l) 190 | } 191 | 192 | if l.maxBatch != 0 && pos >= l.maxBatch-1 { 193 | if !b.closing { 194 | b.closing = true 195 | l.batch = nil 196 | go b.end(l) 197 | } 198 | } 199 | 200 | return pos 201 | } 202 | 203 | func (b *userLoaderBatch) startTimer(l *UserLoader) { 204 | time.Sleep(l.wait) 205 | l.mu.Lock() 206 | 207 | // we must have hit a batch limit and are already finalizing this batch 208 | if b.closing { 209 | l.mu.Unlock() 210 | return 211 | } 212 | 213 | l.batch = nil 214 | l.mu.Unlock() 215 | 216 | b.end(l) 217 | } 218 | 219 | func (b *userLoaderBatch) end(l *UserLoader) { 220 | b.data, b.error = l.fetch(b.keys) 221 | close(b.done) 222 | } 223 | -------------------------------------------------------------------------------- /jwt/jwt.go: -------------------------------------------------------------------------------- 1 | package jwt 2 | 3 | import ( 4 | "context" 5 | "fmt" 6 | "net/http" 7 | "time" 8 | 9 | "github.com/equimper/twitter" 10 | "github.com/equimper/twitter/config" 11 | "github.com/lestrrat-go/jwx/jwa" 12 | jwtGo "github.com/lestrrat-go/jwx/jwt" 13 | ) 14 | 15 | var signatureType = jwa.HS256 16 | 17 | var now = time.Now 18 | 19 | type TokenService struct { 20 | Conf *config.Config 21 | } 22 | 23 | func NewTokenService(conf *config.Config) *TokenService { 24 | return &TokenService{ 25 | Conf: conf, 26 | } 27 | } 28 | 29 | func (ts *TokenService) ParseTokenFromRequest(ctx context.Context, r *http.Request) (twitter.AuthToken, error) { 30 | token, err := jwtGo.ParseRequest( 31 | r, 32 | jwtGo.WithValidate(true), 33 | jwtGo.WithIssuer(ts.Conf.JWT.Issuer), 34 | jwtGo.WithVerify(signatureType, []byte(ts.Conf.JWT.Secret)), 35 | ) 36 | if err != nil { 37 | return twitter.AuthToken{}, twitter.ErrInvalidAccessToken 38 | } 39 | 40 | return buildToken(token), nil 41 | } 42 | 43 | func buildToken(token jwtGo.Token) twitter.AuthToken { 44 | return twitter.AuthToken{ 45 | ID: token.JwtID(), 46 | Sub: token.Subject(), 47 | } 48 | } 49 | 50 | func (ts *TokenService) ParseToken(ctx context.Context, payload string) (twitter.AuthToken, error) { 51 | token, err := jwtGo.Parse( 52 | []byte(payload), 53 | jwtGo.WithValidate(true), 54 | jwtGo.WithIssuer(ts.Conf.JWT.Issuer), 55 | jwtGo.WithVerify(signatureType, []byte(ts.Conf.JWT.Secret)), 56 | ) 57 | if err != nil { 58 | return twitter.AuthToken{}, twitter.ErrInvalidAccessToken 59 | } 60 | 61 | return buildToken(token), nil 62 | } 63 | 64 | func (ts *TokenService) CreateRefreshToken(ctx context.Context, user twitter.User, tokenID string) (string, error) { 65 | t := jwtGo.New() 66 | 67 | if err := setDefaultToken(t, user, twitter.RefreshTokenLifetime, ts.Conf); err != nil { 68 | return "", err 69 | } 70 | 71 | if err := t.Set(jwtGo.JwtIDKey, tokenID); err != nil { 72 | return "", fmt.Errorf("error set jwt id: %v", err) 73 | } 74 | 75 | token, err := jwtGo.Sign(t, signatureType, []byte(ts.Conf.JWT.Secret)) 76 | if err != nil { 77 | return "", fmt.Errorf("error sign jwt: %v", err) 78 | } 79 | 80 | return string(token), nil 81 | } 82 | 83 | func (ts *TokenService) CreateAccessToken(ctx context.Context, user twitter.User) (string, error) { 84 | t := jwtGo.New() 85 | 86 | if err := setDefaultToken(t, user, twitter.AccessTokenLifetime, ts.Conf); err != nil { 87 | return "", err 88 | } 89 | 90 | token, err := jwtGo.Sign(t, signatureType, []byte(ts.Conf.JWT.Secret)) 91 | if err != nil { 92 | return "", fmt.Errorf("error sign jwt: %v", err) 93 | } 94 | 95 | return string(token), nil 96 | } 97 | 98 | func setDefaultToken(t jwtGo.Token, user twitter.User, lifetime time.Duration, conf *config.Config) error { 99 | if err := t.Set(jwtGo.SubjectKey, user.ID); err != nil { 100 | return fmt.Errorf("error set jwt sub: %v", err) 101 | } 102 | 103 | if err := t.Set(jwtGo.IssuerKey, conf.JWT.Issuer); err != nil { 104 | return fmt.Errorf("error set jwt issuer key: %v", err) 105 | } 106 | 107 | if err := t.Set(jwtGo.IssuedAtKey, now().Unix()); err != nil { 108 | return fmt.Errorf("error set jwt issued at key: %v", err) 109 | } 110 | 111 | if err := t.Set(jwtGo.ExpirationKey, now().Add(lifetime).Unix()); err != nil { 112 | return fmt.Errorf("error set jwt expired at: %v", err) 113 | } 114 | 115 | return nil 116 | } 117 | -------------------------------------------------------------------------------- /jwt/jwt_test.go: -------------------------------------------------------------------------------- 1 | package jwt 2 | 3 | import ( 4 | "context" 5 | "fmt" 6 | "net/http/httptest" 7 | "os" 8 | "testing" 9 | "time" 10 | 11 | "github.com/equimper/twitter" 12 | "github.com/equimper/twitter/config" 13 | jwtGo "github.com/lestrrat-go/jwx/jwt" 14 | "github.com/stretchr/testify/require" 15 | ) 16 | 17 | var ( 18 | conf *config.Config 19 | tokenService *TokenService 20 | ) 21 | 22 | func TestMain(m *testing.M) { 23 | config.LoadEnv(".env.test") 24 | 25 | conf = config.New() 26 | 27 | tokenService = NewTokenService(conf) 28 | 29 | os.Exit(m.Run()) 30 | } 31 | 32 | func TestTokenService_CreateAccessToken(t *testing.T) { 33 | t.Run("can create a valid access token", func(t *testing.T) { 34 | ctx := context.Background() 35 | user := twitter.User{ 36 | ID: "123", 37 | } 38 | 39 | token, err := tokenService.CreateAccessToken(ctx, user) 40 | require.NoError(t, err) 41 | 42 | now = func() time.Time { 43 | return time.Now() 44 | } 45 | 46 | tok, err := jwtGo.Parse( 47 | []byte(token), 48 | jwtGo.WithValidate(true), 49 | jwtGo.WithVerify(signatureType, []byte(conf.JWT.Secret)), 50 | jwtGo.WithIssuer(conf.JWT.Issuer), 51 | ) 52 | require.NoError(t, err) 53 | 54 | require.Equal(t, "123", tok.Subject()) 55 | require.Equal(t, now().Add(twitter.AccessTokenLifetime).Unix(), tok.Expiration().Unix()) 56 | 57 | teardownTimeNow(t) 58 | }) 59 | } 60 | 61 | func TestTokenService_CreateRefreshToken(t *testing.T) { 62 | t.Run("can create a valid refresh token", func(t *testing.T) { 63 | ctx := context.Background() 64 | user := twitter.User{ 65 | ID: "123", 66 | } 67 | 68 | token, err := tokenService.CreateRefreshToken(ctx, user, "456") 69 | require.NoError(t, err) 70 | 71 | now = func() time.Time { 72 | return time.Now() 73 | } 74 | 75 | tok, err := jwtGo.Parse( 76 | []byte(token), 77 | jwtGo.WithValidate(true), 78 | jwtGo.WithVerify(signatureType, []byte(conf.JWT.Secret)), 79 | jwtGo.WithIssuer(conf.JWT.Issuer), 80 | ) 81 | require.NoError(t, err) 82 | 83 | require.Equal(t, "123", tok.Subject()) 84 | require.Equal(t, "456", tok.JwtID()) 85 | require.Equal(t, now().Add(twitter.RefreshTokenLifetime).Unix(), tok.Expiration().Unix()) 86 | 87 | teardownTimeNow(t) 88 | }) 89 | } 90 | 91 | func TestTokenService_ParseToken(t *testing.T) { 92 | t.Run("can parse a valid access token", func(t *testing.T) { 93 | ctx := context.Background() 94 | user := twitter.User{ 95 | ID: "123", 96 | } 97 | 98 | token, err := tokenService.CreateAccessToken(ctx, user) 99 | require.NoError(t, err) 100 | 101 | tok, err := tokenService.ParseToken(ctx, token) 102 | require.NoError(t, err) 103 | require.Equal(t, "123", tok.Sub) 104 | }) 105 | 106 | t.Run("can parse a valid refresh token", func(t *testing.T) { 107 | ctx := context.Background() 108 | user := twitter.User{ 109 | ID: "123", 110 | } 111 | 112 | token, err := tokenService.CreateRefreshToken(ctx, user, "456") 113 | require.NoError(t, err) 114 | 115 | tok, err := tokenService.ParseToken(ctx, token) 116 | require.NoError(t, err) 117 | require.Equal(t, "123", tok.Sub) 118 | require.Equal(t, "456", tok.ID) 119 | }) 120 | 121 | t.Run("return err if invalid access token", func(t *testing.T) { 122 | ctx := context.Background() 123 | 124 | _, err := tokenService.ParseToken(ctx, "invalid token") 125 | require.ErrorIs(t, err, twitter.ErrInvalidAccessToken) 126 | }) 127 | 128 | t.Run("return err if access token expired", func(t *testing.T) { 129 | ctx := context.Background() 130 | user := twitter.User{ 131 | ID: "123", 132 | } 133 | 134 | now = func() time.Time { 135 | return time.Now().Add(-twitter.AccessTokenLifetime * 5) 136 | } 137 | 138 | token, err := tokenService.CreateAccessToken(ctx, user) 139 | require.NoError(t, err) 140 | 141 | _, err = tokenService.ParseToken(ctx, token) 142 | require.ErrorIs(t, err, twitter.ErrInvalidAccessToken) 143 | 144 | teardownTimeNow(t) 145 | }) 146 | } 147 | 148 | func TestTokenService_ParseTokenFromRequest(t *testing.T) { 149 | t.Run("can parse an access token from the request", func(t *testing.T) { 150 | ctx := context.Background() 151 | user := twitter.User{ 152 | ID: "123", 153 | } 154 | 155 | req := httptest.NewRequest("GET", "/", nil) 156 | 157 | accessToken, err := tokenService.CreateAccessToken(ctx, user) 158 | require.NoError(t, err) 159 | 160 | req.Header.Set("Authorization", accessToken) 161 | 162 | token, err := tokenService.ParseTokenFromRequest(ctx, req) 163 | require.NoError(t, err) 164 | 165 | require.Equal(t, "123", token.Sub) 166 | 167 | req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", accessToken)) 168 | 169 | token, err = tokenService.ParseTokenFromRequest(ctx, req) 170 | require.NoError(t, err) 171 | 172 | require.Equal(t, "123", token.Sub) 173 | }) 174 | 175 | t.Run("expired token will fail", func(t *testing.T) { 176 | ctx := context.Background() 177 | user := twitter.User{ 178 | ID: "123", 179 | } 180 | 181 | req := httptest.NewRequest("GET", "/", nil) 182 | 183 | now = func() time.Time { 184 | return time.Now().Add(-twitter.AccessTokenLifetime * 5) 185 | } 186 | 187 | accessToken, err := tokenService.CreateAccessToken(ctx, user) 188 | require.NoError(t, err) 189 | 190 | req.Header.Set("Authorization", accessToken) 191 | 192 | _, err = tokenService.ParseTokenFromRequest(ctx, req) 193 | require.ErrorIs(t, err, twitter.ErrInvalidAccessToken) 194 | 195 | teardownTimeNow(t) 196 | }) 197 | 198 | t.Run("expired token will fail", func(t *testing.T) { 199 | ctx := context.Background() 200 | 201 | req := httptest.NewRequest("GET", "/", nil) 202 | 203 | req.Header.Set("Authorization", "invalid token") 204 | 205 | _, err := tokenService.ParseTokenFromRequest(ctx, req) 206 | require.ErrorIs(t, err, twitter.ErrInvalidAccessToken) 207 | }) 208 | } 209 | 210 | func teardownTimeNow(t *testing.T) { 211 | t.Helper() 212 | 213 | now = func() time.Time { 214 | return time.Now() 215 | } 216 | } 217 | -------------------------------------------------------------------------------- /mocks/AuthService.go: -------------------------------------------------------------------------------- 1 | // Code generated by mockery 2.9.0. DO NOT EDIT. 2 | 3 | package mocks 4 | 5 | import ( 6 | context "context" 7 | 8 | twitter "github.com/equimper/twitter" 9 | mock "github.com/stretchr/testify/mock" 10 | ) 11 | 12 | // AuthService is an autogenerated mock type for the AuthService type 13 | type AuthService struct { 14 | mock.Mock 15 | } 16 | 17 | // Login provides a mock function with given fields: ctx, input 18 | func (_m *AuthService) Login(ctx context.Context, input twitter.LoginInput) (twitter.AuthResponse, error) { 19 | ret := _m.Called(ctx, input) 20 | 21 | var r0 twitter.AuthResponse 22 | if rf, ok := ret.Get(0).(func(context.Context, twitter.LoginInput) twitter.AuthResponse); ok { 23 | r0 = rf(ctx, input) 24 | } else { 25 | r0 = ret.Get(0).(twitter.AuthResponse) 26 | } 27 | 28 | var r1 error 29 | if rf, ok := ret.Get(1).(func(context.Context, twitter.LoginInput) error); ok { 30 | r1 = rf(ctx, input) 31 | } else { 32 | r1 = ret.Error(1) 33 | } 34 | 35 | return r0, r1 36 | } 37 | 38 | // Register provides a mock function with given fields: ctx, input 39 | func (_m *AuthService) Register(ctx context.Context, input twitter.RegisterInput) (twitter.AuthResponse, error) { 40 | ret := _m.Called(ctx, input) 41 | 42 | var r0 twitter.AuthResponse 43 | if rf, ok := ret.Get(0).(func(context.Context, twitter.RegisterInput) twitter.AuthResponse); ok { 44 | r0 = rf(ctx, input) 45 | } else { 46 | r0 = ret.Get(0).(twitter.AuthResponse) 47 | } 48 | 49 | var r1 error 50 | if rf, ok := ret.Get(1).(func(context.Context, twitter.RegisterInput) error); ok { 51 | r1 = rf(ctx, input) 52 | } else { 53 | r1 = ret.Error(1) 54 | } 55 | 56 | return r0, r1 57 | } 58 | -------------------------------------------------------------------------------- /mocks/AuthTokenService.go: -------------------------------------------------------------------------------- 1 | // Code generated by mockery 2.9.0. DO NOT EDIT. 2 | 3 | package mocks 4 | 5 | import ( 6 | context "context" 7 | http "net/http" 8 | 9 | mock "github.com/stretchr/testify/mock" 10 | 11 | twitter "github.com/equimper/twitter" 12 | ) 13 | 14 | // AuthTokenService is an autogenerated mock type for the AuthTokenService type 15 | type AuthTokenService struct { 16 | mock.Mock 17 | } 18 | 19 | // CreateAccessToken provides a mock function with given fields: ctx, user 20 | func (_m *AuthTokenService) CreateAccessToken(ctx context.Context, user twitter.User) (string, error) { 21 | ret := _m.Called(ctx, user) 22 | 23 | var r0 string 24 | if rf, ok := ret.Get(0).(func(context.Context, twitter.User) string); ok { 25 | r0 = rf(ctx, user) 26 | } else { 27 | r0 = ret.Get(0).(string) 28 | } 29 | 30 | var r1 error 31 | if rf, ok := ret.Get(1).(func(context.Context, twitter.User) error); ok { 32 | r1 = rf(ctx, user) 33 | } else { 34 | r1 = ret.Error(1) 35 | } 36 | 37 | return r0, r1 38 | } 39 | 40 | // CreateRefreshToken provides a mock function with given fields: ctx, user, tokenID 41 | func (_m *AuthTokenService) CreateRefreshToken(ctx context.Context, user twitter.User, tokenID string) (string, error) { 42 | ret := _m.Called(ctx, user, tokenID) 43 | 44 | var r0 string 45 | if rf, ok := ret.Get(0).(func(context.Context, twitter.User, string) string); ok { 46 | r0 = rf(ctx, user, tokenID) 47 | } else { 48 | r0 = ret.Get(0).(string) 49 | } 50 | 51 | var r1 error 52 | if rf, ok := ret.Get(1).(func(context.Context, twitter.User, string) error); ok { 53 | r1 = rf(ctx, user, tokenID) 54 | } else { 55 | r1 = ret.Error(1) 56 | } 57 | 58 | return r0, r1 59 | } 60 | 61 | // ParseToken provides a mock function with given fields: ctx, payload 62 | func (_m *AuthTokenService) ParseToken(ctx context.Context, payload string) (twitter.AuthToken, error) { 63 | ret := _m.Called(ctx, payload) 64 | 65 | var r0 twitter.AuthToken 66 | if rf, ok := ret.Get(0).(func(context.Context, string) twitter.AuthToken); ok { 67 | r0 = rf(ctx, payload) 68 | } else { 69 | r0 = ret.Get(0).(twitter.AuthToken) 70 | } 71 | 72 | var r1 error 73 | if rf, ok := ret.Get(1).(func(context.Context, string) error); ok { 74 | r1 = rf(ctx, payload) 75 | } else { 76 | r1 = ret.Error(1) 77 | } 78 | 79 | return r0, r1 80 | } 81 | 82 | // ParseTokenFromRequest provides a mock function with given fields: ctx, r 83 | func (_m *AuthTokenService) ParseTokenFromRequest(ctx context.Context, r *http.Request) (twitter.AuthToken, error) { 84 | ret := _m.Called(ctx, r) 85 | 86 | var r0 twitter.AuthToken 87 | if rf, ok := ret.Get(0).(func(context.Context, *http.Request) twitter.AuthToken); ok { 88 | r0 = rf(ctx, r) 89 | } else { 90 | r0 = ret.Get(0).(twitter.AuthToken) 91 | } 92 | 93 | var r1 error 94 | if rf, ok := ret.Get(1).(func(context.Context, *http.Request) error); ok { 95 | r1 = rf(ctx, r) 96 | } else { 97 | r1 = ret.Error(1) 98 | } 99 | 100 | return r0, r1 101 | } 102 | -------------------------------------------------------------------------------- /mocks/RefreshTokenRepo.go: -------------------------------------------------------------------------------- 1 | // Code generated by mockery 2.9.0. DO NOT EDIT. 2 | 3 | package mocks 4 | 5 | import ( 6 | context "context" 7 | 8 | twitter "github.com/equimper/twitter" 9 | mock "github.com/stretchr/testify/mock" 10 | ) 11 | 12 | // RefreshTokenRepo is an autogenerated mock type for the RefreshTokenRepo type 13 | type RefreshTokenRepo struct { 14 | mock.Mock 15 | } 16 | 17 | // Create provides a mock function with given fields: ctx, params 18 | func (_m *RefreshTokenRepo) Create(ctx context.Context, params twitter.CreateRefreshTokenParams) (twitter.RefreshToken, error) { 19 | ret := _m.Called(ctx, params) 20 | 21 | var r0 twitter.RefreshToken 22 | if rf, ok := ret.Get(0).(func(context.Context, twitter.CreateRefreshTokenParams) twitter.RefreshToken); ok { 23 | r0 = rf(ctx, params) 24 | } else { 25 | r0 = ret.Get(0).(twitter.RefreshToken) 26 | } 27 | 28 | var r1 error 29 | if rf, ok := ret.Get(1).(func(context.Context, twitter.CreateRefreshTokenParams) error); ok { 30 | r1 = rf(ctx, params) 31 | } else { 32 | r1 = ret.Error(1) 33 | } 34 | 35 | return r0, r1 36 | } 37 | 38 | // GetByID provides a mock function with given fields: ctx, id 39 | func (_m *RefreshTokenRepo) GetByID(ctx context.Context, id string) (twitter.RefreshToken, error) { 40 | ret := _m.Called(ctx, id) 41 | 42 | var r0 twitter.RefreshToken 43 | if rf, ok := ret.Get(0).(func(context.Context, string) twitter.RefreshToken); ok { 44 | r0 = rf(ctx, id) 45 | } else { 46 | r0 = ret.Get(0).(twitter.RefreshToken) 47 | } 48 | 49 | var r1 error 50 | if rf, ok := ret.Get(1).(func(context.Context, string) error); ok { 51 | r1 = rf(ctx, id) 52 | } else { 53 | r1 = ret.Error(1) 54 | } 55 | 56 | return r0, r1 57 | } 58 | -------------------------------------------------------------------------------- /mocks/TweetRepo.go: -------------------------------------------------------------------------------- 1 | // Code generated by mockery 2.9.0. DO NOT EDIT. 2 | 3 | package mocks 4 | 5 | import ( 6 | context "context" 7 | 8 | twitter "github.com/equimper/twitter" 9 | mock "github.com/stretchr/testify/mock" 10 | ) 11 | 12 | // TweetRepo is an autogenerated mock type for the TweetRepo type 13 | type TweetRepo struct { 14 | mock.Mock 15 | } 16 | 17 | // All provides a mock function with given fields: ctx 18 | func (_m *TweetRepo) All(ctx context.Context) ([]twitter.Tweet, error) { 19 | ret := _m.Called(ctx) 20 | 21 | var r0 []twitter.Tweet 22 | if rf, ok := ret.Get(0).(func(context.Context) []twitter.Tweet); ok { 23 | r0 = rf(ctx) 24 | } else { 25 | if ret.Get(0) != nil { 26 | r0 = ret.Get(0).([]twitter.Tweet) 27 | } 28 | } 29 | 30 | var r1 error 31 | if rf, ok := ret.Get(1).(func(context.Context) error); ok { 32 | r1 = rf(ctx) 33 | } else { 34 | r1 = ret.Error(1) 35 | } 36 | 37 | return r0, r1 38 | } 39 | 40 | // Create provides a mock function with given fields: ctx, tweet 41 | func (_m *TweetRepo) Create(ctx context.Context, tweet twitter.Tweet) (twitter.Tweet, error) { 42 | ret := _m.Called(ctx, tweet) 43 | 44 | var r0 twitter.Tweet 45 | if rf, ok := ret.Get(0).(func(context.Context, twitter.Tweet) twitter.Tweet); ok { 46 | r0 = rf(ctx, tweet) 47 | } else { 48 | r0 = ret.Get(0).(twitter.Tweet) 49 | } 50 | 51 | var r1 error 52 | if rf, ok := ret.Get(1).(func(context.Context, twitter.Tweet) error); ok { 53 | r1 = rf(ctx, tweet) 54 | } else { 55 | r1 = ret.Error(1) 56 | } 57 | 58 | return r0, r1 59 | } 60 | 61 | // Delete provides a mock function with given fields: ctx, id 62 | func (_m *TweetRepo) Delete(ctx context.Context, id string) error { 63 | ret := _m.Called(ctx, id) 64 | 65 | var r0 error 66 | if rf, ok := ret.Get(0).(func(context.Context, string) error); ok { 67 | r0 = rf(ctx, id) 68 | } else { 69 | r0 = ret.Error(0) 70 | } 71 | 72 | return r0 73 | } 74 | 75 | // GetByID provides a mock function with given fields: ctx, id 76 | func (_m *TweetRepo) GetByID(ctx context.Context, id string) (twitter.Tweet, error) { 77 | ret := _m.Called(ctx, id) 78 | 79 | var r0 twitter.Tweet 80 | if rf, ok := ret.Get(0).(func(context.Context, string) twitter.Tweet); ok { 81 | r0 = rf(ctx, id) 82 | } else { 83 | r0 = ret.Get(0).(twitter.Tweet) 84 | } 85 | 86 | var r1 error 87 | if rf, ok := ret.Get(1).(func(context.Context, string) error); ok { 88 | r1 = rf(ctx, id) 89 | } else { 90 | r1 = ret.Error(1) 91 | } 92 | 93 | return r0, r1 94 | } 95 | -------------------------------------------------------------------------------- /mocks/TweetService.go: -------------------------------------------------------------------------------- 1 | // Code generated by mockery 2.9.0. DO NOT EDIT. 2 | 3 | package mocks 4 | 5 | import ( 6 | context "context" 7 | 8 | twitter "github.com/equimper/twitter" 9 | mock "github.com/stretchr/testify/mock" 10 | ) 11 | 12 | // TweetService is an autogenerated mock type for the TweetService type 13 | type TweetService struct { 14 | mock.Mock 15 | } 16 | 17 | // All provides a mock function with given fields: ctx 18 | func (_m *TweetService) All(ctx context.Context) ([]twitter.Tweet, error) { 19 | ret := _m.Called(ctx) 20 | 21 | var r0 []twitter.Tweet 22 | if rf, ok := ret.Get(0).(func(context.Context) []twitter.Tweet); ok { 23 | r0 = rf(ctx) 24 | } else { 25 | if ret.Get(0) != nil { 26 | r0 = ret.Get(0).([]twitter.Tweet) 27 | } 28 | } 29 | 30 | var r1 error 31 | if rf, ok := ret.Get(1).(func(context.Context) error); ok { 32 | r1 = rf(ctx) 33 | } else { 34 | r1 = ret.Error(1) 35 | } 36 | 37 | return r0, r1 38 | } 39 | 40 | // Create provides a mock function with given fields: ctx, input 41 | func (_m *TweetService) Create(ctx context.Context, input twitter.CreateTweetInput) (twitter.Tweet, error) { 42 | ret := _m.Called(ctx, input) 43 | 44 | var r0 twitter.Tweet 45 | if rf, ok := ret.Get(0).(func(context.Context, twitter.CreateTweetInput) twitter.Tweet); ok { 46 | r0 = rf(ctx, input) 47 | } else { 48 | r0 = ret.Get(0).(twitter.Tweet) 49 | } 50 | 51 | var r1 error 52 | if rf, ok := ret.Get(1).(func(context.Context, twitter.CreateTweetInput) error); ok { 53 | r1 = rf(ctx, input) 54 | } else { 55 | r1 = ret.Error(1) 56 | } 57 | 58 | return r0, r1 59 | } 60 | 61 | // CreateReply provides a mock function with given fields: ctx, parentID, input 62 | func (_m *TweetService) CreateReply(ctx context.Context, parentID string, input twitter.CreateTweetInput) (twitter.Tweet, error) { 63 | ret := _m.Called(ctx, parentID, input) 64 | 65 | var r0 twitter.Tweet 66 | if rf, ok := ret.Get(0).(func(context.Context, string, twitter.CreateTweetInput) twitter.Tweet); ok { 67 | r0 = rf(ctx, parentID, input) 68 | } else { 69 | r0 = ret.Get(0).(twitter.Tweet) 70 | } 71 | 72 | var r1 error 73 | if rf, ok := ret.Get(1).(func(context.Context, string, twitter.CreateTweetInput) error); ok { 74 | r1 = rf(ctx, parentID, input) 75 | } else { 76 | r1 = ret.Error(1) 77 | } 78 | 79 | return r0, r1 80 | } 81 | 82 | // Delete provides a mock function with given fields: ctx, id 83 | func (_m *TweetService) Delete(ctx context.Context, id string) error { 84 | ret := _m.Called(ctx, id) 85 | 86 | var r0 error 87 | if rf, ok := ret.Get(0).(func(context.Context, string) error); ok { 88 | r0 = rf(ctx, id) 89 | } else { 90 | r0 = ret.Error(0) 91 | } 92 | 93 | return r0 94 | } 95 | 96 | // GetByID provides a mock function with given fields: ctx, id 97 | func (_m *TweetService) GetByID(ctx context.Context, id string) (twitter.Tweet, error) { 98 | ret := _m.Called(ctx, id) 99 | 100 | var r0 twitter.Tweet 101 | if rf, ok := ret.Get(0).(func(context.Context, string) twitter.Tweet); ok { 102 | r0 = rf(ctx, id) 103 | } else { 104 | r0 = ret.Get(0).(twitter.Tweet) 105 | } 106 | 107 | var r1 error 108 | if rf, ok := ret.Get(1).(func(context.Context, string) error); ok { 109 | r1 = rf(ctx, id) 110 | } else { 111 | r1 = ret.Error(1) 112 | } 113 | 114 | return r0, r1 115 | } 116 | -------------------------------------------------------------------------------- /mocks/UserRepo.go: -------------------------------------------------------------------------------- 1 | // Code generated by mockery 2.9.0. DO NOT EDIT. 2 | 3 | package mocks 4 | 5 | import ( 6 | context "context" 7 | 8 | twitter "github.com/equimper/twitter" 9 | mock "github.com/stretchr/testify/mock" 10 | ) 11 | 12 | // UserRepo is an autogenerated mock type for the UserRepo type 13 | type UserRepo struct { 14 | mock.Mock 15 | } 16 | 17 | // Create provides a mock function with given fields: ctx, user 18 | func (_m *UserRepo) Create(ctx context.Context, user twitter.User) (twitter.User, error) { 19 | ret := _m.Called(ctx, user) 20 | 21 | var r0 twitter.User 22 | if rf, ok := ret.Get(0).(func(context.Context, twitter.User) twitter.User); ok { 23 | r0 = rf(ctx, user) 24 | } else { 25 | r0 = ret.Get(0).(twitter.User) 26 | } 27 | 28 | var r1 error 29 | if rf, ok := ret.Get(1).(func(context.Context, twitter.User) error); ok { 30 | r1 = rf(ctx, user) 31 | } else { 32 | r1 = ret.Error(1) 33 | } 34 | 35 | return r0, r1 36 | } 37 | 38 | // GetByEmail provides a mock function with given fields: ctx, email 39 | func (_m *UserRepo) GetByEmail(ctx context.Context, email string) (twitter.User, error) { 40 | ret := _m.Called(ctx, email) 41 | 42 | var r0 twitter.User 43 | if rf, ok := ret.Get(0).(func(context.Context, string) twitter.User); ok { 44 | r0 = rf(ctx, email) 45 | } else { 46 | r0 = ret.Get(0).(twitter.User) 47 | } 48 | 49 | var r1 error 50 | if rf, ok := ret.Get(1).(func(context.Context, string) error); ok { 51 | r1 = rf(ctx, email) 52 | } else { 53 | r1 = ret.Error(1) 54 | } 55 | 56 | return r0, r1 57 | } 58 | 59 | // GetByID provides a mock function with given fields: ctx, id 60 | func (_m *UserRepo) GetByID(ctx context.Context, id string) (twitter.User, error) { 61 | ret := _m.Called(ctx, id) 62 | 63 | var r0 twitter.User 64 | if rf, ok := ret.Get(0).(func(context.Context, string) twitter.User); ok { 65 | r0 = rf(ctx, id) 66 | } else { 67 | r0 = ret.Get(0).(twitter.User) 68 | } 69 | 70 | var r1 error 71 | if rf, ok := ret.Get(1).(func(context.Context, string) error); ok { 72 | r1 = rf(ctx, id) 73 | } else { 74 | r1 = ret.Error(1) 75 | } 76 | 77 | return r0, r1 78 | } 79 | 80 | // GetByIds provides a mock function with given fields: ctx, ids 81 | func (_m *UserRepo) GetByIds(ctx context.Context, ids []string) ([]twitter.User, error) { 82 | ret := _m.Called(ctx, ids) 83 | 84 | var r0 []twitter.User 85 | if rf, ok := ret.Get(0).(func(context.Context, []string) []twitter.User); ok { 86 | r0 = rf(ctx, ids) 87 | } else { 88 | if ret.Get(0) != nil { 89 | r0 = ret.Get(0).([]twitter.User) 90 | } 91 | } 92 | 93 | var r1 error 94 | if rf, ok := ret.Get(1).(func(context.Context, []string) error); ok { 95 | r1 = rf(ctx, ids) 96 | } else { 97 | r1 = ret.Error(1) 98 | } 99 | 100 | return r0, r1 101 | } 102 | 103 | // GetByUsername provides a mock function with given fields: ctx, username 104 | func (_m *UserRepo) GetByUsername(ctx context.Context, username string) (twitter.User, error) { 105 | ret := _m.Called(ctx, username) 106 | 107 | var r0 twitter.User 108 | if rf, ok := ret.Get(0).(func(context.Context, string) twitter.User); ok { 109 | r0 = rf(ctx, username) 110 | } else { 111 | r0 = ret.Get(0).(twitter.User) 112 | } 113 | 114 | var r1 error 115 | if rf, ok := ret.Get(1).(func(context.Context, string) error); ok { 116 | r1 = rf(ctx, username) 117 | } else { 118 | r1 = ret.Error(1) 119 | } 120 | 121 | return r0, r1 122 | } 123 | -------------------------------------------------------------------------------- /mocks/UserService.go: -------------------------------------------------------------------------------- 1 | // Code generated by mockery 2.9.0. DO NOT EDIT. 2 | 3 | package mocks 4 | 5 | import ( 6 | context "context" 7 | 8 | twitter "github.com/equimper/twitter" 9 | mock "github.com/stretchr/testify/mock" 10 | ) 11 | 12 | // UserService is an autogenerated mock type for the UserService type 13 | type UserService struct { 14 | mock.Mock 15 | } 16 | 17 | // GetByID provides a mock function with given fields: ctx, id 18 | func (_m *UserService) GetByID(ctx context.Context, id string) (twitter.User, error) { 19 | ret := _m.Called(ctx, id) 20 | 21 | var r0 twitter.User 22 | if rf, ok := ret.Get(0).(func(context.Context, string) twitter.User); ok { 23 | r0 = rf(ctx, id) 24 | } else { 25 | r0 = ret.Get(0).(twitter.User) 26 | } 27 | 28 | var r1 error 29 | if rf, ok := ret.Get(1).(func(context.Context, string) error); ok { 30 | r1 = rf(ctx, id) 31 | } else { 32 | r1 = ret.Error(1) 33 | } 34 | 35 | return r0, r1 36 | } 37 | -------------------------------------------------------------------------------- /mocks/graph/MutationResolver.go: -------------------------------------------------------------------------------- 1 | // Code generated by mockery 2.9.0. DO NOT EDIT. 2 | 3 | package mocks 4 | 5 | import ( 6 | context "context" 7 | 8 | graph "github.com/equimper/twitter/graph" 9 | mock "github.com/stretchr/testify/mock" 10 | ) 11 | 12 | // MutationResolver is an autogenerated mock type for the MutationResolver type 13 | type MutationResolver struct { 14 | mock.Mock 15 | } 16 | 17 | // CreateReply provides a mock function with given fields: ctx, parentID, input 18 | func (_m *MutationResolver) CreateReply(ctx context.Context, parentID string, input graph.CreateTweetInput) (*graph.Tweet, error) { 19 | ret := _m.Called(ctx, parentID, input) 20 | 21 | var r0 *graph.Tweet 22 | if rf, ok := ret.Get(0).(func(context.Context, string, graph.CreateTweetInput) *graph.Tweet); ok { 23 | r0 = rf(ctx, parentID, input) 24 | } else { 25 | if ret.Get(0) != nil { 26 | r0 = ret.Get(0).(*graph.Tweet) 27 | } 28 | } 29 | 30 | var r1 error 31 | if rf, ok := ret.Get(1).(func(context.Context, string, graph.CreateTweetInput) error); ok { 32 | r1 = rf(ctx, parentID, input) 33 | } else { 34 | r1 = ret.Error(1) 35 | } 36 | 37 | return r0, r1 38 | } 39 | 40 | // CreateTweet provides a mock function with given fields: ctx, input 41 | func (_m *MutationResolver) CreateTweet(ctx context.Context, input graph.CreateTweetInput) (*graph.Tweet, error) { 42 | ret := _m.Called(ctx, input) 43 | 44 | var r0 *graph.Tweet 45 | if rf, ok := ret.Get(0).(func(context.Context, graph.CreateTweetInput) *graph.Tweet); ok { 46 | r0 = rf(ctx, input) 47 | } else { 48 | if ret.Get(0) != nil { 49 | r0 = ret.Get(0).(*graph.Tweet) 50 | } 51 | } 52 | 53 | var r1 error 54 | if rf, ok := ret.Get(1).(func(context.Context, graph.CreateTweetInput) error); ok { 55 | r1 = rf(ctx, input) 56 | } else { 57 | r1 = ret.Error(1) 58 | } 59 | 60 | return r0, r1 61 | } 62 | 63 | // DeleteTweet provides a mock function with given fields: ctx, id 64 | func (_m *MutationResolver) DeleteTweet(ctx context.Context, id string) (bool, error) { 65 | ret := _m.Called(ctx, id) 66 | 67 | var r0 bool 68 | if rf, ok := ret.Get(0).(func(context.Context, string) bool); ok { 69 | r0 = rf(ctx, id) 70 | } else { 71 | r0 = ret.Get(0).(bool) 72 | } 73 | 74 | var r1 error 75 | if rf, ok := ret.Get(1).(func(context.Context, string) error); ok { 76 | r1 = rf(ctx, id) 77 | } else { 78 | r1 = ret.Error(1) 79 | } 80 | 81 | return r0, r1 82 | } 83 | 84 | // Login provides a mock function with given fields: ctx, input 85 | func (_m *MutationResolver) Login(ctx context.Context, input graph.LoginInput) (*graph.AuthResponse, error) { 86 | ret := _m.Called(ctx, input) 87 | 88 | var r0 *graph.AuthResponse 89 | if rf, ok := ret.Get(0).(func(context.Context, graph.LoginInput) *graph.AuthResponse); ok { 90 | r0 = rf(ctx, input) 91 | } else { 92 | if ret.Get(0) != nil { 93 | r0 = ret.Get(0).(*graph.AuthResponse) 94 | } 95 | } 96 | 97 | var r1 error 98 | if rf, ok := ret.Get(1).(func(context.Context, graph.LoginInput) error); ok { 99 | r1 = rf(ctx, input) 100 | } else { 101 | r1 = ret.Error(1) 102 | } 103 | 104 | return r0, r1 105 | } 106 | 107 | // Register provides a mock function with given fields: ctx, input 108 | func (_m *MutationResolver) Register(ctx context.Context, input graph.RegisterInput) (*graph.AuthResponse, error) { 109 | ret := _m.Called(ctx, input) 110 | 111 | var r0 *graph.AuthResponse 112 | if rf, ok := ret.Get(0).(func(context.Context, graph.RegisterInput) *graph.AuthResponse); ok { 113 | r0 = rf(ctx, input) 114 | } else { 115 | if ret.Get(0) != nil { 116 | r0 = ret.Get(0).(*graph.AuthResponse) 117 | } 118 | } 119 | 120 | var r1 error 121 | if rf, ok := ret.Get(1).(func(context.Context, graph.RegisterInput) error); ok { 122 | r1 = rf(ctx, input) 123 | } else { 124 | r1 = ret.Error(1) 125 | } 126 | 127 | return r0, r1 128 | } 129 | -------------------------------------------------------------------------------- /mocks/graph/QueryResolver.go: -------------------------------------------------------------------------------- 1 | // Code generated by mockery 2.9.0. DO NOT EDIT. 2 | 3 | package mocks 4 | 5 | import ( 6 | context "context" 7 | 8 | graph "github.com/equimper/twitter/graph" 9 | mock "github.com/stretchr/testify/mock" 10 | ) 11 | 12 | // QueryResolver is an autogenerated mock type for the QueryResolver type 13 | type QueryResolver struct { 14 | mock.Mock 15 | } 16 | 17 | // Me provides a mock function with given fields: ctx 18 | func (_m *QueryResolver) Me(ctx context.Context) (*graph.User, error) { 19 | ret := _m.Called(ctx) 20 | 21 | var r0 *graph.User 22 | if rf, ok := ret.Get(0).(func(context.Context) *graph.User); ok { 23 | r0 = rf(ctx) 24 | } else { 25 | if ret.Get(0) != nil { 26 | r0 = ret.Get(0).(*graph.User) 27 | } 28 | } 29 | 30 | var r1 error 31 | if rf, ok := ret.Get(1).(func(context.Context) error); ok { 32 | r1 = rf(ctx) 33 | } else { 34 | r1 = ret.Error(1) 35 | } 36 | 37 | return r0, r1 38 | } 39 | 40 | // Tweets provides a mock function with given fields: ctx 41 | func (_m *QueryResolver) Tweets(ctx context.Context) ([]*graph.Tweet, error) { 42 | ret := _m.Called(ctx) 43 | 44 | var r0 []*graph.Tweet 45 | if rf, ok := ret.Get(0).(func(context.Context) []*graph.Tweet); ok { 46 | r0 = rf(ctx) 47 | } else { 48 | if ret.Get(0) != nil { 49 | r0 = ret.Get(0).([]*graph.Tweet) 50 | } 51 | } 52 | 53 | var r1 error 54 | if rf, ok := ret.Get(1).(func(context.Context) error); ok { 55 | r1 = rf(ctx) 56 | } else { 57 | r1 = ret.Error(1) 58 | } 59 | 60 | return r0, r1 61 | } 62 | -------------------------------------------------------------------------------- /mocks/graph/ResolverRoot.go: -------------------------------------------------------------------------------- 1 | // Code generated by mockery 2.9.0. DO NOT EDIT. 2 | 3 | package mocks 4 | 5 | import ( 6 | graph "github.com/equimper/twitter/graph" 7 | mock "github.com/stretchr/testify/mock" 8 | ) 9 | 10 | // ResolverRoot is an autogenerated mock type for the ResolverRoot type 11 | type ResolverRoot struct { 12 | mock.Mock 13 | } 14 | 15 | // Mutation provides a mock function with given fields: 16 | func (_m *ResolverRoot) Mutation() graph.MutationResolver { 17 | ret := _m.Called() 18 | 19 | var r0 graph.MutationResolver 20 | if rf, ok := ret.Get(0).(func() graph.MutationResolver); ok { 21 | r0 = rf() 22 | } else { 23 | if ret.Get(0) != nil { 24 | r0 = ret.Get(0).(graph.MutationResolver) 25 | } 26 | } 27 | 28 | return r0 29 | } 30 | 31 | // Query provides a mock function with given fields: 32 | func (_m *ResolverRoot) Query() graph.QueryResolver { 33 | ret := _m.Called() 34 | 35 | var r0 graph.QueryResolver 36 | if rf, ok := ret.Get(0).(func() graph.QueryResolver); ok { 37 | r0 = rf() 38 | } else { 39 | if ret.Get(0) != nil { 40 | r0 = ret.Get(0).(graph.QueryResolver) 41 | } 42 | } 43 | 44 | return r0 45 | } 46 | 47 | // Tweet provides a mock function with given fields: 48 | func (_m *ResolverRoot) Tweet() graph.TweetResolver { 49 | ret := _m.Called() 50 | 51 | var r0 graph.TweetResolver 52 | if rf, ok := ret.Get(0).(func() graph.TweetResolver); ok { 53 | r0 = rf() 54 | } else { 55 | if ret.Get(0) != nil { 56 | r0 = ret.Get(0).(graph.TweetResolver) 57 | } 58 | } 59 | 60 | return r0 61 | } 62 | -------------------------------------------------------------------------------- /mocks/graph/TweetResolver.go: -------------------------------------------------------------------------------- 1 | // Code generated by mockery 2.9.0. DO NOT EDIT. 2 | 3 | package mocks 4 | 5 | import ( 6 | context "context" 7 | 8 | graph "github.com/equimper/twitter/graph" 9 | mock "github.com/stretchr/testify/mock" 10 | ) 11 | 12 | // TweetResolver is an autogenerated mock type for the TweetResolver type 13 | type TweetResolver struct { 14 | mock.Mock 15 | } 16 | 17 | // User provides a mock function with given fields: ctx, obj 18 | func (_m *TweetResolver) User(ctx context.Context, obj *graph.Tweet) (*graph.User, error) { 19 | ret := _m.Called(ctx, obj) 20 | 21 | var r0 *graph.User 22 | if rf, ok := ret.Get(0).(func(context.Context, *graph.Tweet) *graph.User); ok { 23 | r0 = rf(ctx, obj) 24 | } else { 25 | if ret.Get(0) != nil { 26 | r0 = ret.Get(0).(*graph.User) 27 | } 28 | } 29 | 30 | var r1 error 31 | if rf, ok := ret.Get(1).(func(context.Context, *graph.Tweet) error); ok { 32 | r1 = rf(ctx, obj) 33 | } else { 34 | r1 = ret.Error(1) 35 | } 36 | 37 | return r0, r1 38 | } 39 | -------------------------------------------------------------------------------- /postgres/migrations/20210508145803_create_users_table.down.sql: -------------------------------------------------------------------------------- 1 | DROP TABLE IF EXISTS users; -------------------------------------------------------------------------------- /postgres/migrations/20210508145803_create_users_table.up.sql: -------------------------------------------------------------------------------- 1 | CREATE EXTENSION IF NOT EXISTS "uuid-ossp"; 2 | 3 | CREATE TABLE IF NOT EXISTS users( 4 | id UUID PRIMARY KEY NOT NULL DEFAULT uuid_generate_v1(), 5 | username VARCHAR(255) UNIQUE NOT NULL, 6 | email VARCHAR(255) UNIQUE NOT NULL, 7 | password TEXT NOT NULL, 8 | created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(), 9 | updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW() 10 | ); -------------------------------------------------------------------------------- /postgres/migrations/20211027092349_create_tweets_table.down.sql: -------------------------------------------------------------------------------- 1 | DROP TABLE IF EXISTS tweets; -------------------------------------------------------------------------------- /postgres/migrations/20211027092349_create_tweets_table.up.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE IF NOT EXISTS tweets( 2 | id UUID PRIMARY KEY NOT NULL DEFAULT uuid_generate_v1(), 3 | body VARCHAR(250) NOT NULL, 4 | user_id UUID NOT NULL REFERENCES users (id) ON DELETE CASCADE, 5 | created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(), 6 | updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW() 7 | ); -------------------------------------------------------------------------------- /postgres/migrations/20220117202457_add_parent_id_to_tweets_table.down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE tweets DROP COLUMN IF EXISTS parent_id; -------------------------------------------------------------------------------- /postgres/migrations/20220117202457_add_parent_id_to_tweets_table.up.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE tweets ADD COLUMN parent_id UUID REFERENCES tweets (id) ON DELETE CASCADE; -------------------------------------------------------------------------------- /postgres/postgres.go: -------------------------------------------------------------------------------- 1 | package postgres 2 | 3 | import ( 4 | "context" 5 | "fmt" 6 | "log" 7 | "os" 8 | "path" 9 | "runtime" 10 | 11 | "github.com/golang-migrate/migrate/v4" 12 | _ "github.com/golang-migrate/migrate/v4/database/postgres" 13 | _ "github.com/golang-migrate/migrate/v4/source/file" 14 | "github.com/sirupsen/logrus" 15 | 16 | "github.com/jackc/pgx/v4/log/logrusadapter" 17 | "github.com/jackc/pgx/v4/pgxpool" 18 | 19 | "github.com/equimper/twitter/config" 20 | ) 21 | 22 | type DB struct { 23 | Pool *pgxpool.Pool 24 | conf *config.Config 25 | } 26 | 27 | func New(ctx context.Context, conf *config.Config) *DB { 28 | dbConf, err := pgxpool.ParseConfig(conf.Database.URL) 29 | if err != nil { 30 | log.Fatalf("can't parse postgres config: %v", err) 31 | } 32 | 33 | logrusLogger := &logrus.Logger{ 34 | Out: os.Stderr, 35 | Formatter: new(logrus.JSONFormatter), 36 | Hooks: make(logrus.LevelHooks), 37 | Level: logrus.InfoLevel, 38 | ExitFunc: os.Exit, 39 | ReportCaller: false, 40 | } 41 | 42 | dbConf.ConnConfig.Logger = logrusadapter.NewLogger(logrusLogger) 43 | 44 | pool, err := pgxpool.ConnectConfig(ctx, dbConf) 45 | if err != nil { 46 | log.Fatalf("error connecting to postgres: %v", err) 47 | } 48 | 49 | db := &DB{Pool: pool, conf: conf} 50 | 51 | db.Ping(ctx) 52 | 53 | return db 54 | } 55 | 56 | func (db *DB) Ping(ctx context.Context) { 57 | if err := db.Pool.Ping(ctx); err != nil { 58 | log.Fatalf("can't ping postgres: %v", err) 59 | } 60 | 61 | log.Println("postgres connected") 62 | } 63 | 64 | func (db *DB) Close() { 65 | db.Pool.Close() 66 | } 67 | 68 | func (db *DB) Migrate() error { 69 | _, b, _, _ := runtime.Caller(0) 70 | 71 | migrationPath := fmt.Sprintf("file:///%s/migrations", path.Dir(b)) 72 | 73 | m, err := migrate.New(migrationPath, db.conf.Database.URL) 74 | if err != nil { 75 | return fmt.Errorf("error create the migrate instance: %v", err) 76 | } 77 | 78 | if err := m.Up(); err != nil && err != migrate.ErrNoChange { 79 | return fmt.Errorf("error migrate up: %v", err) 80 | } 81 | 82 | log.Println("migration done") 83 | 84 | return nil 85 | } 86 | 87 | func (db *DB) Drop() error { 88 | _, b, _, _ := runtime.Caller(0) 89 | 90 | migrationPath := fmt.Sprintf("file:///%s/migrations", path.Dir(b)) 91 | 92 | m, err := migrate.New(migrationPath, db.conf.Database.URL) 93 | if err != nil { 94 | return fmt.Errorf("error create the migrate instance: %v", err) 95 | } 96 | 97 | if err := m.Drop(); err != nil { 98 | return fmt.Errorf("error drop: %v", err) 99 | } 100 | 101 | log.Println("migration drop") 102 | 103 | return nil 104 | } 105 | 106 | func (db *DB) Truncate(ctx context.Context) error { 107 | if _, err := db.Pool.Exec(ctx, ` 108 | DELETE FROM users; 109 | `); err != nil { 110 | return fmt.Errorf("error truncate: %v", err) 111 | } 112 | 113 | return nil 114 | } 115 | -------------------------------------------------------------------------------- /postgres/tweet_repo.go: -------------------------------------------------------------------------------- 1 | package postgres 2 | 3 | import ( 4 | "context" 5 | "fmt" 6 | 7 | "github.com/equimper/twitter" 8 | "github.com/georgysavva/scany/pgxscan" 9 | "github.com/jackc/pgx/v4" 10 | ) 11 | 12 | type TweetRepo struct { 13 | DB *DB 14 | } 15 | 16 | func NewTweetRepo(db *DB) *TweetRepo { 17 | return &TweetRepo{ 18 | DB: db, 19 | } 20 | } 21 | 22 | func (tr *TweetRepo) All(ctx context.Context) ([]twitter.Tweet, error) { 23 | return getAllTweets(ctx, tr.DB.Pool) 24 | } 25 | 26 | func getAllTweets(ctx context.Context, q pgxscan.Querier) ([]twitter.Tweet, error) { 27 | query := `SELECT * FROM tweets WHERE parent_id IS NULL ORDER BY created_at DESC;` 28 | 29 | var tweets []twitter.Tweet 30 | 31 | if err := pgxscan.Select(ctx, q, &tweets, query); err != nil { 32 | return nil, fmt.Errorf("error get all tweets %+v", err) 33 | } 34 | 35 | return tweets, nil 36 | } 37 | 38 | func (tr *TweetRepo) Create(ctx context.Context, tweet twitter.Tweet) (twitter.Tweet, error) { 39 | tx, err := tr.DB.Pool.Begin(ctx) 40 | if err != nil { 41 | return twitter.Tweet{}, fmt.Errorf("error starting transaction: %v", err) 42 | } 43 | defer tx.Rollback(ctx) 44 | 45 | tweet, err = createTweet(ctx, tx, tweet) 46 | if err != nil { 47 | return twitter.Tweet{}, err 48 | } 49 | 50 | if err := tx.Commit(ctx); err != nil { 51 | return twitter.Tweet{}, fmt.Errorf("error commiting: %v", err) 52 | } 53 | 54 | return tweet, nil 55 | } 56 | 57 | func createTweet(ctx context.Context, tx pgx.Tx, tweet twitter.Tweet) (twitter.Tweet, error) { 58 | query := `INSERT INTO tweets (body, user_id, parent_id) VALUES ($1, $2, $3) RETURNING *;` 59 | 60 | t := twitter.Tweet{} 61 | 62 | if err := pgxscan.Get(ctx, tx, &t, query, tweet.Body, tweet.UserID, tweet.ParentID); err != nil { 63 | return twitter.Tweet{}, fmt.Errorf("error insert: %v", err) 64 | } 65 | 66 | return t, nil 67 | } 68 | 69 | func (tr *TweetRepo) GetByID(ctx context.Context, id string) (twitter.Tweet, error) { 70 | return getTweetByID(ctx, tr.DB.Pool, id) 71 | } 72 | 73 | func getTweetByID(ctx context.Context, q pgxscan.Querier, id string) (twitter.Tweet, error) { 74 | query := `SELECT * FROM tweets WHERE id = $1 LIMIT 1;` 75 | 76 | t := twitter.Tweet{} 77 | 78 | if err := pgxscan.Get(ctx, q, &t, query, id); err != nil { 79 | if pgxscan.NotFound(err) { 80 | return twitter.Tweet{}, twitter.ErrNotFound 81 | } 82 | 83 | return twitter.Tweet{}, fmt.Errorf("error get tweet: %+v", err) 84 | } 85 | 86 | return t, nil 87 | } 88 | 89 | func (tr *TweetRepo) Delete(ctx context.Context, id string) error { 90 | tx, err := tr.DB.Pool.Begin(ctx) 91 | if err != nil { 92 | return fmt.Errorf("error starting transaction: %v", err) 93 | } 94 | defer tx.Rollback(ctx) 95 | 96 | if err := deleteTweet(ctx, tx, id); err != nil { 97 | return err 98 | } 99 | 100 | if err := tx.Commit(ctx); err != nil { 101 | return fmt.Errorf("error commiting: %v", err) 102 | } 103 | 104 | return nil 105 | } 106 | 107 | func deleteTweet(ctx context.Context, tx pgx.Tx, id string) error { 108 | query := `DELETE FROM tweets WHERE id = $1;` 109 | 110 | if _, err := tx.Exec(ctx, query, id); err != nil { 111 | return fmt.Errorf("error insert: %v", err) 112 | } 113 | 114 | return nil 115 | } 116 | 117 | func (tr *TweetRepo) GetByParentID(ctx context.Context, id string) ([]twitter.Tweet, error) { 118 | return getTweetsByParentID(ctx, tr.DB.Pool, id) 119 | } 120 | 121 | func getTweetsByParentID(ctx context.Context, q pgxscan.Querier, id string) ([]twitter.Tweet, error) { 122 | query := `SELECT * FROM tweets WHERE parent_id = $1;` 123 | 124 | var tweets []twitter.Tweet 125 | 126 | if err := pgxscan.Select(ctx, q, &tweets, query, id); err != nil { 127 | return nil, fmt.Errorf("error get all tweets by parent id %+v", err) 128 | } 129 | 130 | return tweets, nil 131 | } 132 | -------------------------------------------------------------------------------- /postgres/user_repo.go: -------------------------------------------------------------------------------- 1 | package postgres 2 | 3 | import ( 4 | "context" 5 | "fmt" 6 | 7 | "github.com/equimper/twitter" 8 | "github.com/georgysavva/scany/pgxscan" 9 | "github.com/jackc/pgx/v4" 10 | ) 11 | 12 | type UserRepo struct { 13 | DB *DB 14 | } 15 | 16 | func NewUserRepo(db *DB) *UserRepo { 17 | return &UserRepo{ 18 | DB: db, 19 | } 20 | } 21 | 22 | func (ur *UserRepo) Create(ctx context.Context, user twitter.User) (twitter.User, error) { 23 | tx, err := ur.DB.Pool.Begin(ctx) 24 | if err != nil { 25 | return twitter.User{}, fmt.Errorf("error starting transaction: %v", err) 26 | } 27 | defer tx.Rollback(ctx) 28 | 29 | user, err = createUser(ctx, tx, user) 30 | if err != nil { 31 | return twitter.User{}, err 32 | } 33 | 34 | if err := tx.Commit(ctx); err != nil { 35 | return twitter.User{}, fmt.Errorf("error commiting: %v", err) 36 | } 37 | 38 | return user, nil 39 | } 40 | 41 | func createUser(ctx context.Context, tx pgx.Tx, user twitter.User) (twitter.User, error) { 42 | query := `INSERT INTO users (email, username, password) VALUES ($1, $2, $3) RETURNING *;` 43 | 44 | u := twitter.User{} 45 | 46 | if err := pgxscan.Get(ctx, tx, &u, query, user.Email, user.Username, user.Password); err != nil { 47 | return twitter.User{}, fmt.Errorf("error insert: %v", err) 48 | } 49 | 50 | return u, nil 51 | } 52 | 53 | func (ur *UserRepo) GetByUsername(ctx context.Context, username string) (twitter.User, error) { 54 | query := `SELECT * FROM users WHERE username = $1 LIMIT 1;` 55 | 56 | u := twitter.User{} 57 | 58 | if err := pgxscan.Get(ctx, ur.DB.Pool, &u, query, username); err != nil { 59 | if pgxscan.NotFound(err) { 60 | return twitter.User{}, twitter.ErrNotFound 61 | } 62 | 63 | return twitter.User{}, fmt.Errorf("error select: %v", err) 64 | } 65 | 66 | return u, nil 67 | } 68 | 69 | func (ur *UserRepo) GetByEmail(ctx context.Context, email string) (twitter.User, error) { 70 | query := `SELECT * FROM users WHERE email = $1 LIMIT 1;` 71 | 72 | u := twitter.User{} 73 | 74 | if err := pgxscan.Get(ctx, ur.DB.Pool, &u, query, email); err != nil { 75 | if pgxscan.NotFound(err) { 76 | return twitter.User{}, twitter.ErrNotFound 77 | } 78 | 79 | return twitter.User{}, fmt.Errorf("error select: %v", err) 80 | } 81 | 82 | return u, nil 83 | } 84 | 85 | func (ur *UserRepo) GetByID(ctx context.Context, id string) (twitter.User, error) { 86 | query := `SELECT * FROM users WHERE id = $1 LIMIT 1;` 87 | 88 | u := twitter.User{} 89 | 90 | if err := pgxscan.Get(ctx, ur.DB.Pool, &u, query, id); err != nil { 91 | if pgxscan.NotFound(err) { 92 | return twitter.User{}, twitter.ErrNotFound 93 | } 94 | 95 | return twitter.User{}, fmt.Errorf("error select: %v", err) 96 | } 97 | 98 | return u, nil 99 | } 100 | 101 | func (ur *UserRepo) GetByIds(ctx context.Context, ids []string) ([]twitter.User, error) { 102 | return getUsersByIds(ctx, ur.DB.Pool, ids) 103 | } 104 | 105 | func getUsersByIds(ctx context.Context, q pgxscan.Querier, ids []string) ([]twitter.User, error) { 106 | query := `SELECT * FROM users WHERE id = ANY($1);` 107 | 108 | var uu []twitter.User 109 | 110 | if err := pgxscan.Select(ctx, q, &uu, query, ids); err != nil { 111 | return nil, fmt.Errorf("error get users by ids: %+v", err) 112 | } 113 | 114 | return uu, nil 115 | } 116 | -------------------------------------------------------------------------------- /refresh_token.go: -------------------------------------------------------------------------------- 1 | package twitter 2 | 3 | import ( 4 | "context" 5 | "time" 6 | ) 7 | 8 | var ( 9 | AccessTokenLifetime = time.Minute * 15 // 15 minutes 10 | RefreshTokenLifetime = time.Hour * 24 * 7 // 1 week 11 | ) 12 | 13 | type RefreshToken struct { 14 | ID string 15 | Name string 16 | UserID string 17 | LastUsedAt time.Time 18 | ExpiredAt time.Time 19 | CreatedAt time.Time 20 | } 21 | 22 | type CreateRefreshTokenParams struct { 23 | Sub string 24 | Name string 25 | } 26 | 27 | type RefreshTokenRepo interface { 28 | Create(ctx context.Context, params CreateRefreshTokenParams) (RefreshToken, error) 29 | GetByID(ctx context.Context, id string) (RefreshToken, error) 30 | } 31 | -------------------------------------------------------------------------------- /test_helpers/test_helpers.go: -------------------------------------------------------------------------------- 1 | package test_helpers 2 | 3 | import ( 4 | "context" 5 | "testing" 6 | 7 | "github.com/equimper/twitter" 8 | "github.com/equimper/twitter/faker" 9 | "github.com/equimper/twitter/postgres" 10 | "github.com/stretchr/testify/require" 11 | ) 12 | 13 | func TeardownDB(ctx context.Context, t *testing.T, db *postgres.DB) { 14 | t.Helper() 15 | 16 | err := db.Truncate(ctx) 17 | require.NoError(t, err) 18 | } 19 | 20 | func CreateUser(ctx context.Context, t *testing.T, userRepo twitter.UserRepo) twitter.User { 21 | t.Helper() 22 | 23 | user, err := userRepo.Create(ctx, twitter.User{ 24 | Username: faker.Username(), 25 | Email: faker.Email(), 26 | Password: faker.Password, 27 | }) 28 | require.NoError(t, err) 29 | 30 | return user 31 | } 32 | 33 | func CreateTweet(ctx context.Context, t *testing.T, tweetRepo twitter.TweetRepo, forUser string) twitter.Tweet { 34 | t.Helper() 35 | 36 | tweet, err := tweetRepo.Create(ctx, twitter.Tweet{ 37 | Body: faker.RandStr(20), 38 | UserID: forUser, 39 | }) 40 | require.NoError(t, err) 41 | 42 | return tweet 43 | } 44 | 45 | func LoginUser(ctx context.Context, t *testing.T, user twitter.User) context.Context { 46 | t.Helper() 47 | 48 | return twitter.PutUserIDIntoContext(ctx, user.ID) 49 | } 50 | -------------------------------------------------------------------------------- /tweet.go: -------------------------------------------------------------------------------- 1 | package twitter 2 | 3 | import ( 4 | "context" 5 | "fmt" 6 | "strings" 7 | "time" 8 | ) 9 | 10 | var ( 11 | TweetMinLength = 2 12 | TweetMaxLength = 250 13 | ) 14 | 15 | type CreateTweetInput struct { 16 | Body string 17 | } 18 | 19 | func (in *CreateTweetInput) Sanitize() { 20 | in.Body = strings.TrimSpace(in.Body) 21 | } 22 | 23 | func (in CreateTweetInput) Validate() error { 24 | if len(in.Body) < TweetMinLength { 25 | return fmt.Errorf("%w: body not long enough, (%d) characters at least", ErrValidation, TweetMinLength) 26 | } 27 | 28 | if len(in.Body) > TweetMaxLength { 29 | return fmt.Errorf("%w: body too long, (%d) characters at max", ErrValidation, TweetMaxLength) 30 | } 31 | 32 | return nil 33 | } 34 | 35 | type Tweet struct { 36 | ID string 37 | Body string 38 | UserID string 39 | ParentID *string 40 | CreatedAt time.Time 41 | UpdatedAt time.Time 42 | } 43 | 44 | func (t Tweet) CanDelete(user User) bool { 45 | return t.UserID == user.ID 46 | } 47 | 48 | type TweetService interface { 49 | All(ctx context.Context) ([]Tweet, error) 50 | Create(ctx context.Context, input CreateTweetInput) (Tweet, error) 51 | CreateReply(ctx context.Context, parentID string, input CreateTweetInput) (Tweet, error) 52 | GetByID(ctx context.Context, id string) (Tweet, error) 53 | GetByParentID(ctx context.Context, id string) ([]Tweet, error) 54 | Delete(ctx context.Context, id string) error 55 | } 56 | 57 | type TweetRepo interface { 58 | All(ctx context.Context) ([]Tweet, error) 59 | Create(ctx context.Context, tweet Tweet) (Tweet, error) 60 | GetByID(ctx context.Context, id string) (Tweet, error) 61 | GetByParentID(ctx context.Context, id string) ([]Tweet, error) 62 | Delete(ctx context.Context, id string) error 63 | } 64 | -------------------------------------------------------------------------------- /tweet_test.go: -------------------------------------------------------------------------------- 1 | package twitter 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/equimper/twitter/faker" 7 | "github.com/stretchr/testify/require" 8 | ) 9 | 10 | func TestCreateTweetInput_Sanitize(t *testing.T) { 11 | input := CreateTweetInput{ 12 | Body: " hello ", 13 | } 14 | 15 | want := CreateTweetInput{ 16 | Body: "hello", 17 | } 18 | 19 | input.Sanitize() 20 | 21 | require.Equal(t, want, input) 22 | } 23 | 24 | func TestCreateTweetInput_Validate(t *testing.T) { 25 | testCases := []struct { 26 | name string 27 | input CreateTweetInput 28 | err error 29 | }{ 30 | { 31 | name: "valid", 32 | input: CreateTweetInput{ 33 | Body: "hello", 34 | }, 35 | err: nil, 36 | }, 37 | { 38 | name: "tweet not long enough", 39 | input: CreateTweetInput{ 40 | Body: "h", 41 | }, 42 | err: ErrValidation, 43 | }, 44 | { 45 | name: "tweet too long", 46 | input: CreateTweetInput{ 47 | Body: faker.RandStr(300), 48 | }, 49 | err: ErrValidation, 50 | }, 51 | } 52 | 53 | for _, tc := range testCases { 54 | t.Run(tc.name, func(t *testing.T) { 55 | err := tc.input.Validate() 56 | 57 | if tc.err != nil { 58 | require.ErrorIs(t, err, tc.err) 59 | } else { 60 | require.NoError(t, err) 61 | } 62 | }) 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /twitter.go: -------------------------------------------------------------------------------- 1 | package twitter 2 | 3 | import "errors" 4 | 5 | var ( 6 | ErrBadCredentials = errors.New("email/password wrong combination") 7 | ErrNotFound = errors.New("not found") 8 | ErrValidation = errors.New("validation error") 9 | ErrInvalidAccessToken = errors.New("invalid access token") 10 | ErrNoUserIDInContext = errors.New("no user id in context") 11 | ErrGenAccessToken = errors.New("generate access token error") 12 | ErrUnauthenticated = errors.New("unauthenticated") 13 | ErrInvalidUUID = errors.New("invalid uuid") 14 | ErrForbidden = errors.New("forbidden") 15 | ) 16 | -------------------------------------------------------------------------------- /user.go: -------------------------------------------------------------------------------- 1 | package twitter 2 | 3 | import ( 4 | "context" 5 | "errors" 6 | "time" 7 | ) 8 | 9 | var ( 10 | ErrUsernameTaken = errors.New("username taken") 11 | ErrEmailTaken = errors.New("email taken") 12 | ) 13 | 14 | type UserService interface { 15 | GetByID(ctx context.Context, id string) (User, error) 16 | } 17 | 18 | type UserRepo interface { 19 | Create(ctx context.Context, user User) (User, error) 20 | GetByUsername(ctx context.Context, username string) (User, error) 21 | GetByEmail(ctx context.Context, email string) (User, error) 22 | GetByID(ctx context.Context, id string) (User, error) 23 | GetByIds(ctx context.Context, ids []string) ([]User, error) 24 | } 25 | 26 | type User struct { 27 | ID string 28 | Username string 29 | Email string 30 | Password string 31 | CreatedAt time.Time 32 | UpdatedAt time.Time 33 | } 34 | -------------------------------------------------------------------------------- /uuid/uuid.go: -------------------------------------------------------------------------------- 1 | package uuid 2 | 3 | import "github.com/google/uuid" 4 | 5 | func Generate() string { 6 | return uuid.NewString() 7 | } 8 | 9 | func Validate(value string) bool { 10 | if _, err := uuid.Parse(value); err != nil { 11 | return false 12 | } 13 | 14 | return true 15 | } 16 | --------------------------------------------------------------------------------