1+ /*
2+ * Copyright (C) 2014-present Cloudflare, Inc.
3+
4+ * This software may be modified and distributed under the terms
5+ * of the MIT license. See the LICENSE file for details.
6+ */
7+
18'use strict' ;
2- var prototypal = require ( 'es-class' ) ;
3- var pkg = require ( '../package.json' ) ;
4- var Getter = require ( './Getter' ) ;
59
6- var USER_AGENT = JSON . stringify ( {
10+ const prototypal = require ( 'es-class' ) ;
11+ const pkg = require ( '../package.json' ) ;
12+ const Getter = require ( './Getter' ) ;
13+
14+ const USER_AGENT = JSON . stringify ( {
715 bindings_version : pkg . version , // eslint-disable-line camelcase
816 lang : 'node' ,
917 lang_version : process . version , // eslint-disable-line camelcase
1018 platform : process . platform ,
1119 arch : process . arch ,
12- publisher : 'cloudflare'
20+ publisher : 'cloudflare' ,
1321} ) ;
1422
15- function isPlainObject ( x ) {
16- var prototype = Object . getPrototypeOf ( x ) ;
17- var toString = Object . prototype . toString ;
23+ const isPlainObject = function isPlainObject ( x ) {
24+ const prototype = Object . getPrototypeOf ( x ) ;
25+ const toString = Object . prototype . toString ;
1826
19- return toString . call ( x ) === '[object Object]' &&
20- ( prototype === null || prototype === Object . getPrototypeOf ( { } ) ) ;
21- }
27+ return (
28+ toString . call ( x ) === '[object Object]' &&
29+ ( prototype === null || prototype === Object . getPrototypeOf ( { } ) )
30+ ) ;
31+ } ;
2232
23- function isUserServiceKey ( x ) {
33+ const isUserServiceKey = function isUserServiceKey ( x ) {
2434 return x && x . substring ( 0 , 5 ) === 'v1.0-' ;
25- }
35+ } ;
2636
2737module . exports = prototypal ( {
28- constructor : function ( options ) {
38+ constructor : function constructor ( options ) {
2939 this . email = options . email ;
3040 this . key = options . key ;
3141 this . getter = new Getter ( options ) ;
3242 } ,
33- request : function ( requestMethod , requestPath , data , opts ) {
34- var uri = ' https://api.cloudflare.com/client/v4/' + requestPath ;
43+ request ( requestMethod , requestPath , data , opts ) {
44+ const uri = ` https://api.cloudflare.com/client/v4/${ requestPath } ` ;
3545
36- var options = {
46+ const options = {
3747 json : true ,
38- timeout : opts . timeout || 1E4 ,
48+ timeout : opts . timeout || 1e4 ,
3949 retries : opts . retries ,
4050 method : requestMethod ,
4151 headers : {
42- 'user-agent' : ' cloudflare/' + pkg . version + ' node/' + process . versions . node ,
52+ 'user-agent' : ` cloudflare/${ pkg . version } node/${ process . versions . node } ` ,
4353 'Content-Type' : 'application/json' ,
4454 Accept : 'application/json' ,
45- 'X-Cloudflare-Client-User-Agent' : USER_AGENT
46- }
55+ 'X-Cloudflare-Client-User-Agent' : USER_AGENT ,
56+ } ,
4757 } ;
4858
4959 if ( isUserServiceKey ( opts . auth . key || this . key ) ) {
@@ -63,8 +73,6 @@ module.exports = prototypal({
6373 options . body = JSON . stringify ( options . body ) ;
6474 }
6575
66- return this . getter . got ( uri , options ) . then ( function ( res ) {
67- return res . body ;
68- } ) ;
69- }
76+ return this . getter . got ( uri , options ) . then ( res => res . body ) ;
77+ } ,
7078} ) ;
0 commit comments