88// - Setting additional response headers
99//
1010function get ( context , params ) {
11- var results = [ ] ;
11+ let results = [ ] ;
1212 context . outputTypes = [ ] ;
13- for ( var pname in params ) {
13+ for ( const pname in params ) {
1414 if ( params . hasOwnProperty ( pname ) ) {
1515 results . push ( { name : pname , value : params [ pname ] } ) ;
1616 context . outputTypes . push ( 'application/json' ) ;
@@ -28,7 +28,7 @@ function get(context, params) {
2828
2929 // Return a Sequence to return multiple documents
3030 return Sequence . from ( results ) ;
31- } ;
31+ }
3232
3333// PUT
3434//
@@ -49,8 +49,8 @@ function get(context, params) {
4949//
5050function put ( context , params , input ) {
5151 // normalize the inputs so we don't care whether we have 1 or many
52- var docs = normalizeInput ( input ) ;
53- var basenames = params . basename instanceof Array
52+ const docs = normalizeInput ( input ) ;
53+ const basenames = params . basename instanceof Array
5454 ? params . basename : [ params . basename ] ;
5555
5656 // Validate inputs.
@@ -62,9 +62,9 @@ function put(context, params, input) {
6262 }
6363
6464 // Do something with the input documents
65- var i = 0 ;
66- var uris = [ ] ;
67- for ( var doc of docs ) {
65+ let i = 0 ;
66+ const uris = [ ] ;
67+ for ( const doc of docs ) {
6868 uris . push ( doSomething (
6969 doc , context . inputTypes [ i ] , basenames [ i ++ ]
7070 ) ) ;
@@ -73,17 +73,17 @@ function put(context, params, input) {
7373 // Set the response body MIME type and return the response data.
7474 context . outputTypes = [ 'application/json' ] ;
7575 return { written : uris } ;
76- } ;
76+ }
7777
7878function post ( context , params , input ) {
7979 xdmp . log ( 'POST invoked' ) ;
8080 return null ;
81- } ;
81+ }
8282
8383function deleteFunction ( context , params ) {
8484 xdmp . log ( 'POST invoked' ) ;
8585 return null ;
86- } ;
86+ }
8787
8888// PUT helper func that demonstrates working with input documents.
8989//
@@ -99,10 +99,10 @@ function deleteFunction(context, params) {
9999//
100100function doSomething ( doc , docType , basename )
101101{
102- var uri = '/extensions/' + basename ;
102+ let uri = '/extensions/' + basename ;
103103 if ( docType == 'application/json' ) {
104104 // create a mutable version of the doc so we can modify it
105- var mutableDoc = doc . toObject ( ) ;
105+ const mutableDoc = doc . toObject ( ) ;
106106 uri += '.json' ;
107107
108108 // add a JSON property to the input content
@@ -117,7 +117,7 @@ function doSomething(doc, docType, basename)
117117 } else {
118118 return '(skipped)' ;
119119 }
120- } ;
120+ }
121121
122122// Helper function that demonstrates how to normalize inputs
123123// that may or may not be multi-valued, such as the 'input'
@@ -132,7 +132,7 @@ function normalizeInput(item)
132132 return ( item instanceof Sequence )
133133 ? item // many
134134 : Sequence . from ( [ item ] ) ; // one
135- } ;
135+ }
136136
137137// Helper function that demonstrates how to return an error response
138138// to the client.
@@ -145,7 +145,7 @@ function returnErrToClient(statusCode, statusMsg, body)
145145 fn . error ( null , 'RESTAPI-SRVEXERR' ,
146146 Sequence . from ( [ statusCode , statusMsg , body ] ) ) ;
147147 // unreachable - control does not return from fn.error.
148- } ;
148+ }
149149
150150
151151// Include an export for each method supported by your extension.
0 commit comments