Skip to content

Commit

Permalink
Merge pull request #66 from oliviervd/master
Browse files Browse the repository at this point in the history
add versioning
  • Loading branch information
oliviervd authored Jul 29, 2024
2 parents d89210d + 8c13134 commit 36b2d3e
Show file tree
Hide file tree
Showing 14 changed files with 183 additions and 208 deletions.
31 changes: 16 additions & 15 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ import {Dump} from "./src/routes/data-dump.js";
import {requestConcept} from "./src/routes/thesaurus.js";
import {requestByColor} from "./src/routes/colors.js";

const BASE_URI = "https://data.designmuseumgent.be/v1/";

async function start() {
// setup accept-headers
const app = express();
Expand All @@ -43,44 +45,43 @@ async function start() {
console.log(`app listening on port ${port}`),
);

const baseURI = "https://data.designmuseumgent.be/";

// ROUTE to top level DCAT
requestDCAT(app);
requestDCAT(app, BASE_URI);

// ROUTES to human-made objects
requestObjects(app); // request list of all published human-made objects
requestObject(app); // request individual entity (human-made object) using content-negotiation.
requestObjects(app, BASE_URI); // request list of all published human-made objects
requestObject(app, BASE_URI); // request individual entity (human-made object) using content-negotiation.

// ROUTE to COLOR-API
requestByColor(app);
requestByColor(app, BASE_URI);

// ROUTE to PRIVATE objects
requestPrivateObjects(app);
requestPrivateObjects(app, BASE_URI);

// ROUTES to exhibition data
const billboard = await fetchAllBillboards(); // fetch data from supabase
requestAllBillboards(app); // request all billboards. (endpoint)
requestExhibition(app); // request all exhibitions
requestExhibitions(app); // request single exhibition
requestAllBillboards(app, BASE_URI); // request all billboards. (endpoint)
requestExhibition(app, BASE_URI); // request all exhibitions
requestExhibitions(app, BASE_URI); // request single exhibition

// ROUTES to agent (authority list) data
requestAgents(app);
requestAgents(app, BASE_URI);

// ROUTE to concepts (thesaurus)
requestConcept(app);
requestConcept(app, BASE_URI);

// ROUTES to archive (posters)
requestArchive(app);
requestArchive(app, BASE_URI);

// ROUTES to texts that are related to the collection of Design Museum Gent
requestTexts(app);
requestTexts(app, BASE_URI);

// ROUTE to randomimage
//requestRandomImage(app);
requestRandomImage(app, BASE_URI);

// ROUTE to DUMP
Dump(app);
Dump(app, BASE_URI);
}

start();
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
"eject": "react-scripts eject",
"heroku-postbuild": "npm run build"
},
"keywords": [],
"author": "",
"keywords": ["REST", "rest-API", "GLAM", "design", "heritage", "linked open data"],
"author": "Olivier Van D'huynslager",
"license": "ISC",
"dependencies": {
"@supabase/supabase-js": "^2.4.1",
Expand Down
9 changes: 4 additions & 5 deletions src/routes/agents.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {fetchLDESAllAgents, fetchLDESRecordByAgentID} from "../utils/parsers.js";

export function requestAgents(app) {
app.get('/id/agents/', async(req, res) => {
export function requestAgents(app, BASE_URI) {
app.get('/v1/id/agents/', async(req, res) => {
res.set('Content-Type', 'application/json+ld;charset=utf-8')
const x = await fetchLDESAllAgents();

Expand All @@ -22,14 +22,13 @@ export function requestAgents(app) {

for( let i = 0; i < x.length; i ++) {
let _agent = {}
const baseURI = "https://data.designmuseumgent.be/"

_agent["@context"] = [
"https://apidg.gent.be/opendata/adlib2eventstream/v1/context/persoon-basis.jsonld",
"https://apidg.gent.be/opendata/adlib2eventstream/v1/context/cultureel-erfgoed-object-ap.jsonld",
"https://apidg.gent.be/opendata/adlib2eventstream/v1/context/cultureel-erfgoed-event-ap.jsonld"
]
_agent["@id"] = baseURI+"id/agent/"+x[i]["agent_ID"]
_agent["@id"] = BASE_URI+"id/agent/"+x[i]["agent_ID"]
_agent["@type"] = "Persoon"
_agent["Persoon.identificator"]=[
{
Expand All @@ -55,7 +54,7 @@ export function requestAgents(app) {
}
})

app.get('/id/agent/:agentPID', async(req, res) => {
app.get('/v1/id/agent/:agentPID', async(req, res) => {
const x = await fetchLDESRecordByAgentID(req.params.agentPID);
const result_cidoc = x

Expand Down
6 changes: 3 additions & 3 deletions src/routes/archief.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
// API generator for Archives of Design Museum Gent
import {fetchArchiveByObjectNumber} from "../utils/parsers.js";

export function requestArchive(app) {
app.get('/id/archive/:objectNumber', async(req, res)=> {
export function requestArchive(app, BASE_URI) {
app.get('/v1/id/archive/:objectNumber', async(req, res)=> {
console.log(req.params.objectNumber)
const object = await fetchArchiveByObjectNumber(req.params.objectNumber);

// construct id for isPartOf:
const PID = req.params.objectNumber.split("_Aff")[0]
const exh_PURI = `https://data.designmuseumgent.be/id/exhibition/${PID}`
const exh_PURI = `${BASE_URI}id/exhibition/${PID}`

//todo: remove when in LDES.
object[0]["LDES_raw"]["object"]["http://purl.org/dc/terms/isPartOf"]["cidoc:P16_used_specific_object"]["@id"] = exh_PURI
Expand Down
4 changes: 2 additions & 2 deletions src/routes/billboards.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {fetchAllBillboards} from "../utils/parsers.js";
export function requestAllBillboards(app) {
app.get('/id/exhibitions/billboardseries/', async (req, res) => {
export function requestAllBillboards(app, BASE_URI) {
app.get('/v1/id/exhibitions/billboardseries/', async (req, res) => {
// ASYNC FUNCTION THAT AWAITS fetch from Supabase.
const billboard = await fetchAllBillboards()

Expand Down
6 changes: 3 additions & 3 deletions src/routes/colors.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

import {fetchAllLDESrecordsObjects} from "../utils/parsers.js";

export function requestByColor(app) {
export function requestByColor(app, BASE_URI) {

app.get('/colors/', (req, res) => {
app.get('/v1/colors/', (req, res) => {
res.status(200).send(colors_dict)
})

app.get('/color-api/:color', async (req, res) => {
app.get('/v1/color-api/:color', async (req, res) => {

// fetch all objects
const objects = await fetchAllLDESrecordsObjects();
Expand Down
4 changes: 2 additions & 2 deletions src/routes/data-dump.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import {
parseBoolean
} from "../utils/parsers.js";
import {supabase} from "../../supabaseClient.js";
export function Dump(app) {
export function Dump(app, BASE_URI) {

let types = ["concepts", "objects", "agents", "exhibitions"]

app.get("/dump/:type", async(req, res)=> {
app.get("/v1/dump/:type", async(req, res)=> {
// await RES from DB req
// if not existing type; return error message

Expand Down
14 changes: 7 additions & 7 deletions src/routes/dcat.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import negotiate from "express-negotiate";

export function requestDCAT(app) {
app.get("/", (req, res) => {
export function requestDCAT(app, BASE_URI) {
app.get("/v1/", (req, res) => {
//res.set('Content-Type', 'application/json+ld;charset=utf-8')
res.send({
"@context": [
Expand All @@ -11,7 +11,7 @@ export function requestDCAT(app) {
tree: "https://w3id.org/tree#",
},
],
"@id": "https://data.designmuseumgent.be/",
"@id": BASE_URI,
"@type": "Datasetcatalogus",
"Catalogus.titel": {
"@value": "catalogus Design Museum Gent",
Expand Down Expand Up @@ -51,7 +51,7 @@ export function requestDCAT(app) {
],
"Catalogus.heeftDataset": [
{
"@id": "https://data.designmuseumgent.be/id/objects/",
"@id": BASE_URI +"objects/",
"@type": "Dataset",
"Dataset.titel": [
{
Expand All @@ -69,7 +69,7 @@ export function requestDCAT(app) {
"https://metadata.vlaanderen.be/id/GDI-Vlaanderen-Trefwoorden/VLOPENDATASERVICE",
},
{
"@id": "https://data.designmuseumgent.be/id/exhibitions/",
"@id": BASE_URI+"exhibitions/",
"@type": "Dataset",
"Dataset.titel": [
{
Expand All @@ -87,7 +87,7 @@ export function requestDCAT(app) {
"https://metadata.vlaanderen.be/id/GDI-Vlaanderen-Trefwoorden/VLOPENDATASERVICE",
},
{
"@id": "https://data.designmuseumgent.be/id/agents/",
"@id": BASE_URI+"agents/",
"@type": "Dataset",
"Dataset.titel": [
{
Expand All @@ -106,7 +106,7 @@ export function requestDCAT(app) {
},
{
"@id":
"https://data.designmuseumgent.be/id/exhibitions/billboardseries",
BASE_URI+"exhibitions/billboardseries",
"@type": "Dataset",
"Dataset.titel": [
{
Expand Down
13 changes: 6 additions & 7 deletions src/routes/exhibitions.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
import {fetchAllExhibitions, fetchLDESrecordsByExhibitionID} from "../utils/parsers.js";

export function requestExhibitions(app) {
app.get('/id/exhibitions', async(req, res)=> {
export function requestExhibitions(app, BASE_URI) {
app.get('/v1/id/exhibitions', async(req, res)=> {
const exh = await fetchAllExhibitions()
let range = exh.length
let _exhibitions = []
const baseURI = "https://data.designmuseumgent.be/"

for (let i = 0; i < range; i ++) {
let _exhibition = {}

// generate PURI for exhibition
_exhibition["@id"] = baseURI+"id/exhibition/"+exh[i]["exh_PID"]
_exhibition["@id"] = BASE_URI+"id/exhibition/"+exh[i]["exh_PID"]

// parse title from LDES feed - if no title available use value "title unknown".
let _title = "title unknown"
Expand All @@ -36,10 +35,10 @@ export function requestExhibitions(app) {
})
}

export function requestExhibition(app) {
export function requestExhibition(app, BASE_URI) {

// FLEMISH URI STANDARD.
app.get('/id/exhibition/:exhibitionPID', async (req, res)=> {
app.get('/v1/id/exhibition/:exhibitionPID', async (req, res)=> {
const x = await fetchLDESrecordsByExhibitionID(req.params.exhibitionPID)
try{
//res.send(x[0]["LDES_raw"])
Expand All @@ -51,7 +50,7 @@ export function requestExhibition(app) {
})

// ARK
app.get('/id/ark:/29417/exhibition/:exhibitionPID', async (req, res)=> {
app.get('/v1/id/ark:/29417/exhibition/:exhibitionPID', async (req, res)=> {
const x = await fetchLDESrecordsByExhibitionID(req.params.exhibitionPID)
try{
const result_cidoc = x[0]["LDES_raw"];
Expand Down
Loading

0 comments on commit 36b2d3e

Please sign in to comment.