{"id":16190871,"url":"https://github.com/vobu/sap-cf-destination","last_synced_at":"2025-07-28T02:08:10.147Z","repository":{"id":53364211,"uuid":"158580388","full_name":"vobu/sap-cf-destination","owner":"vobu","description":"convenience module for querying a destination via a connectivity instance on SAP BTP Cloud Foundry","archived":false,"fork":false,"pushed_at":"2021-12-28T09:27:40.000Z","size":320,"stargazers_count":12,"open_issues_count":1,"forks_count":5,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-28T13:52:02.532Z","etag":null,"topics":["cloudfoundry","connectivity","destination","nodejs","proxy","sap"],"latest_commit_sha":null,"homepage":"https://blogs.sap.com/2018/11/21/scp-cloud-foundry-destinations-demystified/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vobu.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-11-21T16:57:24.000Z","updated_at":"2021-12-28T09:27:42.000Z","dependencies_parsed_at":"2022-09-11T04:40:26.948Z","dependency_job_id":null,"html_url":"https://github.com/vobu/sap-cf-destination","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"purl":"pkg:github/vobu/sap-cf-destination","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vobu%2Fsap-cf-destination","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vobu%2Fsap-cf-destination/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vobu%2Fsap-cf-destination/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vobu%2Fsap-cf-destination/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vobu","download_url":"https://codeload.github.com/vobu/sap-cf-destination/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vobu%2Fsap-cf-destination/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267451489,"owners_count":24089312,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-28T02:00:09.689Z","response_time":68,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cloudfoundry","connectivity","destination","nodejs","proxy","sap"],"created_at":"2024-10-10T07:44:21.281Z","updated_at":"2025-07-28T02:08:10.113Z","avatar_url":"https://github.com/vobu.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SAP BTP Cloud Foundry destination handler\n[![Build Status](https://travis-ci.com/vobu/sap-cf-destination.svg?branch=master)](https://travis-ci.com/vobu/sap-cf-destination) \n[![npm Package](https://img.shields.io/npm/v/sap-cf-destination.svg)](https://www.npmjs.com/package/sap-cf-destination)\n\n## Install\n~~~\nnpm install --save sap-cf-destination\n~~~\n\n## Prerequisites\n- `destination` and `destination` instance created\n- `connectivity` instance created\n- `xsuaa` instance created\n- all of the above instances bound to the node app, e.g. via `manifest.yml`:\n  ~~~ yaml\n  applications:\n  - name: my_app\n    path: my_app\n    memory: 128M\n    services:\n      - xsuaa-instance\n      - connectivity-instance\n      - destination-instance\n  ~~~  \n\n## Usage\n~~~ javascript\nconst callDestination = require('sap-cf-destination');\n\n// Promise chain\ncallDestination({\n        url: '/api/json',\n        connectivity_instance: 'connectivity-lite',\n        uaa_instance: 'uaa-lite',\n        destination_instance: 'destination-lite',\n        destination_name: 'tbaas',\n        http_verb: 'POST',\n        payload: {\n            \"me\": \"here\"\n        }\n    })\n        .then(response =\u003e {\n            // do sth clever from the response\n            // of $server_behind_destination_'tbaas'/api/json\n        })\n        .catch(err =\u003e {\n            // oh no 💩\n        })\n        \n// async/await? 👏\n// add the 'async' keyword to an outer function wrapping 'callDestination'\nasync function getIt() {\n    try {\n        const response = await callDestination({...});\n        // do sth clever w/ the response\n    } catch (err) {\n        // oh no 💩\n    }\n}\n~~~\n\n## API\n## sap-cf-destination(options) ⇒ \u003ccode\u003ePromise.\u0026lt;(any\\|never)\u0026gt;\u003c/code\u003e\n\n| Param | Type | Description |\n| --- | --- | --- |\n| options | \u003ccode\u003eMap\u003c/code\u003e | configuration options for several CF service instances |\n| options.url | \u003ccode\u003estring\u003c/code\u003e | the url to call in the destination, absolute path (including leading slash)                              e.g. /api/v1/json |\n| options.connectivity_instance | \u003ccode\u003estring\u003c/code\u003e | name of the instance of the connectivity service |\n| options.uaa_instance | \u003ccode\u003estring\u003c/code\u003e | name of the instance of the uaa service |\n| options.destination_instance | \u003ccode\u003estring\u003c/code\u003e | name of the instance of the destination service |\n| options.destination_name | \u003ccode\u003estring\u003c/code\u003e | name of the destination to use |\n| options.http_verb | \u003ccode\u003e\u0026#x27;GET\u0026#x27;\u003c/code\u003e \\| \u003ccode\u003e\u0026#x27;POST\u0026#x27;\u003c/code\u003e \\| \u003ccode\u003e\u0026#x27;PUT\u0026#x27;\u003c/code\u003e \\| \u003ccode\u003e\u0026#x27;PATCH\u0026#x27;\u003c/code\u003e \\| \u003ccode\u003e\u0026#x27;DELETE\u0026#x27;\u003c/code\u003e \\| \u003ccode\u003e\u0026#x27;HEAD\u0026#x27;\u003c/code\u003e \\| \u003ccode\u003e\u0026#x27;OPTIONS\u0026#x27;\u003c/code\u003e | HTTP method to use |\n| [options.payload] | \u003ccode\u003eobject\u003c/code\u003e | payload for POST, PUT or PATCH |\n| [options.formData] | \u003ccode\u003eobject\u003c/code\u003e | mimic a browser for POSTing a form to the destination; implies http verb POST |\n| [options.content_type] | \u003ccode\u003estring\u003c/code\u003e | value for \"Content-Type\" http header, e.g. \"application/json\" |\n| [options.full_response] | \u003ccode\u003eboolean\u003c/code\u003e | whether to have the full response (including all headers etc)                                          pass through to the caller (BE -\u003e proxy -\u003e client) |\n| [options.tech_error_only] | \u003ccode\u003eboolean\u003c/code\u003e | get a rejection only if the request failed for technical reasons,                                          so e.g. 404 is considered a valid response |\n| [options.binary] | \u003ccode\u003eboolean\u003c/code\u003e | whether to expect (and deliver) a binary at @param url |\n| [options.scc_name] | \u003ccode\u003estring\u003c/code\u003e | Location ID of the SAP Cloud Connector |\n\n\n\n## Hints \u0026 Limitations\n- all major HTTP verbs are supported (`GET`, `POST`, `PUT`,`PATCH`,`HEAD`, `DELETE`,`OPTIONS`) per se  \n  **BUT**: if the proxy software decides to not let any of them pass through, the request originating from this module will of course fail\n- ~~`POST`,~~ `PUT` and `PATCH` only support a JSON payload.\n  The payload itself can be a plain, deeply nested object; it will be stringified automatically\n- `POST` now supports both a JSON payload and a form-style (\"like a browser\") submission:\n  ~~~js\n  callDestination({\n    url: ...,\n    http_verb: 'POST',\n    formData: {\n      field1: \"some value\",\n      field2: JSON.stringify([ { \"el1\": \"v1\", \"el2\": \"v2\" } ])  // stringify deep nested objects and array structures\n    }\n  })\n  ~~~   \n- use `scc_name: '\u003clocID\u003e'` as a parameter to specify location ID of the SAP Cloud Connector (default: _none_)  \n  ~~~js\n  callDestination({\n          //...\n          scc_name: '\u003clocID of SCC\u003e'\n      }).then(...).catch(...);\n  ~~~\n- use `full_response: true` as a parameter to obtain the full response payload, e.g. to get access to response headers  \n  ~~~js\n  callDestination({\n          //...\n          full_response: true\n      }).then(...).catch(...);\n  ~~~\n- use `tech_error_only: true` as a parameter to only get a rejection if the request failed for technial reasons (\"as long as [it has a status code](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/418), it's a valid response\")  \n  ~~~js\n  callDestination({\n          //...\n          tech_error_only: true\n      }).then( response =\u003e {\n          // even ☕️ ends up here\n          // add\n          //    full_response: true (see above)\n          // to get response.statusCode\n      }).catch( err =\u003e {\n          // network layer problem or such\n      });\n  ~~~\n- do a download of a binary file by specifying the matching `Content-Type` of the file and setting `binary` to `true`;   \n  this will deliver a `Buffer` useable in `writeStreams`\n  ~~~js\n  callDestination({\n          //...\n          content_type: 'application/zip',\n          binary: true\n      }).then( buffer =\u003e {\n          // write Buffer\n          fs.createWriteStream('file.zip')\n            .write(buffer, 'binary')\n            .end();\n          // don't forget to listen to the error and finish event\n          // ...\n      }).catch(...);\n   ~~~\n\n\n## License\nApache License 2.0\n\n## References\n- code inspiration from https://github.com/bertdeterd/scc-connector\n- ported `Java` reference code from https://help.sap.com/viewer/cca91383641e40ffbe03bdc78f00f681/Cloud/en-US/313b215066a8400db461b311e01bd99b.html\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvobu%2Fsap-cf-destination","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvobu%2Fsap-cf-destination","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvobu%2Fsap-cf-destination/lists"}