https://github.com/hypermedia-app/express-rdf-problem-details
hydra-box error handler which returns HTTP Problem Details with JSON-LD context link
https://github.com/hypermedia-app/express-rdf-problem-details
Last synced: 25 days ago
JSON representation
hydra-box error handler which returns HTTP Problem Details with JSON-LD context link
- Host: GitHub
- URL: https://github.com/hypermedia-app/express-rdf-problem-details
- Owner: hypermedia-app
- License: mit
- Created: 2021-10-31T15:38:29.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2023-02-28T05:03:52.000Z (over 3 years ago)
- Last Synced: 2025-02-23T01:44:07.549Z (over 1 year ago)
- Language: TypeScript
- Size: 656 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 10
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# express-rdf-problem-details
This package wraps [express-http-problem-details](https://github.com/PDMLab/express-http-problem-details) so that RDF/Linked Data express applications will return Problem documents ([RFC7807](https://tools.ietf.org/html/rfc7807)) as valid JSON-LD.
This is done simply by adding a `Link` header pointing to a JSON-LD `@context`. By default, it's the [context provided by Hydra Community Group](http://www.hydra-cg.com/spec/latest/core/#example-31-rfc-7807-compatible-error-description)
## Usage
```typescript
import express from 'express'
import * as error from 'express-rdf-problem-details'
import { NotFoundMapper } from './error-mappers'
const app = express()
// All params optional
express.use(error.handler({
// change the @context URL
context: 'http://example.com/error.jsonld',
// additional mappers to customize error documents
mappers: [new NotFoundMapper()]
}))
```
Implementing mappers is explained in [PDMLab/express-http-problem-details](https://github.com/PDMLab/express-http-problem-details#example)