feat(fastify-rdf): add RDF content type parser for request bodies#187
Merged
feat(fastify-rdf): add RDF content type parser for request bodies#187
Conversation
- Add `parseRdf` plugin option that registers Fastify content type
parsers for all RDF formats supported by rdf-parse
- Routes opt in via `config: { parseRdf: true }`; the body is parsed
into a DatasetCore (N3 Store)
- Routes without that config get JSON fallback for application/ld+json
and 415 for other RDF types
- Add rdf-parse dependency; move n3 from devDependencies to dependencies
- Add tests for Turtle, JSON-LD, N-Triples parsing, fallback, 415, and
malformed body handling
- Document the new option in README
…el option
- Remove `parseRdf` from `FastifyRdfOptions`; parsers are now always
registered — the only knob is per-route `config: { parseRdf: true }`
- Remove redundant test for the removed plugin-level gate
- Update README to reflect the simplified API
- Re-add `parseRdf` to `FastifyRdfOptions` — when set, all routes get
RDF body parsing without needing per-route config
- Per-route `config: { parseRdf: true }` still works for selective use
- Add test for plugin-level parseRdf behaviour
- Update README to document both modes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The
@lde/fastify-rdfplugin already handles RDF output (serialisation viasendRdf()); this adds the natural complement: RDF input (deserialisation via content type parsers).rdf-parseDatasetCore(N3 Store):config: { parseRdf: true }on individual routesparseRdf: trueon the plugin options — applies to all routesapplication/ld+jsonand 415 Unsupported Media Type for other RDF typesrdf-parseto dependencies; moven3fromdevDependenciestodependenciesFastifyContextConfigwith typedparseRdfpropertyFix #185
Test plan
npx nx test fastify-rdf— 19 tests passnpx nx lint fastify-rdf— no errorsnpx nx typecheck fastify-rdf— no type errorsnpx nx build fastify-rdf— builds successfully