Last active
November 1, 2015 20:17
-
-
Save bergos/b8a053699feeb7ff6d84 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 'use strict'; | |
| var | |
| fs = require('fs'), | |
| path = require('path'); | |
| var buildQuery = function (iri) { | |
| return 'DESCRIBE <' + iri + '>'; | |
| }; | |
| var buildExistsQuery = function (iri) { | |
| return 'ASK { GRAPH <http://dbpedia.org> { <' + iri + '> ?p ?o }}'; | |
| }; | |
| var patchResponseHeaders = function (res, headers) { | |
| if (res.statusCode === 200) { | |
| // clean existings values | |
| var fieldList = [ | |
| 'Access-Control-Allow-Origin', | |
| 'Cache-Control', | |
| 'Fuseki-Request-ID', | |
| 'Server', | |
| 'Vary']; | |
| if (res._headers) { | |
| fieldList.forEach(function (field) { | |
| if (field in res._headers) { | |
| delete res._headers[field]; | |
| } | |
| if (field.toLowerCase() in res._headers) { | |
| delete res._headers[field.toLowerCase()]; | |
| } | |
| }); | |
| } | |
| // cors header | |
| headers['Access-Control-Allow-Origin'] = '*'; | |
| // cache header | |
| headers['Cache-Control'] = 'public, max-age=120'; | |
| // vary header | |
| headers['Vary'] = 'Accept'; | |
| } | |
| return headers; | |
| }; | |
| module.exports = { | |
| app: 'trifid-ld', | |
| hostname: 'dbpedia.org', | |
| port: '', | |
| logger: { | |
| level: 'debug' | |
| }, | |
| listener: { | |
| port: 80 | |
| }, | |
| expressSettings: { | |
| 'trust proxy': 'loopback', | |
| 'x-powered-by': null | |
| }, | |
| patchHeaders: { | |
| patchResponse: patchResponseHeaders | |
| }, | |
| sparqlProxy: { | |
| path: '/raw/sparql', | |
| options: { | |
| endpointUrl:'http://dbpedia.org/sparql', | |
| queryOperation: 'urlencoded' | |
| } | |
| }, | |
| sparqlSearch: { | |
| path: '/query', | |
| options: { | |
| endpointUrl:'http://dbpedia.org/sparql', | |
| resultsPerPage: 5, | |
| queryTemplate: fs.readFileSync(path.join(__dirname, 'data/sparql/search.sparql')).toString(), | |
| variables: { | |
| 'q': { | |
| variable: '%searchstring%', | |
| required: true | |
| } | |
| } | |
| } | |
| }, | |
| HandlerClass: require('./lib/sparql-handler'), | |
| handlerOptions: { | |
| endpointUrl: 'http://dbpedia.org/sparql', | |
| buildQuery: buildQuery, | |
| buildExistsQuery: buildExistsQuery, | |
| hostname: 'dbpedia.org', | |
| port: '' | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment