2.2.2 • Published 4 years ago

pgasus v2.2.2

Weekly downloads
4
License
MIT
Repository
github
Last release
4 years ago

To access pgasus-backed web service, create a new WebService object.

var ws = new WebService(baseUrl, [username], [password]);

username and password are optional parameters, to be specified if HTTP basic authentication is needed.

WebService objects have two methods:

  • relation(path) when the resource is a relation (table or view).
  • procedure(path) when the resource is a procedure (function).

Objects returned by relation have four methods:

  • get(parameters, options, callback)
  • options: filter (use queryme expression), order (use QM.Sort or QM.Order), limit (number), cookie (string)
  • post(parameters, options, callback)
  • options: cookie (string)
  • put(parameters, options, callback)
  • options: filter (use queryme expression), cookie (string)
  • del(parameters, options, callback), for delete HTTP method (delete is a reserved keyword in ECMAScript)
  • options: filter (use queryme expression), cookie (string)

Objects returned by procedure have four methods:

  • get(parameters, options, callback)
  • options: cookie (string)
  • post(parameters, options, callback)
  • options: cookie (string)
  • put(parameters, options, callback)
  • options: cookie (string)
  • del(parameters, options, callback), for delete HTTP method (delete is a reserved keyword in ECMAScript)
  • options: cookie (string)

The provided callback must have type function(error, result) or be left unspecified. Arguments are:

  • error, null if no error detected, otherwise an object with the following members:
  • httpStatus, the numeric HTTP status code.
  • httpStatusText, the HTTP status message.
  • description, additional description of the error may be included here.
  • result, if no error has been detected, this will be the deserialized JSON value returned by the remote server.

Note: support for setting cookie is for server-side use only. When using from express.js, use req.get('Cookie') to retrive cookie sent by browser (where req is a request object).

Example

var ws = new WebService("https://test.com");
var login = ws.procedure("/users/:user_id/login").post;
var projectTasks = ws.relation("/projects/:project_id/tasks");

login({"user_id": "bob", "password": "$3cur3"}, function(err, res) {
  if(err != null) {
    projectTasks.get({"project_id": 100}, {order: QM.Order("dueDate")}, function(res) { });
  }
});

Note: the QM object is defined by queryme.

2.2.2

4 years ago

2.2.1

4 years ago

2.1.0

4 years ago

2.0.6

5 years ago

2.0.5

6 years ago

2.0.4

7 years ago

2.0.3

7 years ago

2.0.2

7 years ago

2.0.1

7 years ago

2.0.0

7 years ago

1.0.9

7 years ago

1.0.8

7 years ago

1.0.7

7 years ago

1.0.6

7 years ago

1.0.5

7 years ago

1.0.4

8 years ago

1.0.3

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago