Cloud Foundry
@di-framework/cloudfoundry connects a di-framework application to Cloud Foundry or Tanzu Application Service. It detects the platform environment, parses VCAP_APPLICATION and VCAP_SERVICES, normalizes service credentials into typed models, and makes those models available through dependency injection.
The package configures an application after it starts on the platform. Continue to use your Cloud Foundry manifest and the cf CLI to push and manage the application itself.
Installation
Dependency injection
Enable the connectors on a container, then inject application metadata or a service by its bound name:
@CloudFoundryService accepts a service name, label, regular expression, or typed filter. By default a missing service is an error. Use required: false, defaultValue, or fallbackEnv when the binding is optional or has a local equivalent.
Programmatic discovery
Use CloudFoundryEnvironment when application code needs to inspect the environment directly:
Application metadata includes the application and space identifiers, names, URIs, instance data, and resource limits exposed by VCAP_APPLICATION.
Supported services
The default creator registry recognizes common platform services and returns a normalized model for each category:
Category | Examples | Model |
|---|---|---|
Relational database | PostgreSQL, MySQL, MariaDB, SQLite |
|
Cache | Redis, Redis TLS, Redis cluster |
|
Messaging | RabbitMQ, CloudAMQP |
|
Blob storage | MinIO, Amazon S3, object stores |
|
User-provided service | Services created with |
|
Register a CloudFoundryServiceInfoCreator with getDefaultRegistry() to normalize another service type.
Local fallback
Local fallback is enabled by default when no Cloud Foundry services are present. The environment checks standard variables including DATABASE_URL, REDIS_URL, AMQP_URL, and S3_BUCKET and exposes matching service models. Pass localFallback: false when constructing CloudFoundryEnvironment or enabling the connectors to require platform bindings instead.
Next steps
Deployment - Compare deployment targets
Configuration - Load typed application configuration
Repositories - Connect normalized database credentials to a data layer