-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from Lukmanern/dev/cleanup
Dev/cleanup
- Loading branch information
Showing
74 changed files
with
2,800 additions
and
1,197 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,13 @@ | ||
APP_NAME=Gost - Go Fiber Project Starter | ||
APP_IN_PRODUCTION=false | ||
APP_SECRET_KEY=RandomStringHere1234 | ||
APP_ACCESS_TOKEN_TTL=14320m | ||
APP_PORT=9009 | ||
APP_TIME_ZONE=Asia/Jakarta | ||
|
||
DB_HOST=Host | ||
DB_HOST=db.secret.supabase.co | ||
DB_PORT=5432 | ||
DB_USERNAME=postgres | ||
DB_PASSWORD=Password | ||
DB_PASSWORD=secret | ||
DB_DATABASE=postgres | ||
|
||
REDIS_URI=redis://user:@127.0.0.1:6379/1 | ||
|
@@ -18,6 +17,11 @@ PRIVATE_KEY=./keys/private.key | |
|
||
SMTP_SERVER=smtp.gmail.com | ||
SMTP_PORT=587 | ||
SMTP_EMAIL=[email protected] | ||
SMTP_PASSWORD=passwd | ||
CLIENT_URL=https://important.client | ||
SMTP_EMAIL=[email protected] | ||
SMTP_PASSWORD=secret | ||
CLIENT_URL=https://important.client | ||
|
||
# supabase storage | ||
SUPABASE_BUCKET_NAME=user_upload_public | ||
SUPABASE_URL=https://secret.supabase.co | ||
SUPABASE_TOKEN=SECRET |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
name: Go Build | ||
|
||
on: | ||
push: | ||
branches: | ||
- "*" | ||
- "*/*" | ||
pull_request: | ||
branches: | ||
- "*" | ||
- "*/*" | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
go-version: ["1.19.x", "1.20.x", "1.21.x"] | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Setup Go ${{ matrix.go-version }} | ||
uses: actions/setup-go@v3 | ||
with: | ||
go-version: ${{ matrix.go-version }} | ||
|
||
- name: Display Go version | ||
run: go version | ||
|
||
- name: Verify dependencies | ||
run: go mod verify | ||
|
||
- name: Create Keys Directory | ||
run: mkdir -p keys | ||
working-directory: ${{ github.workspace }} | ||
|
||
- name: Generate Self-Signed TLS Certificate | ||
run: | | ||
openssl req -x509 -newkey rsa:4096 -keyout keys/private.key -out keys/publickey.crt -days 365 -nodes -subj "/CN=localhost" | ||
working-directory: ${{ github.workspace }} | ||
|
||
- name: Show Certificate | ||
run: | | ||
cat keys/publickey.crt | ||
cat keys/private.key | ||
- name: Create .env file | ||
run: echo "${{ secrets.ENV }}" > .env | ||
|
||
- name: Build | ||
run: go build -o main main.go |
10 changes: 7 additions & 3 deletions
10
.github/workflows/snyk.yml → .github/workflows/security.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,10 @@ | ||
.env | ||
.env.test | ||
/log | ||
/keys | ||
cover.out | ||
cover.html | ||
/.cover | ||
/.cover | ||
.dockerignore | ||
docker-compose.yml | ||
Dockerfile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2023 Lukman Ernandi | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,31 @@ | ||
test-clear: | ||
go clean -testcache | ||
|
||
test: | ||
go test -p 1 -timeout 240s -coverprofile=cover.out ./... | ||
|
||
test-per-dir: | ||
go test -p 1 -timeout 120s ./application/... | ||
go test -p 1 -timeout 120s ./controller/... | ||
go test -p 1 -timeout 120s ./database/... | ||
go test -p 1 -timeout 120s ./domain/... | ||
go test -p 1 -timeout 120s ./internal/... | ||
go test -p 1 -timeout 120s ./repository/... | ||
go test -p 1 -timeout 120s ./service/... | ||
go test -p 1 -timeout 120s ./tests/... | ||
|
||
# without ./application and ./tests | ||
# go test -race -timeout 200s ./controller/... ./database/... ./internal/... ./repository/... ./service/... | ||
test-race: | ||
go clean -testcache | ||
go test -race -timeout 120s ./controller/... | ||
go test -race -timeout 120s ./database/... | ||
go test -race -timeout 120s ./domain/... | ||
go test -race -timeout 120s ./internal/... | ||
go test -race -timeout 120s ./repository/... | ||
go test -race -timeout 120s ./service/... | ||
|
||
migrate: | ||
go run database/migration/main.go | ||
|
||
run: | ||
go run . | ||
|
||
test-report: | ||
test-clear: | ||
go clean -testcache | ||
|
||
test: | ||
go clean -testcache | ||
go test -p 1 -timeout 330s -coverprofile=cover.out ./... | ||
go tool cover -html cover.out -o cover.html | ||
del cover.out | ||
|
||
test-race: | ||
go clean -testcache | ||
go test -race -timeout 200s ./controller/... ./database/... ./internal/... ./repository/... ./service/... | ||
|
||
migrate-test-report: | ||
go run database/migration/main.go | ||
timeout 5 | ||
go test -p 1 -timeout 240s -coverprofile=cover.out ./... | ||
go clean -testcache | ||
go test -race -timeout 200s ./controller/... ./database/... ./internal/... ./repository/... ./service/... | ||
go test -p 1 -timeout 330s -coverprofile=cover.out ./... | ||
go tool cover -html cover.out -o cover.html | ||
del cover.out | ||
|
||
# !!windows only!! run redis in background | ||
# windowsOS only | ||
st-redis: | ||
redis-server.exe --service-start |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,42 @@ | ||
## Gost Project | ||
<h1 align="center">Gost: Go Starter</h1> | ||
|
||
Go-Fiber project starter, with jwt-auth and highly effective RBAC implementation. | ||
<br> | ||
|
||
Golang project starter with Fiber Framework, jwt-auth and highly effective bit-manipulation RBAC implementation to build a robust RestAPI Application. | ||
|
||
  | ||
|
||
## :rocket: Technologies And :wrench: Tools | ||
|
||
Techs and tools were used in this project: | ||
|
||
- [Go](https://go.dev) | ||
- [Fiber Framework](https://docs.gofiber.io/) → Framework for routing & HTTP handler. | ||
- [GORM](https://gorm.io/) → Database logics & queries. | ||
- [Supabase Services: PostgreSQL & Bucket](https://www.supabase.com) → Free database & storage (bucket). | ||
- [Github CLI](https://cli.github.com/) → Github management for repository's secrets & etc. | ||
- [Github Action](https://github.com/features/actions) → Automated testing and building across multiple versions of Go. | ||
- [Snyk](https://app.snyk.io/) → Dependency scanning. | ||
- [SonarLint, VSCode ext.](https://marketplace.visualstudio.com/items?itemName=SonarSource.sonarlint-vscode) → Detects & highlights issues that can lead to bugs & vulnerabilities. | ||
- [GoLint](https://github.com/golang/lint) → CLI static code analytic for code-styling & many more. | ||
|
||
  | ||
|
||
## :closed_book: Read List | ||
|
||
- [Database Connection Configuration](https://www.alexedwards.net/blog/configuring-sqldb) | ||
- [Go-Fiber Testing](https://dev.to/koddr/go-fiber-by-examples-testing-the-application-1ldf) | ||
- [Production Checklist 1](https://aleksei-kornev.medium.com/production-readiness-checklist-for-backend-applications-8d2b0c57ccec/) | ||
- [Production Checklist 2](https://github.com/gorrion-io/production-readiness-checklist/) | ||
- [Production Checklist 3](https://www.cockroachlabs.com/docs/cockroachcloud/production-checklist/) | ||
- [Deployment Checklist](https://last9.io/blog/deployment-readiness-checklists/) | ||
- [CI with Github Actions](https://www.alexedwards.net/blog/ci-with-go-and-github-actions) | ||
- [RestAPI Security Checklist](https://roadmap.sh/best-practices/api-security/) | ||
|
||
  | ||
|
||
## :memo: License | ||
|
||
This project is under license from MIT. For more details, see the [LICENSE](LICENSE) file. | ||
|
||
  |
Oops, something went wrong.