Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[REFACTOR] Refactored to MVC Mesh with Layered Architecture. Renamed to GoBlitz #5

Merged
merged 65 commits into from
Apr 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
15ff430
Init 2
Mar 22, 2024
7a4a451
Update readme
Mar 22, 2024
c2529e2
Cringe but forgot the expose port xd
Mar 22, 2024
7b670c1
Updated readme
Mar 22, 2024
4773bdd
Moved to moduled code
Apr 2, 2024
1d89819
Added 502 error handler
Apr 3, 2024
fe95059
Refactored a bit handlers and environment configuration, added html t…
Apr 3, 2024
a4366a5
Refactored code according to review, made code to use envs from model…
Apr 3, 2024
f512127
Moved folders in readme to ``
Apr 3, 2024
b68d55b
Added verify workflow, refactored the PSQLEnabled to be configured vi…
Apr 3, 2024
26899d7
Added README verify workflow
Apr 3, 2024
cdc7725
Little code improvements. Fixed bug with status page where it was alw…
Apr 3, 2024
2e4c1d3
Little code improvements to config
Apr 3, 2024
cddc279
Moved status route to routes
Apr 3, 2024
8c03713
Removed model from handlers.Handlers cause unnecessary
Apr 3, 2024
9d77af1
Merge pull request #1 from KostLinux/feature/refactor-to-moduled-arch…
Apr 4, 2024
9e5305d
Newer architecture with a lot of fixes
Apr 4, 2024
6bac437
Moved handlers to separate package
Apr 4, 2024
3ab55d4
Refactored code, moved postgres envs to config, made architectural pi…
Apr 4, 2024
8f0ef9d
Fixed validation errors, bug in architectural picture
Apr 4, 2024
f7edb98
Updated the readme and architectural drawing
Apr 5, 2024
8b70217
Added warning to readme
Apr 5, 2024
a2bad97
Added benchmarks
Apr 5, 2024
5f3ee02
Added node benchmark also
Apr 5, 2024
a55090b
Fixed laravel benchmark results
Apr 5, 2024
4ac2c99
Added a bit more described folder description
Apr 5, 2024
8ef7c19
Another refactor, moved templates generation out from handlers to tem…
Apr 5, 2024
d20e42a
updated architecture
Apr 5, 2024
128461d
Fixed bug with architectural board
Apr 5, 2024
4794507
Merge pull request #2 from KostLinux/refactor/newer-architecture-with…
Apr 5, 2024
b52d599
Remove config environmentals to improve readability
Apr 17, 2024
4a3674f
Removed config folder, changes architecture and readme
Apr 17, 2024
7b824a4
Added DEBUG_MODE and RELEASE_MODE
Apr 17, 2024
9145445
Refactored configuration files and added DEBUG_MODE environment variable
Apr 17, 2024
c5efc4c
Fixed bug with environmental name
Apr 17, 2024
2b5ec85
Merge pull request #3 from KostLinux/refactor/remove-config-environme…
Apr 17, 2024
0c81afd
Fixed bug with hostHeader for local dev
Apr 19, 2024
9807453
Added issue templates
Apr 19, 2024
dc97a56
Added autoloader and made few fixes
Apr 19, 2024
d5cc1ce
Moved handlers to controller, removed architectural overview, little …
Apr 19, 2024
91712d8
Little fix
Apr 19, 2024
5482e1c
Little update in comment
Apr 19, 2024
738174b
Refactored architectural overview
Apr 19, 2024
5fc48f2
Validation fixes, made tests to run via .env.tests
Apr 19, 2024
7f249df
Merge pull request #4 from KostLinux/feature/add-autoloader-with-some…
Apr 19, 2024
59878c9
Removed unnecessary stuff from workflow
Apr 19, 2024
687700d
Added editorconfig, renamed controllers
Apr 19, 2024
e55b453
change appHost to localHostHeader
Apr 19, 2024
5bc2413
Check 500 instead of 502, 502-503 can come from LB also
Apr 19, 2024
dec3f15
Fix bug of 500 in router
Apr 19, 2024
17e16e9
Changed names of controllers
Apr 19, 2024
bd2a4dd
Changed names of packages
Apr 19, 2024
f2203be
Changed names of error package, changes done in templates
Apr 19, 2024
a4f496b
Fixed bug with templates naming
Apr 19, 2024
2e18c9a
Another packages name change
Apr 19, 2024
91233c5
Fix HTTP 500 title
Apr 19, 2024
d03656b
Updated index.html
Apr 19, 2024
de30591
Added test suite, made changes according to review
KostLinux Apr 22, 2024
b457bad
Refactored back to global DB *sql var
KostLinux Apr 22, 2024
8721658
Made /users endpoint and an example SQL Controller, little naming fix…
KostLinux Apr 22, 2024
2ef4e27
Removed the data folder which was pushed accidentally
KostLinux Apr 22, 2024
073436b
Remove data directory
KostLinux Apr 22, 2024
d2f82a1
Changed model file names
KostLinux Apr 23, 2024
66d56c2
Moved suite above and tests below
KostLinux Apr 23, 2024
3e99a86
Moved the sql logic to repository/db
KostLinux Apr 23, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions .air.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
root = "."
Matrix278 marked this conversation as resolved.
Show resolved Hide resolved
tmp_dir = "/tmp"

[build]
args_bin = []
bin = "/tmp/main"
cmd = "go build -o /tmp/main ."
delay = 1000
exclude_dir = ["assets", "/tmp", "vendor", "public/node_modules"]
exclude_file = []
exclude_regex = ["_test.go"]
exclude_unchanged = false
follow_symlink = false
full_bin = ""
include_dir = []
include_ext = ["go", "tpl", "tmpl", "html", "js", "css", "jsx", "tsx"]
include_file = []
kill_delay = "0s"
log = "build-errors.log"
poll = false
poll_interval = 0
post_cmd = []
pre_cmd = []
rerun = false
rerun_delay = 1
send_interrupt = false
stop_on_error = true

[color]
app = ""
build = "yellow"
main = "magenta"
runner = "green"
watcher = "cyan"

[log]
main_only = false
time = true

[misc]
clean_on_exit = true

[screen]
clear_on_rebuild = false
keep_scroll = true
20 changes: 20 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Top-most EditorConfig file
root = true

# Set the default charset to UTF-8
[*]
charset = utf-8

# Use spaces instead of tabs for indentation
[*.go]
indent_style = space
indent_size = 4

# Trim trailing whitespace
trim_trailing_whitespace = true

# Set the end of line character to LF (Unix-style)
end_of_line = lf

# Ensure a newline at the end of the file
insert_final_newline = true
25 changes: 24 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -1,2 +1,25 @@
# APP
APP_PORT=8000
API_PATH="/api/v1"
APP_HOST=localhost

## Possible values are "development" & "production"
APP_ENV=development

# API
API_PATH=/api/v1/

# MISC
FORCE_TLS=false
DEBUG_MODE=true

# External Services

## PSQL
### To enable PSQL connection, set PSQL_ENABLED true
PSQL_ENABLED=false

POSTGRES_HOST=localhost
POSTGRES_PORT=5432
POSTGRES_USER=postgres
POSTGRES_PASSWORD=postgres
POSTGRES_DB=postgres
33 changes: 33 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
name: Bug report
about: Create a report to help us improve
title: "[BUG] YOUR_TITLE"
labels: bug
assignees: 'KostLinux'

---

**Describe the bug**
A clear and concise description of what the bug is.

**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error

**Expected behavior**
A clear and concise description of what you expected to happen.

**Screenshots**
If applicable, add screenshots to help explain your problem.

**Device (please complete the following information):**
- Device: [e.g. Mac, iPhone]
- OS: [e.g. iOS]
- Browser [e.g. chrome, safari]
- Version [e.g. 22]

**Additional context**
Add any other context about the problem here.
20 changes: 20 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
name: Feature request
about: Suggest an idea for this project
title: "[FEATURE] YOUR_TITLE"
labels: enhancement
assignees: 'KostLinux'

---

**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

**Describe the solution you'd like**
A clear and concise description of what you want to happen.

**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.

**Additional context**
Add any other context or screenshots about the feature request here.
17 changes: 17 additions & 0 deletions .github/ISSUE_TEMPLATE/other.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
name: Other issues template
about: Describe this issue template's purpose here.
title: "[MISC] YOUR_TITLE"
labels: misc
assignees: 'KostLinux'

---

**Describe the problem**
A clear and concise description of what to fix.

**Describe the solution you'd like**
A clear and concise description of what you want to happen.

**Additional context**
Add any other context about the problem here.
8 changes: 8 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
version: 2
updates:
- package-ecosystem: "gomod"
directory: "/"
schedule:
interval: "monthly"
reviewers:
- "KostLinux"
52 changes: 52 additions & 0 deletions .github/workflows/verify.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Verify Code
run-name: Verify code changes
on:
pull_request:
types:
- opened
- synchronize
- edited
- closed

env:
GOPROXY: https://proxy.golang.org

permissions:
contents: read
packages: read
statuses: write
pull-requests: write

jobs:
verify_backend_quality:
name: Verify Backend Code Quality
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: actions/setup-go@v5
with:
go-version: '1.22'

- name: golangci-lint
uses: golangci/golangci-lint-action@v4
with:
version: v1.56.2
working-directory: ./
only-new-issues: false
args: --concurrency=16 --timeout=5m --out-format=github-actions --issues-exit-code=1
skip-cache: false
skip-pkg-cache: true

verify_backend_functional:
name: Verify Backend Functionality
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: actions/setup-go@v5
with:
go-version: '1.22'

- name: Run Go tests
run: go test ./tests/ -p 32
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
.env
.env
vendor/
bin/main
data
57 changes: 57 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
run:
# Default concurrency is an available CPU number
concurrency: 4

# Include test files or not, default is true
tests: true

# Settings of specific linters
linters-settings:
gocyclo:
min-complexity: 20

linters:
# do not use `enable-all`: it's deprecated and will be removed soon.
disable-all: true
enable:
- asasalint
- asciicheck
- bidichk
- bodyclose
- dogsled
- durationcheck
- errcheck
- errchkjson
- execinquery
- exportloopref
- forbidigo
- gocognit
- gocritic
- godox
- gofmt
- gofumpt
- goimports
- goprintffuncname
- gosimple
- govet
- ineffassign
- misspell
- nakedret
- nestif
- nilerr
- nonamedreturns
- prealloc
- predeclared
- revive
- staticcheck
- stylecheck
- tenv
- typecheck
- unconvert
- unparam
- unused
- usestdlibvars
- whitespace

issues:
max-same-issues: 0
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,6 @@ RUN apk add \

RUN go mod download

EXPOSE ${APP_PORT}

CMD [ "go", "run", "main.go" ]
38 changes: 38 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
_DEFAULT_GOAL := air

include .env

air:
@air

build:
go build -o bin/main main.go

run:
go run main.go

fumpt:
gofumpt -w .

mod-vendor:
go mod vendor

linter:
@golangci-lint run

gosec:
@gosec -quiet ./...

test:
@go test ./tests/ -p 32

validate: linter gosec test

migrate-create:
@goose -dir=migrations create "$(name)" sql

migrate-up:
@goose -dir=migrations postgres "host=${POSTGRES_HOST} user=${POSTGRES_USER} password=${POSTGRES_PASSWORD} dbname=${POSTGRES_DB} sslmode=disable" up

migrate-down:
@goose -dir=migrations postgres "host=${POSTGRES_HOST} user=${POSTGRES_USER} password=${POSTGRES_PASSWORD} dbname=${POSTGRES_DB} sslmode=disable" down
Loading