Skip to content

Commit

Permalink
Merge pull request #16 from oleksandrkhmil/feature/refactor-structure
Browse files Browse the repository at this point in the history
Feature/refactor structure
  • Loading branch information
oleksandrkhmil authored Dec 6, 2024
2 parents 1095ffe + 0275b04 commit 8b4e641
Show file tree
Hide file tree
Showing 38 changed files with 79 additions and 75 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
- name: Setup Swagger
run: |
go install github.com/swaggo/swag/cmd/swag@0b9e347c196710ea155a147782bf51707a600c2c # https://github.com/swaggo/swag/releases/tag/v1.16.4
swag init -g cmd/main.go
swag init -g cmd/service/main.go
- uses: golangci/golangci-lint-action@971e284b6050e8a5849b72094c50ab08da042db8 # https://github.com/golangci/golangci-lint-action/releases/tag/v6.1.1
with:
version: v1.61
Expand All @@ -41,7 +41,7 @@ jobs:
- name: Setup Swagger
run: |
go install github.com/swaggo/swag/cmd/swag@0b9e347c196710ea155a147782bf51707a600c2c # https://github.com/swaggo/swag/releases/tag/v1.16.4
swag init -g cmd/main.go
swag init -g cmd/service/main.go
- name: Run tests
run: go test -race ./...

Expand Down Expand Up @@ -70,7 +70,7 @@ jobs:
- name: Setup Swagger
run: |
go install github.com/swaggo/swag/cmd/swag@0b9e347c196710ea155a147782bf51707a600c2c # https://github.com/swaggo/swag/releases/tag/v1.16.4
swag init -g cmd/main.go
swag init -g cmd/service/main.go
- name: Run govulncheck
run: |
go install golang.org/x/vuln/cmd/govulncheck@4ea4418106cea3bb2c9aa098527c924e9e1fbbb4 # https://go.googlesource.com/vuln/+/refs/tags/v1.1.3
Expand Down
6 changes: 3 additions & 3 deletions app.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package application

import (
"echo-demo-project/config"
"echo-demo-project/server"
"echo-demo-project/server/routes"
"echo-demo-project/internal/config"
"echo-demo-project/internal/server"
"echo-demo-project/internal/server/routes"
"log"
)

Expand Down
2 changes: 1 addition & 1 deletion cmd/main.go → cmd/service/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package main

import (
application "echo-demo-project"
"echo-demo-project/config"
"echo-demo-project/internal/config"
"echo-demo-project/docs"
"fmt"
)
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions db/connection.go → internal/db/connection.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package db

import (
"echo-demo-project/config"
"echo-demo-project/db/seeders"
"echo-demo-project/internal/config"
"echo-demo-project/internal/db/seeders"
"fmt"

"gorm.io/driver/mysql"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package seeders

import (
"echo-demo-project/models"
"echo-demo-project/internal/models"

"gorm.io/gorm"
)
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package repositories

import (
"echo-demo-project/models"
"echo-demo-project/internal/models"

"gorm.io/gorm"
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package repositories

import (
"echo-demo-project/models"
"echo-demo-project/internal/models"

"gorm.io/gorm"
)
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package responses

import (
"echo-demo-project/models"
"echo-demo-project/internal/models"
)

type PostResponse struct {
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package builders

import "echo-demo-project/models"
import "echo-demo-project/internal/models"

type UserBuilder struct {
email string
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package handlers

import (
"echo-demo-project/models"
"echo-demo-project/repositories"
"echo-demo-project/requests"
"echo-demo-project/responses"
s "echo-demo-project/server"
tokenservice "echo-demo-project/services/token"
"echo-demo-project/internal/models"
"echo-demo-project/internal/repositories"
"echo-demo-project/internal/requests"
"echo-demo-project/internal/responses"
s "echo-demo-project/internal/server"
tokenservice "echo-demo-project/internal/services/token"
"fmt"
"net/http"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package handlers

import (
"echo-demo-project/models"
"echo-demo-project/repositories"
"echo-demo-project/requests"
"echo-demo-project/responses"
s "echo-demo-project/server"
postservice "echo-demo-project/services/post"
"echo-demo-project/services/token"
"echo-demo-project/internal/models"
"echo-demo-project/internal/repositories"
"echo-demo-project/internal/requests"
"echo-demo-project/internal/responses"
s "echo-demo-project/internal/server"
postservice "echo-demo-project/internal/services/post"
"echo-demo-project/internal/services/token"
"net/http"
"strconv"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package handlers

import (
"echo-demo-project/models"
"echo-demo-project/repositories"
"echo-demo-project/requests"
"echo-demo-project/responses"
s "echo-demo-project/server"
"echo-demo-project/services/user"
"echo-demo-project/internal/models"
"echo-demo-project/internal/repositories"
"echo-demo-project/internal/requests"
"echo-demo-project/internal/responses"
s "echo-demo-project/internal/server"
"echo-demo-project/internal/services/user"
"net/http"

"github.com/labstack/echo/v4"
Expand Down
6 changes: 3 additions & 3 deletions server/routes/routes.go → internal/server/routes/routes.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package routes

import (
s "echo-demo-project/server"
"echo-demo-project/server/handlers"
"echo-demo-project/services/token"
s "echo-demo-project/internal/server"
"echo-demo-project/internal/server/handlers"
"echo-demo-project/internal/services/token"
"fmt"

"github.com/golang-jwt/jwt/v5"
Expand Down
4 changes: 2 additions & 2 deletions server/server.go → internal/server/server.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package server

import (
"echo-demo-project/config"
"echo-demo-project/db"
"echo-demo-project/internal/config"
"echo-demo-project/internal/db"

"github.com/labstack/echo/v4"
"gorm.io/gorm"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package post

import "echo-demo-project/models"
import "echo-demo-project/internal/models"

func (postService *Service) Create(post *models.Post) {
postService.DB.Create(post)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package post

import "echo-demo-project/models"
import "echo-demo-project/internal/models"

func (postService *Service) Delete(post *models.Post) {
postService.DB.Delete(post)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package post

import (
"echo-demo-project/models"
"echo-demo-project/requests"
"echo-demo-project/internal/models"
"echo-demo-project/internal/requests"

"gorm.io/gorm"
)
Expand Down
4 changes: 2 additions & 2 deletions services/post/update.go → internal/services/post/update.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package post

import (
"echo-demo-project/models"
"echo-demo-project/requests"
"echo-demo-project/internal/models"
"echo-demo-project/internal/requests"
)

func (postService *Service) Update(post *models.Post, updatePostRequest *requests.UpdatePostRequest) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package token

import (
"echo-demo-project/models"
"echo-demo-project/internal/models"
"time"

"github.com/golang-jwt/jwt/v5"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package token

import (
"echo-demo-project/models"
"echo-demo-project/internal/models"
"time"

"github.com/golang-jwt/jwt/v5"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package token

import (
"echo-demo-project/config"
"echo-demo-project/models"
"echo-demo-project/internal/config"
"echo-demo-project/internal/models"

"github.com/golang-jwt/jwt/v5"
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package user

import (
"echo-demo-project/requests"
"echo-demo-project/server/builders"
"echo-demo-project/internal/requests"
"echo-demo-project/internal/server/builders"

"golang.org/x/crypto/bcrypt"
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package user

import (
"echo-demo-project/requests"
"echo-demo-project/internal/requests"

"gorm.io/gorm"
)
Expand Down
21 changes: 11 additions & 10 deletions tests/auth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,26 @@ package tests

import (
"database/sql/driver"
"echo-demo-project/config"
"echo-demo-project/models"
"echo-demo-project/requests"
"echo-demo-project/responses"
"echo-demo-project/server"
"echo-demo-project/server/handlers"
"echo-demo-project/services/token"
"echo-demo-project/internal/config"
"echo-demo-project/internal/models"
"echo-demo-project/internal/requests"
"echo-demo-project/internal/responses"
"echo-demo-project/internal/server"
"echo-demo-project/internal/server/handlers"
"echo-demo-project/internal/services/token"
"echo-demo-project/tests/helpers"
"encoding/json"
"errors"
"fmt"
"net/http"
"net/http/httptest"
"testing"

"github.com/DATA-DOG/go-sqlmock"
"github.com/golang-jwt/jwt/v5"
"github.com/labstack/echo/v4"
"github.com/stretchr/testify/assert"
"golang.org/x/crypto/bcrypt"
"net/http"
"net/http/httptest"
"testing"
)

func TestWalkAuth(t *testing.T) {
Expand Down
5 changes: 3 additions & 2 deletions tests/helpers/server.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package helpers

import (
"echo-demo-project/config"
"echo-demo-project/server"
"echo-demo-project/internal/config"
"echo-demo-project/internal/server"

"github.com/labstack/echo/v4"
"gorm.io/gorm"
)
Expand Down
2 changes: 1 addition & 1 deletion tests/helpers/test_case.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package helpers

import (
"database/sql/driver"
"echo-demo-project/server"
"echo-demo-project/internal/server"
"encoding/json"
"github.com/DATA-DOG/go-sqlmock"
"github.com/labstack/echo/v4"
Expand Down
13 changes: 7 additions & 6 deletions tests/post_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,18 @@ package tests

import (
"database/sql/driver"
"echo-demo-project/requests"
"echo-demo-project/server"
"echo-demo-project/server/handlers"
"echo-demo-project/services/token"
"echo-demo-project/internal/requests"
"echo-demo-project/internal/server"
"echo-demo-project/internal/server/handlers"
"echo-demo-project/internal/services/token"
"echo-demo-project/tests/helpers"
"net/http"
"testing"

"github.com/DATA-DOG/go-sqlmock"
"github.com/golang-jwt/jwt/v5"
"github.com/labstack/echo/v4"
"github.com/stretchr/testify/assert"
"net/http"
"testing"
)

const postId = "1"
Expand Down
11 changes: 6 additions & 5 deletions tests/register_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@ package tests

import (
"database/sql/driver"
"echo-demo-project/requests"
"echo-demo-project/server"
"echo-demo-project/server/handlers"
"echo-demo-project/internal/requests"
"echo-demo-project/internal/server"
"echo-demo-project/internal/server/handlers"
"echo-demo-project/tests/helpers"
"net/http"
"testing"

"github.com/DATA-DOG/go-sqlmock"
"github.com/labstack/echo/v4"
"github.com/stretchr/testify/assert"
"net/http"
"testing"
)

func TestWalkRegister(t *testing.T) {
Expand Down

0 comments on commit 8b4e641

Please sign in to comment.