Git Product home page Git Product logo

cf-nodejs-client's Introduction

cf-nodejs-client

Build Status Dependency Status devDependency Status Changelog

NPM

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:

ScreenShot

Using this library, you could interact with the following platforms: PWS , Bluemix or a Local Cloud Foundry instance:

Cloud Controller UAA Logging & Metrics
Apps Users Logs
Buildpacks
Domains
Jobs
Organizations
Organizations Quotas
Routes
Services
Service Bindings
Service Instances
Service Plans
Spaces
Spaces Quotas
Stacks
User provided Services
Users

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:

"use-strict";

const endpoint = "https://api.run.pivotal.io";
const username = "PWS_USERNAME";
const password = "PWS_PASSWORD";

const CloudController = new (require("cf-nodejs-client")).CloudController(endpoint);
const UsersUAA = new (require("cf-nodejs-client")).UsersUAA;
const Apps = new (require("cf-nodejs-client")).Apps(endpoint);

CloudController.getInfo().then( (result) => {
    UsersUAA.setEndPoint(result.authorization_endpoint);
    return UsersUAA.login(username, password);
}).then( (result) => {
	Apps.setToken(result);
    return Apps.getApps();
}).then( (result) => {
    console.log(result);
}).catch( (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

Technical 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:

Local Instance PWS Bluemix
2.25.0 2.47.0 2.40.0

Last test: 2016/01/26

Test suite:

npm test

Code coverage:

istanbul cover node_modules/mocha/bin/_mocha -- -R spec

Continous integration:

https://travis-ci.org/prosociallearnEU/cf-nodejs-client/

Versions

Take a look this doc to check the evolution of this Client for Cloud foundry.

References

Others references

Issues

If you have any question or doubt, please create an issue.

License

Licensed under the Apache License, Version 2.0.

cf-nodejs-client's People

Contributors

jabrena avatar jm2garrido avatar jthomas avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

cf-nodejs-client's Issues

Integrate AppMacros in Tests

From the point of view of the user, it is better if the user only use objects from the library.
It is a bit puzzle AppMacros with Examples.

Get stats

GET /v2/apps/2afa40de-8979-4988-9877-52b1c21ae81a/stats

output:

{"0":{"state":"DOWN","since":1439817518}}

Develop a Log utility to show data.

WEBSOCKET REQUEST: [2015-08-10T09:52:53+02:00]
GET /tail/?app=c2821f8f-3671-48ff-b3ba-20eeb15e255e HTTP/1.1
Host: wss://loggregator.MY_IP.xip.io:4443
Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Version: 13
Sec-WebSocket-Key: [HIDDEN]
Origin: http://localhost
Authorization: [PRIVATE DATA HIDDEN]


WEBSOCKET RESPONSE: [2015-08-10T09:52:54+02:00]
HTTP/1.1 101 Switching Protocols
Upgrade: websocket
Connection: Upgrade
Sec-Websocket-Accept: xdXbtZjCfzGQ2sKQ1ahMLgFD8II=

Starting app StaticWebsiteHelloWorld in org DevBox / space dev as admin...

Detect staging problems.

cf start appdevelopment
Starting app appdevelopment in org DevBox / space dev as admin...
FAILED
Server error, status code: 400, error code: 170001, message: Staging error: no a
vailable stage

Get instances

GET /v2/apps/2afa40de-8979-4988-9877-52b1c21ae81a/instances

Find application

método necesario para macro: start app

/v2/spaces/e558b66a-1b9c-4c66-a779-5cf46e3b060c/apps?q=name%3Aapp2aside6&inline-relations-depth=1

Create macros

Move big functions used in the testCases to macros folder in examples.

How to detect "organization's memory limit"

     Error: the string "{\n  \"code\": 100005,\n  \"description\": \"You have ex
ceeded your organization's memory limit.\",\n  \"error_code\": \"CF-AppMemoryQuo
taExceeded\"\n}\n" was thrown, throw an Error :)

Add documentation

Associate Cloud foundry documentation about every REST call in every method.

Remove routes in some Tests

Error: {
"code": 310006,
"description": "You have exceeded the total routes for your organization's quota.",
"error_code": "CF-OrgQuotaTotalRoutesExceeded"
}

Protect code

It is necessary to avoid this kind of errors:


undefined
^
SyntaxError: Unexpected token u
    at Object.parse (native)
    at Request._callback (C:\Users\PATH\cf-nodejs-client\lib\utils\HttpUtils.js:76:31)
    at self.callback (C:\Users\PATH\cf-nodejs-client\node_modules\request\request.js:198:22)
    at Request.emit (events.js:107:17)
    at Request.onRequestError (C:\Users\PATH\cf-nodejs-client\node_modules\request\request.js:861:8)
    at ClientRequest.emit (events.js:107:17)
    at TLSSocket.socketErrorListener (_http_client.js:271:9)
    at TLSSocket.emit (events.js:129:20)
    at net.js:950:16
    at process._tickCallback (node.js:355:11)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.