-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
838 additions
and
2,342 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,3 @@ | ||
async function get (req, res) { | ||
export async function get(req, res) { | ||
res.dataset(await req.hydra.resource.dataset()) | ||
} | ||
|
||
module.exports = { | ||
get | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import parent, { Environment } from '@zazuko/env-node' | ||
import alcaeus from 'alcaeus' | ||
|
||
export default new Environment([...alcaeus()], { parent }) |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,11 @@ | ||
const Hydra = require('alcaeus/with-parsers') | ||
const { rdfs } = require('@tpluscode/rdf-ns-builders') | ||
import rdf from './env.js' | ||
|
||
const baseUrl = 'http://localhost:9000/' | ||
|
||
async function getBlog () { | ||
const blog = await Hydra.loadResource(baseUrl) | ||
async function getBlog() { | ||
const blog = await rdf.hydra.loadResource(baseUrl) | ||
return blog.representation.root | ||
} | ||
|
||
getBlog() | ||
.then(res => console.log(`Blog title: ${res[rdfs.label.value].value}`)) | ||
.then(res => console.log(`Blog title: ${res[rdf.ns.rdfs.label.value].value}`)) |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,15 @@ | ||
const rdf = require('@rdfjs/data-model') | ||
const ns = require('./namespaces') | ||
import rdf from '@zazuko/env-node' | ||
|
||
// Generates IRIs for new resources based on the given rdf:type and parent. | ||
// An actual implementation could use a SPARQL query to find the next IRI. | ||
// A cluster version could use a in memory key value store + SPARQL init. | ||
async function generateIri (type, parent) { | ||
if (type.equals(ns.schema.Post)) { | ||
|
||
export default async function generateIri(type, parent) { | ||
if (type.equals(rdf.ns.schema.Post)) { | ||
const id = Math.floor(Math.random() * 100000) | ||
|
||
return rdf.namedNode(`${parent.value}post/${id}`) | ||
} | ||
|
||
throw new Error(`unknown type: ${type.value}`) | ||
} | ||
|
||
module.exports = generateIri |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,14 @@ | ||
const { resolve: resolvePath } = require('path') | ||
const { URL } = require('url') | ||
import { URL } from 'node:url' | ||
import { resolve as resolvePath } from 'node:path' | ||
|
||
function isRelative (iri) { | ||
return !iri.match(new RegExp('^[a-z]+:')) | ||
export function isRelative(iri) { | ||
return !iri.match(/^[a-z]+:/) | ||
} | ||
|
||
function resolve (baseIRI, relative) { | ||
export function resolve(baseIRI, relative) { | ||
const url = new URL(baseIRI) | ||
|
||
url.pathname = resolvePath(url.pathname, relative) | ||
|
||
return url.toString() | ||
} | ||
|
||
module.exports = { | ||
isRelative, | ||
resolve | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains 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
Oops, something went wrong.