Skip to content

Navigation Menu

Sign in
Sign up

Latest commit

History

4 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

express-sparql

Easy SPARQL server with express.js.

Installation

npm install express-sparql

Example

import * as express from 'express';
import * as bodyParser from 'body-parser';
import handleSPARQL from 'express-sparql';
const PORT = '3000';
const server = express();
server.all('/sparql',
 bodyParser.urlencoded(),
 bodyParser.text({ type: [ 'application/sparql-query', 'application/sparql-update' ]}),
 handleSPARQL({
 queryFn: async (query) => {
 const json = await DB.query(query);
 return json;
 },
 updateFn: async (update) => {
 const json = await DB.update(update);
 return json;
 },
 encodeFn: async (result, encoding) => JSON.stringify(result),
 })
);
server.listen(PORT);

See also: https://github.com/knowledge-express/poseidon.

TODO

  • Encoding logic (i.e. content-negotiation)
  • Better error handling

About

Easy SPARQL server with express.js

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages

AltStyle によって変換されたページ (->オリジナル) /