cf-nodejs-client
Note: This package is not ready for a production App yet.
This project provides a simple client library to interact with the Cloud Foundry Architecture:
Using this library, you could interact the following components on PWS
, Bluemix or a Local Cloud Foundry instance:
Applications
Node.js with Express are a great combination to develop Web applications. If you observe the Sinatra market, you will notice that Node.js has a huge Traction.
The development doesn't cover the whole CC API. Main areas of development are:
App life cycle:
- Create an App
- Upload source code in .zip or .war (Support for Static, Python, PHP, Node.js & JEE)
- Create an User Provided Services
- Associate Apps with an User Provided Services
- Start | Stop an App
- Restage Apps
- Scale Apps
- Simple Logs management
- Remove Apps
- Remove User Provided Services
PaaS Management:
- Organization quota
- Organization
- Space
- Services, Service Instances, Service Plans, User provided Services & Service Binding
- UAA Users
- Users
Getting Started
If you need to interact with a Cloud Foundry platform try this online tool and use this example:
var endpoint = "https://api.run.pivotal.io";
var username = "PWS_USERNAME";
var password = "PWS_PASSWORD";
var authorization_endpoint = null;
var token_type = null;
var access_token = null;
var refresh_token = null;
var CloudFoundry = require("cf-nodejs-client").CloudFoundry;
var CloudFoundryUsersUAA = require("cf-nodejs-client").UsersUAA;
CloudFoundry = new CloudFoundry();
CloudFoundryUsersUAA = new CloudFoundryUsersUAA();
CloudFoundry.setEndPoint(endpoint);
function sleep(time, callback) {
var stop = new Date().getTime();
while (new Date().getTime() < stop + time) {
;
}
callback();
}
CloudFoundry.getInfo().then(function (result) {
console.log(result);
authorization_endpoint = result.authorization_endpoint;
token_endpoint = result.token_endpoint;
CloudFoundryUsersUAA.setEndPoint(authorization_endpoint);
return CloudFoundryUsersUAA.login(username, password);
}).then(function (result) {
refresh_token = result.refresh_token;
sleep(5000, function () {
console.log("5 second");
});
return CloudFoundryUsersUAA.refreshToken(refresh_token_test);
}).then(function (result) {
token_type = result.token_type;
access_token = result.access_token;
return CloudFoundryApps.getApps(token_type, access_token);
}).then(function (result) {
console.log(result);
}).catch(function (reason) {
console.error("Error: " + reason);
});
Explore the library and if you like the features, use it on your App:
npm install cf-nodejs-client --save
Online documentation:
JSDoc
Testing
This project has a test suite to ensure the reability of this project. Take a look the Tests cases developed with Mocha & Chai to understand some stuff about Cloud Foundry and the usage of this client. Besides, the project has invested some amount of time in testing phase to be the code with a nice coverage level.
The development has been tested with:
Last test: 2015/12/22
Test suite:
npm test
Code coverage:
istanbul cover node_modules/mocha/bin/_mocha -- -R spec
Continous integration:
https://travis-ci.org/jabrena/cf-nodejs-client/
Versions
Take a look this doc to check the evolution of this Client for Cloud foundry.
References
Issues
If you have any question or doubt, please create an issue.
Juan Antonio
Version 0.12.0 2015-12-22
- Support to refresh OAuth Token.
- Adding PHP & Python buildpacks.
- Package.json refactoring
Pull Requests:
@jthomas:
- Support for Service Instances
- Support for Services
- Support for ServicePlans
- Support for filters in Events
Environment: LOCAL_INSTANCE_1
89 passing (3m)
33 pending
Environment: PIVOTAL
82 passing (4m)
29 pending
Environment: BLUEMIX
82 passing (4m)
29 pending