This updates an nq-file to reflect the changes of the content of RDF-Turtle files in a git (gittea) repository.
It uses ghact to provide a webhook and a web/rest interface.
The server provides the following web endpoints:
/nquads- Returns all RDF data as N-Quads format by concatenating individual n-triples files and adding graph names (determined by the filename)/ntriples- Returns all RDF data as N-Triples format by concatenating individual n-triples files
Both endpoints stream data directly from disk (line-by-line for /nquads) to keep memory usage low even for very large datasets.
Because a full export walks every n-triples file, a complete response takes several minutes for a large dataset. To let callers tell "still working" from "hung", the response is not silent while this happens:
- the first line, sent immediately, is a comment (
# turtle-hook-nq N-Quads export started <timestamp>), - pending data is flushed at least every few seconds, and if nothing could be sent for a while a comment line
# still working: ...is emitted, - the last line is
# export complete: <n> files, <m> unique triples, took <s>s, so a truncated download can be recognized.
Comment lines are part of the N-Triples/N-Quads grammar and are ignored by RDF parsers. Duplicate triples (identical lines in several files) are emitted only once.
Rather than maintaining a single consolidated n-quads file, the system now keeps individual n-triples files matching the turtle file structure. When turtle files are added, modified, or removed, the corresponding n-triples files are updated in the /workdir/ntriples directory.
Run all unit tests:
deno test --allow-read --allow-writeRun specific test files:
deno test --allow-read --allow-write src/endpoints.test.ts