2.6.8 • Published 2 years ago
@zazuko/sparql-proxy v2.6.8
sparql-proxy
This middleware forwards SPARQL queries to a SPARQL endpoint. It supports GET and POST (direct and URL-encoded) query requests and basic authentication.
Usage
The module exports a function to build a middleware. The function must be called with a single options object. The following options are supported:
endpointUrl: The URL of the SPARQL endpointauthentication: Credentials for basic authentication (object withuserandpasswordproperty)queryOperation: The query operation which will be used to access the SPARQL endpoint (default:postQueryDirect)fetchOptions: an object that will be merged (and potentially override) with node-fetch options used for the request from the proxy to the SPARQL endpoint. It can be used to override fetch headers:fetchOptions.headerstimeout: configure a timeout in milliseconds (default value:20000)cache: configure the cache with the following fields:url: connection string for the Redis instance (redis://…orrediss://…)ttl: the time a value should be kept in the cache in seconds (default value:3600, which is one hour)clearAtStartup: set totrueto remove all entries in the cache at the start of the proxy (default:false)disabled: set totrueto disable the cache (default:false)prefix: set a custom prefix for all entries in Redis (default:default)
Example
// load the module
const sparqlProxy = require('@zazuko/sparql-proxy')
// create a middleware instance and add it to the routing
app.use(sparqlProxy({
endpointUrl: 'https://dbpedia.org/sparql'
})Debug
This package uses debug, you can get debug logging via: DEBUG=sparql-proxy.
Since Trifid makes heavy use of this package, using DEBUG=trifid:* also enables
logging in this package.