Skip to content

Implement getEndpoints 2.x - #309

Closed
Amir-61 wants to merge 21 commits into
masterfrom
getEndpoints_2.x
Closed

Implement getEndpoints 2.x#309
Amir-61 wants to merge 21 commits into
masterfrom
getEndpoints_2.x

Conversation

@Amir-61

@Amir-61 Amir-61 commented Jun 6, 2016

Copy link
Copy Markdown
Member

Connect to #305

David Cheung and others added 21 commits January 28, 2016 13:12
- Add option to customize the XML rootElement tag
  (default: "response")

- Add flag to disable declaration from response
  (default: declaration is present)

- Bugfix changing behavior: `string` results from remote methods are
now quoted to avoid json2xmlparser throwing syntax error and returning
500 instead of a regular response body.

User can set the returned XML root element as follows:

    "returns": {
      "xml": { "wrapperElement": "Parent" }
    }

User can disable XML declaration as follows:

    "returns": {
      "xml": { "declaration": false }
    }

This is a back-port of the following GitHub pull request:
#272
Create `ContextBase` - a base class for all Context objects where
we can put methods shared by all contexts.

Move `remotes.getScope` to `ContextBase.prototype.getScope` as it
belongs there more naturally and will make it easier to access scope
in hooks that can access the `ctx` object only.
Deprecate `invokeMethodInContext(ctx, method, cb)` in favour of simpler
`invokeMethodInContext(ctx, cb)`.
Rework "invokeMethodInContext" to use a concept of phases that allows
external components a more fine-grained way for extending built-in
functionality.

The new API is exposed on `remotes.phases`, which is an instance
of PhaseList from loopback-phase.

There are two built-in phases available: "auth" and "invoke".

Hooks registered via `remotes.authorization`, `remotes.before` and
`remotes.after` are invoked in "auth", "invoke:before" and
"invoke:after" phases.

Here is the complete order in which different hooks/handler are called:

 - hook "authorization"
 - phase handlers "auth"
 - hook "remotes.before"
 - phase handlers "invoke:before"
 - invoke method
 - phase handlers "invoke:use"
 - hook "remotes.after"
 - phase handlers "invoke:after"
Implement a method for registering phase handlers with a method-name
based filter.

Example usage:

    // match static methods
    remotes.registerPhaseHandler('invoke', 'User.*', fn)

    // match prototype methods
    remotes.registerPhaseHandler('invoke', 'User.prototype.*', fn)

    // match all model methods
    remotes.registerPhaseHandler('invoke', 'User.**', fn)
 * Backport pull request #279 from strongloop/feature/phases (Miroslav Bajtoš)
 * Add remotes.registerPhaseHandler (Miroslav Bajtoš)
 * Add remote invocation phases (Miroslav Bajtoš)
 * Simplify invokeMethodInContext (Miroslav Bajtoš)
 * Extract ContextBase and ctx.getScope() (Miroslav Bajtoš)
 * Customize XML root element in remoteMethod (David Cheung)
Fix RemoteObjects.prototype.invokeMethodInContext to trigger afterError
hooks only when there was an invocation error.

This bug was introduced recently by #279.
Do not call "afterError" on success
 * Back-port pull request #283 from strongloop/fix/afterError (Miroslav Bajtoš)
 * Do not call "afterError" on success (Miroslav Bajtoš)
"returns" arguments mapped to an http header should not be included
in the response body.
Allow users to specify { type: 'file', root: true } for the single
argument that will be sent directly as the response body.

The following values are supported for file the file argument:
 - String
 - Buffer
 - ReadableStream (anything that exposes .pipe() method)
…-2.x

Add support for "file" return args [2.x]

A back-port of #284
 * Add support for "file" return args (Miroslav Bajtoš)
 * Fix handling of args with http.target:header (Miroslav Bajtoš)
Set to no compression when using change stream
* Implement getEndpoints
* Deprecate getHttpMethod
* Deprecate getFullPath
@Amir-61 Amir-61 added the #review label Jun 6, 2016
@Amir-61

Amir-61 commented Jun 6, 2016

Copy link
Copy Markdown
Member Author

Closing since it needed to be based on 2.x as opposed to master branch.

@Amir-61 Amir-61 closed this Jun 6, 2016
@Amir-61
Amir-61 deleted the getEndpoints_2.x branch June 6, 2016 16:53
@Amir-61 Amir-61 removed the #review label Jun 6, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants