@chittyos/config
v1.0.1
Published
Service configuration and URL management for ChittyOS Framework
Maintainers
Readme
@chittyos/config
Service configuration and URL management for ChittyOS Framework.
Installation
npm install @chittyos/configUsage
Load ChittyOS Configuration
import { loadChittyOSConfig } from '@chittyos/config';
// Load production configuration
const config = loadChittyOSConfig({ environment: 'production' });
console.log(config.services.chittyid); // https://id.chitty.cc
console.log(config.services.chittyauth); // https://auth.chitty.cc
console.log(config.environment); // 'production'Environment-Specific Configuration
import { loadChittyOSConfig } from '@chittyos/config';
// Development environment
const devConfig = loadChittyOSConfig({ environment: 'development' });
console.log(devConfig.services.chittyid); // https://dev-id.chitty.cc
// Staging environment
const stagingConfig = loadChittyOSConfig({ environment: 'staging' });
console.log(stagingConfig.services.chittyid); // https://staging-id.chitty.cc
// Local development with localhost URLs
const localConfig = loadChittyOSConfig({
environment: 'development',
localDev: true
});
console.log(localConfig.services.chittyid); // http://localhost:8701Get Individual Service URLs
import { getServiceURL } from '@chittyos/config';
// Get service URL for current environment
const chittyidURL = getServiceURL('chittyid');
// Get service URL with custom config
const authURL = getServiceURL('chittyauth', {
environment: 'staging'
});Custom Service URLs
import { loadChittyOSConfig } from '@chittyos/config';
// Override specific service URL
const config = loadChittyOSConfig({
services: {
chittyid: 'https://my-custom-id.example.com',
},
});
// Override with environment-specific URLs
const config2 = loadChittyOSConfig({
services: {
chittyid: {
production: 'https://prod-id.example.com',
staging: 'https://stage-id.example.com',
development: 'https://dev-id.example.com',
local: 'http://localhost:9000',
},
},
});Service Configuration Objects
import { createServiceConfig } from '@chittyos/config';
// Create service configuration
const serviceConfig = createServiceConfig('chittyid');
console.log(serviceConfig);
// {
// name: 'chittyid',
// baseURL: 'https://id.chitty.cc',
// healthEndpoint: 'https://id.chitty.cc/health',
// version: '1.0.0',
// environment: 'production'
// }Service Validation
import { validateServiceURL, validateAllServices } from '@chittyos/config';
// Validate single service URL
const isValid = await validateServiceURL('https://id.chitty.cc');
console.log(isValid); // true if service is reachable
// Validate all configured services
const results = await validateAllServices();
console.log(results);
// {
// chittyid: true,
// chittyauth: true,
// chittyschema: false,
// ...
// }Configuration Presets
import { configPresets } from '@chittyos/config';
// Production configuration
const prodConfig = configPresets.production();
// Staging configuration
const stagingConfig = configPresets.staging();
// Development configuration
const devConfig = configPresets.development();
// Local development (localhost URLs)
const localConfig = configPresets.local();
// Minimal configuration (ChittyID only)
const minimalConfig = configPresets.minimal();
console.log(minimalConfig.services); // { chittyid: 'https://id.chitty.cc' }Service Discovery
import {
isServiceConfigured,
getConfiguredServices
} from '@chittyos/config';
// Check if service is configured
if (isServiceConfigured('chittyid')) {
console.log('ChittyID service is configured');
}
// Get all configured services
const services = getConfiguredServices();
console.log(services); // ['chittyid', 'chittyauth', 'chittyschema', ...]ChittyOS Services
| Service | Production URL | Default Port |
|---------|---------------|--------------|
| chittyid | https://id.chitty.cc | 8701 |
| chittyauth | https://auth.chitty.cc | 8702 |
| chittyschema | https://schema.chitty.cc | 8703 |
| chittyrouter | https://router.chitty.cc | 8704 |
| chittychat | https://chat.chitty.cc | 8705 |
| chittyregistry | https://registry.chitty.cc | 8706 |
| chittycanon | https://canon.chitty.cc | 8707 |
| chittygateway | https://gateway.chitty.cc | 8708 |
| chittysync | https://sync.chitty.cc | 8709 |
| chittyverify | https://verify.chitty.cc | 8710 |
Environment Variables
Override service URLs with environment variables:
# Override ChittyID service URL
CHITTYID_SERVICE=https://custom-id.example.com
# Override ChittyAuth service URL
CHITTYAUTH_SERVICE=https://custom-auth.example.com
# Override ChittySchema service URL
CHITTYSCHEMA_SERVICE=https://custom-schema.example.com
# Override Registry service URL
REGISTRY_SERVICE=https://custom-registry.example.com
# Override Gateway service URL
GATEWAY_SERVICE=https://custom-gateway.example.comConfiguration Priority
Service URLs are resolved in the following order (highest priority first):
- Custom URL override - Explicitly passed in
servicesconfig - Environment variable -
CHITTYID_SERVICE,CHITTYAUTH_SERVICE, etc. - Default URLs - Built-in environment-specific defaults
Advanced Configuration
Fallback to Production
import { loadChittyOSConfig } from '@chittyos/config';
// Disable fallback to production URLs
const config = loadChittyOSConfig({
environment: 'staging',
fallbackToProduction: false, // Throw error if staging URL missing
});Service Health Check
import { validateServiceURL } from '@chittyos/config';
// Custom timeout (default: 5000ms)
const isValid = await validateServiceURL(
'https://id.chitty.cc',
3000 // 3 second timeout
);Features
- ✅ Environment-aware configuration (dev/staging/production)
- ✅ Local development mode with localhost URLs
- ✅ Environment variable overrides
- ✅ Custom service URL configuration
- ✅ Service validation and health checks
- ✅ Configuration presets for common scenarios
- ✅ Service discovery utilities
- ✅ Type-safe service identifiers
- ✅ Zero runtime dependencies (except @chittyos/types and @chittyos/env)
Package Size
~28KB (gzipped)
License
MIT
