UNPKG

1.82 kBTypeScriptView Raw
1import { Destination } from './destination-service-types';
2/**
3 * Tries to build a destination from a service binding with the given name.
4 * Throws an error if no services are bound at all, no service with the given name can be found, or the service type is not supported.
5 * The last error can be circumvent by using the second parameter to provide a custom function that transforms a service binding to a destination.
6 * @param serviceInstanceName - The name of the service.
7 * @param options - Options to customize the behavior of this function.
8 * @returns A destination.
9 */
10export declare function destinationForServiceBinding(serviceInstanceName: string, options?: DestinationForServiceBindingsOptions): Destination;
11/**
12 * Options to customize the behavior of [[destinationForServiceBinding]].
13 */
14export interface DestinationForServiceBindingsOptions {
15 /**
16 * Custom transformation function to control how a [[Destination]] is built from the given [[ServiceBinding]].
17 */
18 transformationFn?: (serviceBinding: ServiceBinding) => Destination;
19}
20/**
21 * Represents the JSON object for a given service binding as obtained from the VCAP_SERVICE environment variable.
22 * To see service bindings, run `cf env <app-name>` in the terminal. This will produce output like this:
23 *
24 * ```
25 * {
26 * ...
27 * "VCAP_SERVICES": {
28 * "s4-hana-cloud": [
29 * {
30 * "name": "...",
31 * "type": "...".
32 * ...
33 * }
34 * ]
35 * }
36 * }
37 *
38 * ```
39 *
40 * In this example, the key "s4-hana-cloud" refers to an array of service bindings.
41 */
42export interface ServiceBinding {
43 [key: string]: any;
44 name: string;
45 type: string;
46}
47export declare function searchServiceBindingForDestination(name: string): Destination | undefined;
48//# sourceMappingURL=destination-from-vcap.d.ts.map
\No newline at end of file