Init world. Basic registry API server

Work in progress .
This commit adds the core registry service implementation with methods to:
- Retrieve all registry entries
- List entries with cursor-based pagination
- Fetch specific server details by ID
This commit is contained in:
Avinash Sridhar 2025-04-22 17:09:44 -04:00
commit 4fb5bc477e
No known key found for this signature in database

56
internal/config/config.go Normal file
View file

@ -0,0 +1,56 @@
package config
import "os"
// Config holds the application configuration
type Config struct {
ServerAddress string
DatabaseURL string
DatabaseName string
CollectionName string
LogLevel string
Environment string // Added environment field
Version string // Application version
}
// NewConfig creates a new configuration with default values
func NewConfig() *Config {
// Get environment from OS environment variable or default to "production"
env := os.Getenv("APP_ENV")
if env == "" {
env = "production"
}
// Get version from environment variable or default to "dev"
version := os.Getenv("APP_VERSION")
if version == "" {
version = "dev"
}
// Get database URL from environment variable or default to localhost
dbURL := os.Getenv("DATABASE_URL")
if dbURL == "" {
dbURL = "localhost:5432"
}
// Get database name from environment variable or default to "mcp_registry"
dbName := os.Getenv("DATABASE_NAME")
if dbName == "" {
dbName = "mcp-registry"
}
// Get collection name from environment variable or default to "entries"
collectionName := os.Getenv("COLLECTION_NAME")
if collectionName == "" {
collectionName = "servers_v2"
}
return &Config{
ServerAddress: ":8080",
DatabaseURL: dbURL,
DatabaseName: dbName,
CollectionName: collectionName,
LogLevel: "info",
Environment: env,
Version: version,
}
}