strongloop / strong-remoting

Communicate between objects in servers, mobile apps, and other servers.
www.strongloop.com
Other
105 stars 93 forks source link

Cleanup argument coercion and validation #208

Closed bajtos closed 8 years ago

bajtos commented 9 years ago

A follow-up for #207.

bajtos commented 8 years ago

I like the (re)design presented by @STRML in https://github.com/strongloop/strong-remoting/issues/312, especially the fact that we treat built-in and user-provided converters the same way.

I would like to push it a bit further so that user-provided converters can decide how to deal with sloppy coercion from url-encoded sources.

Here are few high-level cases that each converter has to support:

Additionally, I'd like to make it easy for for user-provided converters to run built-in sloppy conversion first before applying further transformation.

Last but not least, the registry of converters should be scoped to RemoteObject instance, as opposed to current global singleton Dynamic. This is needed to support applications running multiple LoopBack app instances in the same process, where each app may provide different converter for the same type (model name). For backwards compatibility, we can fall back to global Dynamic for types that are not found in the local registry.

/cc @ritch @alexpit

bajtos commented 8 years ago

Most of the items were already done in #343.

Refactor handling of "accepts" and "returns" type descriptors, create a class providing information like "isArrayType" or "isAnyType".

This was not needed in the new implementation.