first commit
This commit is contained in:
parent
f729f0c48f
commit
1ac40acc04
@ -4,7 +4,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/farahty/go-mongo/models"
|
"git.farahty.com/nimer/go-mongo/models"
|
||||||
)
|
)
|
||||||
|
|
||||||
type contextKey struct {
|
type contextKey struct {
|
||||||
|
|||||||
@ -7,11 +7,11 @@ import (
|
|||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
|
"git.farahty.com/nimer/go-mongo/models"
|
||||||
"github.com/99designs/gqlgen/graphql"
|
"github.com/99designs/gqlgen/graphql"
|
||||||
"github.com/99designs/gqlgen/graphql/handler/transport"
|
"github.com/99designs/gqlgen/graphql/handler/transport"
|
||||||
"github.com/casbin/casbin/v2"
|
"github.com/casbin/casbin/v2"
|
||||||
mongodbadapter "github.com/casbin/mongodb-adapter/v3"
|
mongodbadapter "github.com/casbin/mongodb-adapter/v3"
|
||||||
"github.com/farahty/go-mongo/models"
|
|
||||||
"github.com/golang-jwt/jwt/v4"
|
"github.com/golang-jwt/jwt/v4"
|
||||||
"go.mongodb.org/mongo-driver/bson"
|
"go.mongodb.org/mongo-driver/bson"
|
||||||
"go.mongodb.org/mongo-driver/mongo/options"
|
"go.mongodb.org/mongo-driver/mongo/options"
|
||||||
|
|||||||
@ -5,7 +5,7 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/farahty/go-mongo/models"
|
"git.farahty.com/nimer/go-mongo/models"
|
||||||
"github.com/golang-jwt/jwt/v4"
|
"github.com/golang-jwt/jwt/v4"
|
||||||
"github.com/mitchellh/mapstructure"
|
"github.com/mitchellh/mapstructure"
|
||||||
)
|
)
|
||||||
|
|||||||
@ -6,7 +6,7 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
"reflect"
|
"reflect"
|
||||||
|
|
||||||
"github.com/farahty/go-mongo/models"
|
"git.farahty.com/nimer/go-mongo/models"
|
||||||
"github.com/graph-gophers/dataloader"
|
"github.com/graph-gophers/dataloader"
|
||||||
"go.mongodb.org/mongo-driver/bson"
|
"go.mongodb.org/mongo-driver/bson"
|
||||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||||
|
|||||||
@ -4,7 +4,7 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
userService "github.com/farahty/go-mongo/services/user"
|
userService "git.farahty.com/nimer/go-mongo/services/user"
|
||||||
"github.com/go-chi/chi/v5"
|
"github.com/go-chi/chi/v5"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@ -4,8 +4,8 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
|
"git.farahty.com/nimer/go-mongo/app"
|
||||||
"github.com/99designs/gqlgen/graphql"
|
"github.com/99designs/gqlgen/graphql"
|
||||||
"github.com/farahty/go-mongo/app"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func Auth(ctx context.Context, obj interface{}, next graphql.Resolver) (res interface{}, err error) {
|
func Auth(ctx context.Context, obj interface{}, next graphql.Resolver) (res interface{}, err error) {
|
||||||
|
|||||||
@ -15,8 +15,8 @@ import (
|
|||||||
|
|
||||||
"github.com/99designs/gqlgen/graphql"
|
"github.com/99designs/gqlgen/graphql"
|
||||||
"github.com/99designs/gqlgen/graphql/introspection"
|
"github.com/99designs/gqlgen/graphql/introspection"
|
||||||
"github.com/farahty/go-mongo/app"
|
"git.farahty.com/nimer/go-mongo/app"
|
||||||
"github.com/farahty/go-mongo/models"
|
"git.farahty.com/nimer/go-mongo/models"
|
||||||
gqlparser "github.com/vektah/gqlparser/v2"
|
gqlparser "github.com/vektah/gqlparser/v2"
|
||||||
"github.com/vektah/gqlparser/v2/ast"
|
"github.com/vektah/gqlparser/v2/ast"
|
||||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||||
|
|||||||
2
go.mod
2
go.mod
@ -1,4 +1,4 @@
|
|||||||
module github.com/farahty/go-mongo
|
module git.farahty.com/nimer/go-mongo
|
||||||
|
|
||||||
go 1.23.0
|
go 1.23.0
|
||||||
|
|
||||||
|
|||||||
2
main.go
2
main.go
@ -9,7 +9,7 @@ import (
|
|||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"github.com/farahty/go-mongo/app"
|
"git.farahty.com/nimer/go-mongo/app"
|
||||||
"github.com/fatih/color"
|
"github.com/fatih/color"
|
||||||
"github.com/joho/godotenv"
|
"github.com/joho/godotenv"
|
||||||
"github.com/redis/go-redis/v9"
|
"github.com/redis/go-redis/v9"
|
||||||
|
|||||||
@ -7,9 +7,9 @@ package resolvers
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/farahty/go-mongo/generated"
|
"git.farahty.com/nimer/go-mongo/generated"
|
||||||
"github.com/farahty/go-mongo/models"
|
"git.farahty.com/nimer/go-mongo/models"
|
||||||
authService "github.com/farahty/go-mongo/services/auth"
|
authService "git.farahty.com/nimer/go-mongo/services/auth"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Login is the resolver for the login field.
|
// Login is the resolver for the login field.
|
||||||
|
|||||||
@ -7,10 +7,10 @@ package resolvers
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/farahty/go-mongo/generated"
|
"git.farahty.com/nimer/go-mongo/generated"
|
||||||
"github.com/farahty/go-mongo/models"
|
"git.farahty.com/nimer/go-mongo/models"
|
||||||
categoryService "github.com/farahty/go-mongo/services/category"
|
categoryService "git.farahty.com/nimer/go-mongo/services/category"
|
||||||
userService "github.com/farahty/go-mongo/services/user"
|
userService "git.farahty.com/nimer/go-mongo/services/user"
|
||||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@ -8,10 +8,10 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
||||||
"github.com/farahty/go-mongo/generated"
|
"git.farahty.com/nimer/go-mongo/generated"
|
||||||
"github.com/farahty/go-mongo/models"
|
"git.farahty.com/nimer/go-mongo/models"
|
||||||
todoService "github.com/farahty/go-mongo/services/todo"
|
todoService "git.farahty.com/nimer/go-mongo/services/todo"
|
||||||
userService "github.com/farahty/go-mongo/services/user"
|
userService "git.farahty.com/nimer/go-mongo/services/user"
|
||||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@ -7,9 +7,9 @@ package resolvers
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/farahty/go-mongo/generated"
|
"git.farahty.com/nimer/go-mongo/generated"
|
||||||
"github.com/farahty/go-mongo/models"
|
"git.farahty.com/nimer/go-mongo/models"
|
||||||
userService "github.com/farahty/go-mongo/services/user"
|
userService "git.farahty.com/nimer/go-mongo/services/user"
|
||||||
)
|
)
|
||||||
|
|
||||||
// CreateUser is the resolver for the createUser field.
|
// CreateUser is the resolver for the createUser field.
|
||||||
|
|||||||
10
router.go
10
router.go
@ -5,16 +5,16 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"git.farahty.com/nimer/go-mongo/app"
|
||||||
|
"git.farahty.com/nimer/go-mongo/controllers"
|
||||||
|
"git.farahty.com/nimer/go-mongo/directives"
|
||||||
|
"git.farahty.com/nimer/go-mongo/generated"
|
||||||
"github.com/99designs/gqlgen/graphql/handler"
|
"github.com/99designs/gqlgen/graphql/handler"
|
||||||
"github.com/99designs/gqlgen/graphql/handler/extension"
|
"github.com/99designs/gqlgen/graphql/handler/extension"
|
||||||
"github.com/99designs/gqlgen/graphql/handler/transport"
|
"github.com/99designs/gqlgen/graphql/handler/transport"
|
||||||
"github.com/99designs/gqlgen/graphql/playground"
|
"github.com/99designs/gqlgen/graphql/playground"
|
||||||
"github.com/farahty/go-mongo/app"
|
|
||||||
"github.com/farahty/go-mongo/controllers"
|
|
||||||
"github.com/farahty/go-mongo/directives"
|
|
||||||
"github.com/farahty/go-mongo/generated"
|
|
||||||
|
|
||||||
"github.com/farahty/go-mongo/resolvers"
|
"git.farahty.com/nimer/go-mongo/resolvers"
|
||||||
"github.com/go-chi/chi/v5"
|
"github.com/go-chi/chi/v5"
|
||||||
"github.com/go-chi/chi/v5/middleware"
|
"github.com/go-chi/chi/v5/middleware"
|
||||||
"github.com/go-chi/httprate"
|
"github.com/go-chi/httprate"
|
||||||
|
|||||||
@ -4,8 +4,8 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/farahty/go-mongo/app"
|
"git.farahty.com/nimer/go-mongo/app"
|
||||||
"github.com/farahty/go-mongo/models"
|
"git.farahty.com/nimer/go-mongo/models"
|
||||||
"go.mongodb.org/mongo-driver/bson"
|
"go.mongodb.org/mongo-driver/bson"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@ -5,8 +5,8 @@ import (
|
|||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/farahty/go-mongo/app"
|
"git.farahty.com/nimer/go-mongo/app"
|
||||||
"github.com/farahty/go-mongo/models"
|
"git.farahty.com/nimer/go-mongo/models"
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
"go.mongodb.org/mongo-driver/bson"
|
"go.mongodb.org/mongo-driver/bson"
|
||||||
)
|
)
|
||||||
|
|||||||
@ -3,8 +3,8 @@ package categoryService
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/farahty/go-mongo/app"
|
"git.farahty.com/nimer/go-mongo/app"
|
||||||
"github.com/farahty/go-mongo/models"
|
"git.farahty.com/nimer/go-mongo/models"
|
||||||
"github.com/graph-gophers/dataloader"
|
"github.com/graph-gophers/dataloader"
|
||||||
"go.mongodb.org/mongo-driver/bson"
|
"go.mongodb.org/mongo-driver/bson"
|
||||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||||
|
|||||||
@ -3,8 +3,8 @@ package todoService
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/farahty/go-mongo/app"
|
"git.farahty.com/nimer/go-mongo/app"
|
||||||
"github.com/farahty/go-mongo/models"
|
"git.farahty.com/nimer/go-mongo/models"
|
||||||
"github.com/graph-gophers/dataloader"
|
"github.com/graph-gophers/dataloader"
|
||||||
"go.mongodb.org/mongo-driver/bson"
|
"go.mongodb.org/mongo-driver/bson"
|
||||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||||
|
|||||||
@ -3,8 +3,8 @@ package userService
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/farahty/go-mongo/app"
|
"git.farahty.com/nimer/go-mongo/app"
|
||||||
"github.com/farahty/go-mongo/models"
|
"git.farahty.com/nimer/go-mongo/models"
|
||||||
"github.com/graph-gophers/dataloader"
|
"github.com/graph-gophers/dataloader"
|
||||||
"go.mongodb.org/mongo-driver/bson"
|
"go.mongodb.org/mongo-driver/bson"
|
||||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user