Skip to content

Commit

Permalink
core: add support for application/sparql-query content type
Browse files Browse the repository at this point in the history
  • Loading branch information
ludovicm67 committed Mar 13, 2024
1 parent 376a133 commit 46e7670
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/mighty-items-behave.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"trifid-core": patch
---

Add support for `application/sparql-query` content type
14 changes: 14 additions & 0 deletions packages/core/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,20 @@ const trifid = async (config, additionalPlugins = {}) => {
...serverOptions,
})

// Add support for `application/sparql-query` content type
server.addContentTypeParser('application/sparql-query', (_request, payload, done) => {
const data = []
payload.on('data', (chunk) => data.push(chunk))
payload.on('end', () => {
try {
const parsed = data.join('')
done(null, parsed)
} catch (err) {
done(err, undefined)
}
})
})

// This can be used to pass data from multiple plugins
/** @type {Map<string, any>} */
const trifidLocals = new Map()
Expand Down

0 comments on commit 46e7670

Please sign in to comment.