@@ -5,7 +5,6 @@ var glob = require('glob')
55var _path = require ( 'path' )
66var $rdf = require ( 'rdflib' )
77var S = require ( 'string' )
8- var async = require ( 'async' )
98var Negotiator = require ( 'negotiator' )
109const url = require ( 'url' )
1110const mime = require ( 'mime-types' )
@@ -161,35 +160,28 @@ function globHandler (req, res, next) {
161160 let reqOrigin = utils . getBaseUri ( req )
162161
163162 debugGlob ( 'found matches ' + matches )
164- async . each ( matches , function ( match , done ) {
163+ Promise . all ( matches . map ( match => new Promise ( ( resolve , reject ) => {
165164 var baseUri = utils . filenameToBaseUri ( match , reqOrigin , root )
166165 fs . readFile ( match , { encoding : 'utf8' } , function ( err , fileData ) {
167166 if ( err ) {
168167 debugGlob ( 'error ' + err )
169- return done ( null )
168+ return resolve ( )
170169 }
171170 aclAllow ( match , req , res , function ( allowed ) {
172171 if ( ! S ( match ) . endsWith ( '.ttl' ) || ! allowed ) {
173- return done ( null )
172+ return resolve ( )
174173 }
175174 try {
176- $rdf . parse (
177- fileData ,
178- globGraph ,
179- baseUri ,
180- 'text/turtle' )
175+ $rdf . parse ( fileData , globGraph , baseUri , 'text/turtle' )
181176 } catch ( parseErr ) {
182- debugGlob ( ' error in parsing the files' + parseErr )
177+ debugGlob ( ` error parsing ${ match } : ${ parseErr } ` )
183178 }
184- return done ( null )
179+ return resolve ( )
185180 } )
186181 } )
187- } , function ( ) {
188- var data = $rdf . serialize (
189- undefined ,
190- globGraph ,
191- requestUri ,
192- 'text/turtle' )
182+ } ) ) )
183+ . then ( ( ) => {
184+ var data = $rdf . serialize ( undefined , globGraph , requestUri , 'text/turtle' )
193185 // TODO this should be added as a middleware in the routes
194186 res . setHeader ( 'Content-Type' , 'text/turtle' )
195187 debugGlob ( 'returning turtle' )
0 commit comments