Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Find limited number of useful frameworks for operation #48

Open
bergos opened this issue Aug 5, 2019 · 0 comments
Open

Find limited number of useful frameworks for operation #48

bergos opened this issue Aug 5, 2019 · 0 comments

Comments

@bergos
Copy link

bergos commented Aug 5, 2019

With the loaders it would be possible to offer many different ways to implement operations. If we have to many options, developers get lost in choosing the right option and each framework needs time for the implementation and maintenance. There are two options which should cover a broad range of use cases.

SPARQL View

A SPARQL View is close to SPARQL, hides the express middleware stuff, but still allows using JavaScript to handle incoming data. Frameworks like clownface might be useful to handle incoming graph data. It's a quick solution for small APIs. The SPARQL View middleware already takes care of the request and response handling. The developer only needs to implement a JavaScript module that returns a SPARQL query string.

Example:

module.exports = () => {
  return `SELECT * WHERE { ... }`
}

Plain JS

Plain JS gives full access to the express middleware stuff, but other middlewares, that handle the request before it arrives at the Plain JS code, extend the req with some useful variables and functions that makes SPARQL queries almost as simple as with the SPARQL View.

SPARQL View example in Plain JS:

module.exports = (req, res) => {
  res.dataset(await req.sparqlClient.construct(`SELECT * WHERE { ... }`))
}

More complex example:

module.exports = (req, res) => {
  req.pipe(fs.createWriteStream('upload.txt'))
  req.sparqlClient.update(`INSERT DATA { ... }`)
  res.status(204).end()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants