Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

rdf-body-parser

Package Overview
Dependencies
Maintainers
2
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rdf-body-parser

RDF body parsing middleware

  • 1.2.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
6
Maintainers
2
Weekly downloads
 
Created
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

Package last updated on 27 Nov 2019

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc