Skip to content

Commit

Permalink
Merge pull request #31 from NikhilSharma03/project_restructure
Browse files Browse the repository at this point in the history
refactor: project restructure
  • Loading branch information
NikhilSharma03 authored Dec 25, 2023
2 parents 8ed0234 + e3ae1ac commit 7d32aaa
Show file tree
Hide file tree
Showing 35 changed files with 327 additions and 270 deletions.
31 changes: 15 additions & 16 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
# gen-protobuf generates .pb.go for protobuf files
gen-protobuf:
protoc -I ./server/api \
--go_out ./server/pkg --go_opt paths=source_relative \
--go-grpc_out ./server/pkg --go-grpc_opt paths=source_relative \
--grpc-gateway_out ./server/pkg --grpc-gateway_opt paths=source_relative \
./server/api/protobuf/*.proto ./server/api/google/api/*.proto ./server/api/google/type/*.proto
.PHONY: generate-proto-protoc
generate-proto-protoc:
protoc -I ./api \
--go_out ./pkg --go_opt paths=source_relative \
--go-grpc_out ./pkg --go-grpc_opt paths=source_relative \
--grpc-gateway_out ./pkg --grpc-gateway_opt paths=source_relative \
./api/protobuf/*.proto ./api/google/api/*.proto ./api/google/type/*.proto

.PHONY: generate-proto
generate-proto:
buf generate api

# clean-protobuf removes generated .pb.go files
clean-protobuf:
rm -rf server/pkg/protobuf
.PHONY: clean-proto
clean-proto:
rm -rf pkg/protobuf pkg/google

# run-server starts the grpc server
.PHONY: run-server
run-server:
go run server/cmd/main.go

# build-cli builds the cli app
build-cli:
cd cli; go build -o okane
go run cmd/main.go
7 changes: 7 additions & 0 deletions api/buf.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
version: v1
breaking:
use:
- FILE
lint:
use:
- DEFAULT
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ option objc_class_prefix = "GAPI";
extend google.protobuf.MethodOptions {
// See `HttpRule`.
HttpRule http = 72295728;
}
}
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ syntax = "proto3";

package okanepb;

option go_package = "github.com/NikhilSharma03/Okane/server/api/protobuf/okane;okanepb";
option go_package = "github.com/NikhilSharma03/Okane/api/protobuf/okane;okanepb";

import "google/type/money.proto";
import "google/api/annotations.proto";
Expand Down
15 changes: 15 additions & 0 deletions buf.gen.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
version: v1
plugins:
- plugin: go
out: pkg
opt:
- paths=source_relative
- plugin: go-grpc
out: pkg
opt:
- paths=source_relative
- plugin: grpc-gateway
out: pkg
opt:
- paths=source_relative
- generate_unbound_methods=true
4 changes: 4 additions & 0 deletions buf.work.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
version: v1
directories:
- api

8 changes: 4 additions & 4 deletions server/cmd/main.go → cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import (
"os"
"strconv"

"github.com/NikhilSharma03/Okane/server/internal/app"
"github.com/NikhilSharma03/Okane/server/internal/repository"
"github.com/NikhilSharma03/Okane/server/internal/service"
okanepb "github.com/NikhilSharma03/Okane/server/pkg/protobuf"
"github.com/NikhilSharma03/Okane/internal/app"
"github.com/NikhilSharma03/Okane/internal/repository"
"github.com/NikhilSharma03/Okane/internal/service"
okanepb "github.com/NikhilSharma03/Okane/pkg/protobuf"
"github.com/grpc-ecosystem/grpc-gateway/v2/runtime"
"github.com/joho/godotenv"
"google.golang.org/grpc"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"context"
"fmt"

"github.com/NikhilSharma03/Okane/server/internal/datastruct"
okanepb "github.com/NikhilSharma03/Okane/server/pkg/protobuf"
"github.com/NikhilSharma03/Okane/internal/datastruct"
okanepb "github.com/NikhilSharma03/Okane/pkg/protobuf"
"google.golang.org/genproto/googleapis/type/money"
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"context"
"fmt"

okanepb "github.com/NikhilSharma03/Okane/server/pkg/protobuf"
okanepb "github.com/NikhilSharma03/Okane/pkg/protobuf"
"google.golang.org/genproto/googleapis/type/money"
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"context"
"fmt"

okanepb "github.com/NikhilSharma03/Okane/server/pkg/protobuf"
okanepb "github.com/NikhilSharma03/Okane/pkg/protobuf"
)

// Delete Expense deletes the expense by the provided expense id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"context"
"fmt"

okanepb "github.com/NikhilSharma03/Okane/server/pkg/protobuf"
okanepb "github.com/NikhilSharma03/Okane/pkg/protobuf"
"google.golang.org/genproto/googleapis/type/money"
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"context"
"fmt"

okanepb "github.com/NikhilSharma03/Okane/server/pkg/protobuf"
okanepb "github.com/NikhilSharma03/Okane/pkg/protobuf"
"google.golang.org/genproto/googleapis/type/money"
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"context"
"fmt"

okanepb "github.com/NikhilSharma03/Okane/server/pkg/protobuf"
okanepb "github.com/NikhilSharma03/Okane/pkg/protobuf"
"google.golang.org/genproto/googleapis/type/money"
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"context"
"fmt"

okanepb "github.com/NikhilSharma03/Okane/server/pkg/protobuf"
okanepb "github.com/NikhilSharma03/Okane/pkg/protobuf"
"google.golang.org/genproto/googleapis/type/money"
)

Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions server/internal/app/service.go → internal/app/service.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package app

import (
"github.com/NikhilSharma03/Okane/server/internal/service"
okanepb "github.com/NikhilSharma03/Okane/server/pkg/protobuf"
"github.com/NikhilSharma03/Okane/internal/service"
okanepb "github.com/NikhilSharma03/Okane/pkg/protobuf"
)

// The UserService implements handler of okanepb.UserService
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"context"
"fmt"

"github.com/NikhilSharma03/Okane/server/internal/datastruct"
okanepb "github.com/NikhilSharma03/Okane/server/pkg/protobuf"
"github.com/NikhilSharma03/Okane/internal/datastruct"
okanepb "github.com/NikhilSharma03/Okane/pkg/protobuf"
"google.golang.org/genproto/googleapis/type/money"
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"context"
"fmt"

okanepb "github.com/NikhilSharma03/Okane/server/pkg/protobuf"
okanepb "github.com/NikhilSharma03/Okane/pkg/protobuf"
"google.golang.org/genproto/googleapis/type/money"
)

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"fmt"
"time"

"github.com/NikhilSharma03/Okane/server/internal/datastruct"
"github.com/NikhilSharma03/Okane/internal/datastruct"
"github.com/go-redis/redis/v8"
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"context"
"fmt"

"github.com/NikhilSharma03/Okane/server/internal/datastruct"
"github.com/NikhilSharma03/Okane/server/internal/utils"
"github.com/NikhilSharma03/Okane/internal/datastruct"
"github.com/NikhilSharma03/Okane/internal/utils"
"github.com/go-redis/redis/v8"
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import (
"strconv"
"strings"

"github.com/NikhilSharma03/Okane/server/internal/datastruct"
"github.com/NikhilSharma03/Okane/server/internal/repository"
"github.com/NikhilSharma03/Okane/server/internal/utils"
"github.com/NikhilSharma03/Okane/internal/datastruct"
"github.com/NikhilSharma03/Okane/internal/repository"
"github.com/NikhilSharma03/Okane/internal/utils"
"github.com/google/uuid"
)

Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions server/internal/service/user.go → internal/service/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"fmt"
"log"

"github.com/NikhilSharma03/Okane/server/internal/datastruct"
"github.com/NikhilSharma03/Okane/server/internal/repository"
"github.com/NikhilSharma03/Okane/internal/datastruct"
"github.com/NikhilSharma03/Okane/internal/repository"
"github.com/google/uuid"
"golang.org/x/crypto/bcrypt"
)
Expand Down
File renamed without changes.

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

Loading

0 comments on commit 7d32aaa

Please sign in to comment.