# README
Application configurations
Introduction
We use Koanf for managing configurations in our project. Koanf allows us to define default configuration values in the default.go
file. If the necessary environment variables are not found, Koanf will fall back to these default values, ensuring that the application has sensible defaults in place.
Setting up configurations
Server Configuration
-
SERVER_PORT
: The port number where the server listens for incoming requests.- Default:
8080
- Default:
-
SERVER_PRODUCTION
: Indicates the environment in which the application is running (true
for production,false
for development).- Default:
false
- Default:
-
SERVER_READ_TIMEOUT
: Duration for reading requests.- Default:
5s
- Default:
-
SERVER_WRITE_TIMEOUT
: Duration for writing responses.- Default:
10s
- Default:
-
SERVER_GRACEFUL_SHUTDOWN
: Time to wait before forcefully terminating ongoing requests during shutdown.- Default:
30s
- Default:
-
SERVER_DOMAIN
: The domain on which the server is accessible.- Default:
http://localhost:4000
- Default:
OAuth Configuration
Google OAuth
-
OAUTH_GOOGLE_CLIENT_ID
: Client ID for Google OAuth.- Default:
"client-id"
- Default:
-
OAUTH_GOOGLE_CLIENT_SECRET
: Client Secret for Google OAuth.- Default:
"secret"
- Default:
-
OAUTH_GOOGLE_REDIRECT_URL
: URL for redirecting users after successful authentication with Google.- Default:
http://localhost:4000/api/v1/oauth/google/callback
- Default:
-
OAUTH_GOOGLE_SCOPES
: Scopes for Google OAuth permissions.- Default:
"email,profile"
- Default:
Microsoft OAuth
-
OAUTH_MICROSOFT_CLIENT_ID
: Client ID for Microsoft OAuth.- Default:
"client-id"
- Default:
-
OAUTH_MICROSOFT_CLIENT_SECRET
: Client Secret for Microsoft OAuth.- Default:
"secret"
- Default:
-
OAUTH_MICROSOFT_REDIRECT_URL
: URL for redirecting users after successful authentication with Microsoft.- Default:
http://localhost:4000/api/v1/oauth/microsoft/callback
- Default:
-
OAUTH_MICROSOFT_SCOPES
: Scopes for Microsoft OAuth permissions.- Default:
"User.Read,openid"
- Default:
Database Configuration
-
DB_HOST
: Hostname or IP address of the database server.- Default:
localhost
- Default:
-
DB_PORT
: Port number on which the database server is listening.- Default:
5432
- Default:
-
DB_USER
: Username for database authentication.- Default:
root
- Default:
-
DB_PASSWORD
: Password for database authentication.- Default:
root
- Default:
-
DB_NAME
: Name of the database.- Default:
test
- Default:
-
DB_MIGRATIONS
: Whether to apply database migrations automatically on startup.- Default:
false
- Default:
-
DB_LOG_LEVEL
: Log level for database operations.- Default:
2
- Default:
-
DB_POOL_MAX_OPEN
: Maximum number of open connections to the database.- Default:
10
- Default:
-
DB_POOL_MAX_IDLE
: Maximum number of idle connections in the pool.- Default:
5
- Default:
-
DB_POOL_MAX_LIFETIME
: Maximum time a connection may remain open.- Default:
5m
- Default:
JWT Configuration
-
JWT_SECRET
: Secret key for signing and verifying JSON Web Tokens (JWT).- Default:
"secret"
- Default:
-
JWT_ACCESS_TOKEN_EXP
: Expiration time for access tokens.- Default:
900s
(15 minutes)
- Default:
-
JWT_REFRESH_TOKEN_EXP
: Expiration time for refresh tokens.- Default:
604800s
(7 days)
- Default:
Logging Configuration
-
LOGGING_LEVEL
: Verbosity level for logging.- Default:
-1
- Default:
-
LOGGING_ENCODING
: Format of log output.- Default:
console
- Default:
AWS Configuration
-
AWS_REGION
: AWS region for cloud resources.- Default:
eu-west-2
- Default:
-
AWS_SES_FROM_EMAIL
: Default sender email address for AWS Simple Email Service (SES).- Default:
"example.com"
- Default:
Setting Environment Variables
To configure the application, set the environment variables as described above. You can set these variables in your environment or by using a .env
file.
Example using .env
file:
SERVER_PORT=8080
SERVER_PRODUCTION=false
OAUTH_GOOGLE_CLIENT_ID="your-google-client-id"
OAUTH_GOOGLE_CLIENT_SECRET="your-google-client-secret"
DB_HOST="localhost"
DB_PORT=5432
JWT_SECRET="your-secret-key"