@@ -4,6 +4,8 @@ const flat = require('flat');
44const DB_OPTIONS = require ( './dbopts' ) ;
55const { httpBody } = require ( '../response-transforms' ) ;
66
7+ const FLATTENED_DB_OPTIONS = flat . flatten ( DB_OPTIONS ) ;
8+
79const dispatchDBOptions = ( conn , config , body ) => {
810 config . headers . set ( 'Content-Type' , 'application/json' ) ;
911
@@ -13,7 +15,7 @@ const dispatchDBOptions = (conn, config, body) => {
1315 } ;
1416
1517 if ( body ) {
16- requestOptions . body = JSON . stringify ( flat ( body , { safe : true } ) ) ;
18+ requestOptions . body = JSON . stringify ( body ) ;
1719 }
1820 return fetch (
1921 conn . request ( 'admin' , 'databases' , config . database , 'options' ) ,
@@ -33,17 +35,8 @@ const get = (conn, database, params) => {
3335 // TODO now that `getAll` is available, remove use of DB_OPTIONS and require
3436 // user to specify which options they want
3537 // Do we want to do this for v3+ of stardog.js?
36- params || DB_OPTIONS // the default list of options to GET values for
37- )
38- . then ( httpBody )
39- . then ( res => {
40- if ( res . status === 200 ) {
41- return Object . assign ( { } , res , {
42- body : flat . unflatten ( res . body ) ,
43- } ) ;
44- }
45- return res ;
46- } ) ;
38+ params || FLATTENED_DB_OPTIONS // the default list of options to GET values for
39+ ) . then ( httpBody ) ;
4740} ;
4841
4942const getAll = ( conn , database ) => {
@@ -52,16 +45,7 @@ const getAll = (conn, database) => {
5245 headers,
5346 database,
5447 method : 'GET' ,
55- } )
56- . then ( httpBody )
57- . then ( res => {
58- if ( res . status === 200 ) {
59- return Object . assign ( { } , res , {
60- body : flat . unflatten ( res . body ) ,
61- } ) ;
62- }
63- return res ;
64- } ) ;
48+ } ) . then ( httpBody ) ;
6549} ;
6650
6751const set = ( conn , database , databaseOptions , params ) => {
@@ -83,16 +67,7 @@ const getAvailable = conn => {
8367 return fetch ( conn . request ( 'admin' , 'config_properties' ) , {
8468 method : 'GET' ,
8569 headers,
86- } )
87- . then ( httpBody )
88- . then ( res => {
89- if ( res . status === 200 ) {
90- return Object . assign ( { } , res , {
91- body : flat . unflatten ( res . body ) ,
92- } ) ;
93- }
94- return res ;
95- } ) ;
70+ } ) . then ( httpBody ) ;
9671} ;
9772
9873module . exports = { get, getAll, set, getAvailable } ;
0 commit comments