File tree Expand file tree Collapse file tree 3 files changed +7
-4
lines changed Expand file tree Collapse file tree 3 files changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -183,6 +183,7 @@ import { Projects } from 'gitlab';
183
183
const service = new Projects ({
184
184
host: ' http://example.com' , // Defaults to https://gitlab.com
185
185
token: ' abcdefghij123456' , // Can be created in your profile.
186
+ camelize = false , // Response Key Camelize. Camelizes all response body keys. Optional, Default: false
186
187
});
187
188
```
188
189
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ interface BaseModelOptions {
6
6
public readonly url : string ;
7
7
token ?: string ;
8
8
oauthToken ?: string ;
9
- useXMLHttpRequest ? : boolean ;
9
+ public readonly camelize : boolean ;
10
10
version ?: string ;
11
11
sudo ?: string | number ;
12
12
rejectUnauthorized ?: boolean ;
@@ -29,6 +29,7 @@ class BaseModel {
29
29
host = 'https://gitlab.com' ,
30
30
url = '' ,
31
31
version = 'v4' ,
32
+ camelize = false ,
32
33
rejectUnauthorized = true ,
33
34
} : BaseModelContructorOptions ) {
34
35
} : BaseServiceOptions ) {
@@ -38,6 +39,7 @@ class BaseModel {
38
39
? XMLHttpRequester : ( Request as temporaryAny as XhrStaticPromisified ) ;
39
40
this . useXMLHttpRequest = useXMLHttpRequest ;
40
41
this . rejectUnauthorized = rejectUnauthorized ;
42
+ this . camelize = camelize ;
41
43
42
44
// Handle auth tokens
43
45
if ( oauthToken ) this . headers . authorization = `Bearer ${ oauthToken } ` ;
Original file line number Diff line number Diff line change 1
1
import Humps from 'humps' ;
2
- import LinkParser from 'parse-link-header ' ;
2
+ import { camelizeKeys } from 'humps ' ;
3
3
import QS from 'qs' ;
4
4
import URLJoin from 'url-join' ;
5
5
import StreamableRequest from 'request' ;
@@ -46,8 +46,8 @@ function defaultRequest(
46
46
47
47
if ( body ) params . body = Humps . decamelizeKeys ( body ) ;
48
48
49
- if ( qs ) {
50
- if ( useXMLHttpRequest ) {
49
+ // Camelize response body if specified
50
+ if ( service . camelize ) body = camelizeKeys ( body ) ;
51
51
// The xhr package doesn't have a way of passing in a qs object until v3
52
52
params . url = URLJoin ( params . url , `?${ QS . stringify ( Humps . decamelizeKeys ( qs ) , { arrayFormat : 'brackets' } ) } ` ) ;
53
53
} else {
You can’t perform that action at this time.
0 commit comments