') + ')', 'gi'); if (regex.test(text)) { found = true; var frag = document.createDocumentFragment(); var parts = text.split(regex); parts.forEach(function(part, i) { if (i % 2 === 0) { frag.appendChild(document.createTextNode(part)); } else { var span = document.createElement('span'); span.className = 'userscript-highlight'; span.textContent = part; frag.appendChild(span); } }); node.parentNode.replaceChild(frag, node); } }); } else if (node.nodeType === 1 && node.childNodes) { // element var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT']; if (!skipTags.includes(node.tagName)) { Array.from(node.childNodes).forEach(highlight); } } } highlight(document.body); // Re-highlight on dynamic content var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1 || node.nodeType === 3) highlight(node); }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ', 'i'); if (__m === '*' || __re.test(location.href)) { // Strip utm_, fbclid, gclid, etc. from all links on page (function() { var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content', 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid', 'ref', 'ref_src', 'source', 'medium', 'campaign']; function cleanUrl(url) { try { var u = new URL(url, window.location.origin); var changed = false; trackingParams.forEach(function(p) { if (u.searchParams.has(p)) { u.searchParams.delete(p); changed = true; } }); return changed ? u.toString() : url; } catch (e) { return url; } } function cleanLinks() { document.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } cleanLinks(); var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1) { if (node.tagName === 'A') cleanLinks(); node.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + ', 'i'); if (__m === '*' || __re.test(location.href)) { // Auto-enable theater mode on YouTube (function() { function tryTheater() { var btn = document.querySelector('button[aria-label="Theater mode"], ytd-player #player button[title="Theater mode"]'); if (btn && !btn.classList.contains('activated')) { btn.click(); } } // Try immediately tryTheater(); // Try after navigation (SPA) var lastUrl = location.href; setInterval(function() { if (location.href !== lastUrl) { lastUrl = location.href; setTimeout(tryTheater, 500); } }, 1000); // Also try on player load var observer = new MutationObserver(tryTheater); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ', 'i'); if (__m === '*' || __re.test(location.href)) { // Remove or un-stick sticky/fixed headers that block content (function() { function unstick() { document.querySelectorAll('header, nav, [role="banner"], .header, .navbar, .sticky, .fixed-top, [style*="position: fixed"], [style*="position:sticky"]').forEach(function(el) { if (el.style.position === 'fixed' || el.style.position === 'sticky' || getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') { el.style.position = 'static'; el.style.top = 'auto'; el.style.zIndex = 'auto'; } }); } unstick(); var observer = new MutationObserver(unstick); observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] }); })(); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); })(); GitHub - leotrinh/cf-node-client: A Cloud Foundry Client for Node.js based on stopped maintenance codebas. NPM pkg: https://www.npmjs.com/package/cf-node-client?activeTab=readme · GitHub
Skip to content

Repository files navigation

cf-node-client

npm versionnpm downloadsLicense

A Node.js client library for the Cloud Foundry API (v2 & v3), with built-in TypeScript support.

Maintained byleotrinh — forked from prosociallearnEU/cf-nodejs-client by Juan Antonio Breña Moral.

Ship by Claude Kit

Ship faster with AI Dev Team — DISCOUNT 25% - PAY ONE TIME, LIFETIME LIFETIME UPDATE

Claude Kit


Supported Cloud Foundry Platforms

This library works with any platform that implements the Cloud Foundry API:

PlatformProviderStatus
SAP BTP Cloud FoundrySAP✅ Supported
Tanzu Platform (formerly Pivotal / TAS)Broadcom / VMware✅ Supported
IBM Cloud FoundryIBM✅ Supported
SUSE Cloud Application PlatformSUSE✅ Supported
Open Source Cloud FoundryCloud Foundry Foundation✅ Supported
Any CF-compatible API endpoint✅ Supported

Architecture Overview

SAP BTP Cloud FoundrySAP BTP CF Architecture

Cloud Foundry Architecture

CF Architecture

UML DiagramUML Diagram


Documentation

DocumentDescription
JSDoc API ReferenceFull generated API documentation (all classes, methods, params)
Usage GuideConfiguration & API usage examples
Service UsageCF Service integration guide
System ArchitectureInternal architecture overview

Documentation Detail

The JSDoc API Reference covers every public class and method in the library:

ClassDescriptionJSDoc
CloudControllerCF API info & versionView
AppsApplication lifecycle (CRUD, start, stop, env, routes)View
OrganizationsOrg management, quotas, domains, usersView
SpacesSpace management, apps, services per spaceView
ServicesService offerings & plansView
ServiceInstancesService instance CRUD & bindingsView
ServiceBindingsService binding managementView
ServicePlansService plan listing & managementView
UserProvidedServicesUser-provided service instancesView
RoutesRoute management & mappingsView
DomainsDomain managementView
BuildPacksBuildpack managementView
StacksStack listingView
UsersUser managementView
EventsAudit eventsView
JobsBackground tasksView
OrganizationsQuotaOrg quota definitionsView
SpacesQuotaSpace quota definitionsView
UsersUAAUAA authentication (login, tokens)View
LogsApplication log streamingView
HttpUtilsHTTP request utilitiesView

Generate Docs Locally

# Generate JSDoc HTML into doc/ folder
npm run docs
# Generate + serve on localhost:9000 + open browser
npm run docs:serve

Installation

npm install cf-node-client

Quick Start

JavaScript

const{ CloudController, UsersUAA, Apps }=require("cf-node-client");// Step 1: Get UAA endpoint from Cloud Controllerconstcc=newCloudController("https://api.<your-cf-domain>");constauthEndpoint=awaitcc.getAuthorizationEndpoint();// Step 2: Authenticateconstuaa=newUsersUAA();uaa.setEndPoint(authEndpoint);consttoken=awaituaa.login("user","pass");// Step 3: Use the tokenconstapps=newApps("https://api.<your-cf-domain>");apps.setToken(token);constresult=awaitapps.getApps();console.log(result.resources);

TypeScript

import{CloudController,UsersUAA,Apps,Spaces,Organizations,OAuthToken}from"cf-node-client";constcc=newCloudController("https://api.<your-cf-domain>");constauthEndpoint: string=awaitcc.getAuthorizationEndpoint();constuaa=newUsersUAA();uaa.setEndPoint(authEndpoint);consttoken: OAuthToken=awaituaa.login("user","pass");constapps=newApps("https://api.<your-cf-domain>");apps.setToken(token);constresult=awaitapps.getApps();console.log(result.resources);

Built-in TypeScript declarations are included — no additional @types package needed.

Available Types

TypeDescription
OAuthTokenUAA authentication token
FilterOptionsPagination and query filters
DeleteOptionsDelete operation options
ApiResponse<T>Typed API response wrapper
CloudControllerBaseOptionsBase constructor options

See examples/ for more usage patterns.


Convenience Methods

Find resources by name using server-side filtering — a single API call instead of fetching all resources and looping:

const{ Organizations, Spaces, Apps, ServiceInstances }=require("cf-node-client");constorgs=newOrganizations("https://api.<your-cf-domain>");constspaces=newSpaces("https://api.<your-cf-domain>");constapps=newApps("https://api.<your-cf-domain>");constsi=newServiceInstances("https://api.<your-cf-domain>");orgs.setToken(token);spaces.setToken(token);apps.setToken(token);si.setToken(token);// Find by name (returns first match or null)constorg=awaitorgs.getOrganizationByName("my-org");constspace=awaitspaces.getSpaceByName("dev",orgGuid);// orgGuid optionalconstapp=awaitapps.getAppByName("my-app",spaceGuid);// spaceGuid optionalconstinst=awaitsi.getInstanceByName("my-db",spaceGuid);// spaceGuid optional// Get by GUID (direct lookup)constorg=awaitorgs.getOrganization(orgGuid);constspace=awaitspaces.getSpace(spaceGuid);constapp=awaitapps.getApp(appGuid);constinst=awaitsi.getInstance(instanceGuid);
ResourceList AllGet by GUIDFind by NameGet ALL (paginated)
OrganizationsgetOrganizations()getOrganization(guid)getOrganizationByName(name)getAllOrganizations(filter?)
SpacesgetSpaces()getSpace(guid)getSpaceByName(name, orgGuid?)getAllSpaces(filter?)
AppsgetApps()getApp(guid)getAppByName(name, spaceGuid?)getAllApps(filter?)
ServiceInstancesgetInstances()getInstance(guid)getInstanceByName(name, spaceGuid?)getAllInstances(filter?)

Works with both v2 (q=name:X) and v3 (names=X) APIs automatically.


Auto-Pagination

No more manual pagination loops — the library pages through every page and returns a flat array:

constallOrgs=awaitorgs.getAllOrganizations();constallSpaces=awaitspaces.getAllSpaces();constallApps=awaitapps.getAllApps({q: "space_guid:xxx"});constallSIs=awaitsi.getAllInstances();

Handles both v2 (next_url) and v3 (pagination.next) transparently. v3 fetches 200 per page; v2 fetches 100 per page.


Memory Cache

Opt-in, in-memory cache with configurable TTL (default 30 s). Reduces redundant API calls when the same data is requested multiple times:

// Enable at construction timeconstorgs=newOrganizations(api,{cache: true,cacheTTL: 60000});orgs.setToken(token);awaitorgs.getAllOrganizations();// API call → result cachedawaitorgs.getAllOrganizations();// cache hit — 0 HTTP calls// Toggle at runtimeorgs.enableCache();// default 30 s TTLorgs.enableCache(60000);// custom 60 s TTLorgs.clearCache();// clear entries, keep cache enabledorgs.disableCache();// turn off + clear all

API Reference

v3 Endpoints (Default)

All API calls use v3 by default. No additional configuration needed.

ResourceDocs
AppsAPI
SpacesAPI
Service InstancesAPI
Service BindingsAPI
OrganizationsAPI
UsersAPI
Other v3 endpointsFull v3 API Reference

v2 Endpoints (Legacy)

Note: CF API v2 is deprecated by Cloud Foundry. Use v2 only if your platform has not yet migrated to v3.

To enable v2, pass { apiVersion: "v2" } when creating any resource instance:

const{ Apps, Spaces, Organizations }=require("cf-node-client");// v2 modeconstapps=newApps("https://api.<your-cf-domain>",{apiVersion: "v2"});constspaces=newSpaces("https://api.<your-cf-domain>",{apiVersion: "v2"});constorgs=newOrganizations("https://api.<your-cf-domain>",{apiVersion: "v2"});
ResourceDocs
AppsAPI
BuildpacksAPI
DomainsAPI
JobsAPI
OrganizationsAPI
Organizations QuotasAPI
RoutesAPI
ServicesAPI
Service BindingsAPI
Service InstancesAPI
Service PlansAPI
SpacesAPI
Spaces QuotasAPI
StacksAPI
User Provided ServicesAPI
UsersAPI

Testing

# Run test suite
npm test# Run unit tests only
npm run test:unit
# Code coverage
istanbul cover node_modules/mocha/bin/_mocha -- -R spec

Changelog

See CHANGELOG.md for version history.


References


Contributing

Contributions are welcome! We want to make contributing as easy and transparent as possible.

How to contribute:

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/my-feature)
  3. Write or improve tests — this is the most impactful way to help
  4. Run the precheck before committing:
    npm run precheck
    This runs TypeScript compilation (tsc) and the full test suite (lint + unit tests). Your PR will not be accepted if precheck fails.
  5. Commit your changes (git commit -m 'feat: add some feature')
  6. Push to the branch (git push origin feature/my-feature)
  7. Open a Pull Request

First time? Look for issues labeled good first issue — writing tests is a great way to start. Every PR with new test coverage is highly appreciated!


Upstream Issues Tracker

This fork tracks and resolves issues from the original upstream repositories:

Individual issue docs: docs/issues/

✅ Resolved in This Fork

#OriginIssueDoc
#199prosociallearnEUHANA Cloud DB start/stop control — Fixed v1.0.8Details
#196prosociallearnEUCopy bits between apps — Fixed v1.0.8 (verified existing)Details
#183prosociallearnEULog timestamp missing — Fixed v1.0.8Details
#173prosociallearnEURespect .cfignore on upload — Fixed v1.0.8 (CfIgnoreHelper utility)Details
#158prosociallearnEUDownload droplet from app — Fixed v1.0.8 (verified existing)Details
#157prosociallearnEUDownload bits from app — Fixed v1.0.8 (verified existing)Details
#156prosociallearnEUURL validation in constructors — Fixed v1.0.8 (verified existing)Details
#44IBM-CloudAPIKey auth (instead of user/password) — Fixed v1.0.8Details
#47IBM-CloudSame-name services in different spaces — Fixed v1.0.8 (verified existing)Details
#15IBM-CloudgetTokenInfo(accessToken) method — Fixed v1.0.8 (verified existing)Details
#198prosociallearnEUApps.upload() broken on Node 12+ (restler) — Fixed v1.0.6Details
#50IBM-CloudNode security alerts (multiple deps) — Fixed v1.0.2Details
#52IBM-Cloudprotobufjs vulnerability — Fixed (v7.0.0)Details
#192prosociallearnEUAsync service creation (accepts_incomplete) — ImplementedDetails
#45IBM-CloudEvents/Logs TypeError at runtime — FixedDetails
#191prosociallearnEUSet environment variables (cf set-env equivalent)Details
#190prosociallearnEUWorks with any CF environment + space handlingDetails
#188prosociallearnEUTravis CI build broken → migrated to GitHub ActionsDetails
#179prosociallearnEUHow to create a CF app (documented)Details
#43IBM-CloudAny CF env support (documented)Details

🔧 Open / In Progress

#OriginIssuePriorityDoc
#161prosociallearnEUImprove JSDocs / TypeScript types (ongoing)LowDetails

Issues

If you have any questions or find a bug, please create an issue.

License

Licensed under the Apache License, Version 2.0.

About

A Cloud Foundry Client for Node.js based on stopped maintenance codebas. NPM pkg: https://www.npmjs.com/package/cf-node-client?activeTab=readme

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Sponsor this project

Packages

Contributors

Languages