wekan/packages/wekan-cfs-http-publish/internal.api.md
2021-04-29 13:26:49 +03:00

8.4 KiB

Public and Private API

API documentation automatically generated by docmeteor.


File: "http.publish.server.api.js" Where: {server}


_publishHTTP {any}  Server

GET /note
GET /note/:id
POST /note
PUT /note/:id
DELETE /note/:id

_publishHTTP = { ... http.publish.server.api.js:20

Could be cool if we could serve some api doc or even an api script user could do and be served a client-side javascript api? Eg. HTTP.api.note.create(); HTTP.api.login(username, password); HTTP.api.logout

_publishhttp.getPublishScope(scope)  Server

This method is private This method getPublishScope is defined in _publishHTTP

Arguments

  • scope {Object}

Returns {httpPublishGetPublishScope.publishScope}

Creates a nice scope for the publish method

_publishHTTP.getPublishScope = function httpPublishGetPublishScope(scope) { ... http.publish.server.api.js:35

_publishhttpformathandlers.json(result)  Server

This method is private This method json is defined in _publishHTTP.formatHandlers

Arguments

  • result {Object}

The result object

Returns {String} JSON

Formats the output into JSON and sets the appropriate content type on this

_publishHTTP.formatHandlers.json = function httpPublishJSONFormatHandler(result) { ... http.publish.server.api.js:56

_publishhttp.formatResult(result, scope, [defaultFormat])  Server

This method is private This method formatResult is defined in _publishHTTP

Arguments

  • result {Object}

The result object

  • scope {Object}
  • defaultFormat {String} (Optional, Default = 'json')

Default format to use if format is not in query string.

Returns {Any} The formatted result

Formats the result into the format selected by querystring eg. "&format=json"

_publishHTTP.formatResult = function httpPublishFormatResult(result, scope, defaultFormat) { ... http.publish.server.api.js:73

_publishhttp.error(statusCode, message, scope)  Server

This method is private This method error is defined in _publishHTTP

Arguments

  • statusCode {String}

The status code

  • message {String}

The message

  • scope {Object}

Returns {Any} The formatted result

Responds with error message in the expected format

_publishHTTP.error = function httpPublishError(statusCode, message, scope) { ... http.publish.server.api.js:114

_publishhttp.getMethodHandler(collection, methodName)  Server

This method is private This method getMethodHandler is defined in _publishHTTP

Arguments

The Meteor.Collection instance

  • methodName {String}

The method name

Returns {Function} The server method

Returns the DDP connection handler, already setup and secured

_publishHTTP.getMethodHandler = function httpPublishGetMethodHandler(collection, methodName) { ... http.publish.server.api.js:129

_publishhttp.unpublishList(names)  Server

This method is private This method unpublishList is defined in _publishHTTP

Arguments

  • names {Array}

List of method names to unpublish

Returns {undefined}

Unpublishes all HTTP methods that have names matching the given list.

_publishHTTP.unpublishList = function httpPublishUnpublishList(names) { ... http.publish.server.api.js:149

_publishhttp.unpublish([name])  Server

This method is private This method unpublish is defined in _publishHTTP

Arguments

The method name or collection

Returns {undefined}

Unpublishes all HTTP methods that were published with the given name or for the given collection. Call with no arguments to unpublish all.

_publishHTTP.unpublish = function httpPublishUnpublish( http.publish.server.api.js:177

http.publishFormats(newHandlers)  Server

This method publishFormats is defined in HTTP

Arguments

  • newHandlers {Object}

Returns {undefined}

Add publish formats. Example:

HTTP.publishFormats({
json: function(inputObject) {
// Set the method scope content type to json
this.setContentType('application/json');
// Return EJSON string
return EJSON.stringify(inputObject);
}
});

HTTP.publishFormats = function httpPublishFormats(newHandlers) { ... http.publish.server.api.js:215

http.publish(options, [name], [collection], [publishFunc])  Server

This method publish is defined in HTTP

Arguments

  • options {Object}

    • defaultFormat {String} (Optional, Default = 'json')

    Format to use for responses when format is not found in the query string.

    • collectionGet {String} (Optional, Default = true)

    Add GET restpoint for collection? Requires a publish function.

    • collectionPost {String} (Optional, Default = true)

    Add POST restpoint for adding documents to the collection?

    • documentGet {String} (Optional, Default = true)

    Add GET restpoint for documents in collection? Requires a publish function.

    • documentPut {String} (Optional, Default = true)

    Add PUT restpoint for updating a document in the collection?

    • documentDelete {String} (Optional, Default = true)

    Add DELETE restpoint for deleting a document in the collection?

  • name {String} (Optional)

Restpoint name (url prefix). Optional if collection is passed. Will mount on /api/collectionName by default.

Meteor.Collection instance. Required for all restpoints except collectionGet

  • publishFunc {Function} (Optional)

A publish function. Required to mount GET restpoints.

Returns {undefined}

TODO

* this should use options argument instead of optional args

Publishes one or more restpoints, mounted on "name" ("/api/collectionName/" by default). The GET restpoints are subscribed to the document set (cursor) returned by the publish function you supply. The other restpoints forward requests to Meteor's built-in DDP methods (insert, update, remove), meaning that full allow/deny security is automatic.

Usage:

Publish only:

HTTP.publish({name: 'mypublish'}, publishFunc);

Publish and mount crud rest point for collection /api/myCollection:

HTTP.publish({collection: myCollection}, publishFunc);

Mount CUD rest point for collection and documents without GET:

HTTP.publish({collection: myCollection});

HTTP.publish = function httpPublish(options, publishFunc) { ... http.publish.server.api.js:256

http.unpublish([name])  Server

This method unpublish is defined in HTTP

Arguments

The method name or collection

Returns {undefined}

Unpublishes all HTTP methods that were published with the given name or for the given collection. Call with no arguments to unpublish all.

HTTP.unpublish = _publishHTTP.unpublish; http.publish.server.api.js:453