Socket
Socket
Sign inDemoInstall

rdf-body-parser

Package Overview
Dependencies
115
Maintainers
2
Versions
11
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    rdf-body-parser

RDF body parsing middleware


Version published
Maintainers
2
Install size
13.9 MB
Created

Readme

Source

rdf-body-parser

Build Status npm version

The rdf-body-parser middleware parses incoming RDF data, parses it and attaches it with the property .graph to the request object. It also attaches the .graph function to the response to send a graph in the requested format.

Usage

Import the module:

const rdfBodyParser = require('rdf-body-parser')

The rdf-body-parser module returns a function to create a middleware. So let's call that function:

app.use(rdfBodyParser())

Now you can use the .graph property and .graph function:

app.use((req, res, next) => {
   // .graph contains the parsed graph
   if (req.graph) {
     console.log(req.graph.toString())
   }

   // .graph sends a graph to the client
   res.graph(rdf.dataset())
})

Attaching

If you don't know if rdf-body-parser is used as middleware, it's possible to attach it dynamically. That is useful inside of a middleware where you want to use an application specific instance (with application options) or the default one. .attach has no callback parameter, instead it returns a Promise.

app.use((req, res, next) => {
  rdfBodyParser.attach(req, res).then(() => {
    if (req.graph) {
      console.log(req.graph.toString())
    }

    res.graph(rdf.dataset())
  })
})

Keywords

FAQs

Last updated on 27 Nov 2019

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc