1- const jQuery = require ( './jquery' ) ;
2- const Superagent = require ( './superagent' ) ;
3- const Request = require ( './request' ) ;
4- const Fetch = require ( './fetch' ) ;
5- const Axios = require ( './axios' ) ;
6- const Angular = require ( './angular' ) ;
1+ const jQueryClient = require ( './jquery' ) ;
2+ const SuperagentClient = require ( './superagent' ) ;
3+ const RequestClient = require ( './request' ) ;
4+ const FetchClient = require ( './fetch' ) ;
5+ const AxiosClient = require ( './axios' ) ;
6+ const AngularClient = require ( './angular' ) ;
77const Base = require ( './base' ) ;
88const AngularHttpClient = require ( './angular-http-client' ) ;
99
1010const transports = {
11- jquery : jQuery ,
12- superagent : Superagent ,
13- request : Request ,
14- fetch : Fetch ,
15- axios : Axios ,
16- angular : Angular ,
11+ jquery : jQueryClient ,
12+ superagent : SuperagentClient ,
13+ request : RequestClient ,
14+ fetch : FetchClient ,
15+ axios : AxiosClient ,
16+ angular : AngularClient ,
1717 angularHttpClient : AngularHttpClient
1818} ;
1919
2020function restClient ( base = '' ) {
2121 const result = { Base } ;
2222
2323 Object . keys ( transports ) . forEach ( key => {
24- const Service = transports [ key ] ;
25-
26- result [ key ] = function ( connection , options = { } ) {
24+ result [ key ] = function ( connection , options = { } , Service = transports [ key ] ) {
2725 if ( ! connection ) {
2826 throw new Error ( `${ key } has to be provided to feathers-rest` ) ;
2927 }
3028
29+ if ( typeof options === 'function' ) {
30+ Service = options ;
31+ options = { } ;
32+ }
33+
3134 const defaultService = function ( name ) {
3235 return new Service ( { base, name, connection, options } ) ;
3336 } ;
@@ -51,5 +54,5 @@ function restClient (base = '') {
5154 return result ;
5255}
5356
54- module . exports = restClient ;
57+ module . exports = Object . assign ( restClient , { SuperagentClient , FetchClient , jQueryClient , RequestClient , AxiosClient , AngularClient , AngularHttpClient } ) ;
5558module . exports . default = restClient ;
0 commit comments