Add configuration file and update server settings
- Introduced a new `config.yaml` file for managing server, database, cache, queue, AI, scraping, logging, and rate limiting configurations. - Updated `docker-compose.yml` to reflect the new server port (8081) and adjusted health check endpoints accordingly. - Modified `Dockerfile` to expose the new server port. - Updated `README.md` to reflect changes in server configuration and added documentation for the new configuration structure. - Added test scripts for server and Swagger documentation testing. - Refactored customer domain structure to align with new configuration settings and improve maintainability.
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
package customer
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/asaskevich/govalidator"
|
||||
)
|
||||
|
||||
// init registers custom validators
|
||||
func init() {
|
||||
// Register custom validators
|
||||
govalidator.CustomTypeTagMap.Set("unix_timestamp", govalidator.CustomTypeValidator(func(i interface{}, context interface{}) bool {
|
||||
switch v := i.(type) {
|
||||
case int64:
|
||||
// Check if timestamp is reasonable (not too old, not in the future)
|
||||
now := time.Now().Unix()
|
||||
minTimestamp := now - (100 * 365 * 24 * 60 * 60) // 100 years ago
|
||||
maxTimestamp := now + (10 * 365 * 24 * 60 * 60) // 10 years in future
|
||||
return v >= minTimestamp && v <= maxTimestamp
|
||||
case *int64:
|
||||
if v == nil {
|
||||
return true // nil is valid for optional fields
|
||||
}
|
||||
now := time.Now().Unix()
|
||||
minTimestamp := now - (100 * 365 * 24 * 60 * 60) // 100 years ago
|
||||
maxTimestamp := now + (10 * 365 * 24 * 60 * 60) // 10 years in future
|
||||
return *v >= minTimestamp && *v <= maxTimestamp
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}))
|
||||
}
|
||||
Reference in New Issue
Block a user