Skip to content

Commit

Permalink
Refactored configuration files and added DEBUG_MODE environment variable
Browse files Browse the repository at this point in the history
  • Loading branch information
KostLinux committed Apr 17, 2024
1 parent 7b824a4 commit 9145445
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 10 deletions.
16 changes: 8 additions & 8 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
# APP
APP_PORT=8000
APP_HOST="localhost"
APP_HOST=localhost
DEBUG_MODE=true

# API
API_PATH="/api/v1/"
API_PATH=/api/v1/

# MISC
FORCE_SSL="false"
GO_ENV="development"
FORCE_SSL=false

# External Services

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

POSTGRES_HOST="localhost"
POSTGRES_HOST=localhost
POSTGRES_PORT=5432
POSTGRES_USER="postgres"
POSTGRES_PASSWORD="postgres"
POSTGRES_DB="postgres"
POSTGRES_USER=postgres
POSTGRES_PASSWORD=postgres
POSTGRES_DB=postgres
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
.env
vendor/
vendor/
bin/main
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
_DEFAULT_GOAL := run

include .env

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

run:
go run main.go

Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ Feel free to fork the project and use it as a starting point for your next web a

## Folder structure

- `bin`- Binary folder for the web application. Mostly used for different scripts or when compiling Go code
- `docs` - Web Application documentation
- `handlers` - Controller component (in MVC architecture) folder. Contain the logic for the web application (e.g. API, Error Handling, etc.)
- `handlers/api` - API request and response handling
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func main() {
log.Fatalf("Error loading .env file")
}

if os.Getenv("APP_ENV") == "production" && os.Getenv("DEBUG_MODE") != "true" {
if os.Getenv("DEBUG_MODE") != "true" {
gin.SetMode(gin.ReleaseMode)
}

Expand Down

0 comments on commit 9145445

Please sign in to comment.