From 729944f2f0805fc4b40fbd21d2386c4c290414a7 Mon Sep 17 00:00:00 2001 From: Jan Forberg Date: Wed, 15 May 2024 11:01:48 +0200 Subject: [PATCH] package updates --- Dockerfile | 39 ++++++++++++---------- server/app/api/lib/dataid-autocomplete.js | 20 ++++++----- server/app/common/get-jsonld.js | 4 --- server/app/pages/modules/resource-pages.js | 1 - server/package.json | 5 +-- 5 files changed, 36 insertions(+), 33 deletions(-) diff --git a/Dockerfile b/Dockerfile index c11a15f..24d393d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,15 +1,31 @@ -FROM ubuntu:22.04 +FROM node:18 AS installer + +COPY ./server/package.json ./server/package-lock.json /server/ +COPY ./public/package.json ./public/package-lock.json /public/ + +# Set up the NPM projects: +RUN cd /server && \ + npm install && \ + cd ../public && \ + npm install + + +FROM ubuntu:22.04 AS release + +COPY --from=installer /server/node_modules /databus/server/node_modules +COPY --from=installer /public/node_modules /databus/public/node_modules # Install node.js, Caddy as proxy server, and java. RUN apt-get update && \ - apt-get -y install curl debian-keyring debian-archive-keyring apt-transport-https && \ + apt-get -y install curl wget systemctl debian-keyring debian-archive-keyring apt-transport-https && \ + wget https://github.com/caddyserver/caddy/releases/download/v2.7.6/caddy_2.7.6_linux_amd64.deb && \ + dpkg -i ./caddy_2.7.6_linux_amd64.deb && \ + caddy version && \ + systemctl daemon-reload && systemctl enable --now caddy && \ curl -sL https://deb.nodesource.com/setup_16.x | bash - && \ - curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg && \ - curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' | tee /etc/apt/sources.list.d/caddy-stable.list && \ apt-get update && \ apt-get -y install \ nodejs \ - caddy \ ca-certificates-java \ openjdk-17-jdk \ openjdk-17-jre && \ @@ -39,18 +55,7 @@ ENV DATABUS_PROXY_SERVER_HOSTNAME="my-databus.org" # Define the volume for the TLS certificate: VOLUME /tls -COPY ./server /databus/server -COPY ./public /databus/public -COPY ./search /databus/search -COPY ./model/generated /databus/model/generated - -COPY ./setup.sh /databus/setup.sh - -# Set up the NPM projects: -RUN cd /databus/server && \ - npm install && \ - cd ../public && \ - npm install +COPY . /databus WORKDIR /databus ENTRYPOINT [ "/bin/bash", "./setup.sh" ] diff --git a/server/app/api/lib/dataid-autocomplete.js b/server/app/api/lib/dataid-autocomplete.js index feda112..5d6d5b2 100644 --- a/server/app/api/lib/dataid-autocomplete.js +++ b/server/app/api/lib/dataid-autocomplete.js @@ -6,6 +6,7 @@ const ArrayUtils = require('../../common/utils/array-utils'); const DatabusUtils = require('../../../../public/js/utils/databus-utils'); const { JSONLD_VALUE } = require('../../../../public/js/utils/databus-uris'); const knownCompressionExtensions = require('../../common/config/compression-extensions.json'); +const DatabusConstants = require('../../../../public/js/utils/databus-constants'); var autocompleter = {}; @@ -52,8 +53,8 @@ function autofillFileIdentifiers(datasetUri, fileGraph) { segment += `.${compression}`; } - fileGraph[DatabusUris.DATABUS_FILE] = []; - fileGraph[DatabusUris.DATABUS_FILE].push({ '@id': `${baseUri}/${segment}` }); + fileGraph[DatabusUris.DATABUS_FILE] = [{}]; + fileGraph[DatabusUris.DATABUS_FILE][0][DatabusUris.JSONLD_ID] = `${baseUri}/${segment}`; fileGraph[DatabusUris.JSONLD_ID] = `${baseUri}#${segment}`; } @@ -86,10 +87,9 @@ autocompleter.autocomplete = function (expandedGraph, logger) { if (publisherUri == null) { versionGraph[DatabusUris.DCT_PUBLISHER] = [{}]; - versionGraph[DatabusUris.DCT_PUBLISHER][0][DatabusUris.JSONLD_ID] = `${accountUri}#this`; + versionGraph[DatabusUris.DCT_PUBLISHER][0][DatabusUris.JSONLD_ID] = `${accountUri}${DatabusConstants.WEBID_THIS}`; } - var timeString = DatabusUtils.timeStringNow(); if (versionGraph[DatabusUris.DCT_ISSUED] == undefined) { @@ -199,9 +199,9 @@ autocompleter.autocomplete = function (expandedGraph, logger) { for (var fileGraph of fileGraphs) { - versionGraph[DatabusUris.DCAT_DISTRIBUTION].push({ - '@id': fileGraph[DatabusUris.JSONLD_ID] - }); + + versionGraph[DatabusUris.DCAT_DISTRIBUTION] = [{}]; + versionGraph[DatabusUris.DCAT_DISTRIBUTION][0][DatabusUris.JSONLD_ID] = fileGraph[DatabusUris.JSONLD_ID]; for (var contentVariantProperty of contentVariantProperties) { @@ -223,8 +223,10 @@ autocompleter.autocompleteArtifact = function (expandedGraphs) { var groupUri = UriUtils.navigateUp(artifactUri, 1); var accountUri = UriUtils.navigateUp(artifactUri, 2); - - expandedGraphs.push({ '@id': groupUri, '@type': DatabusUris.DATABUS_GROUP }); + var groupGraph = {}; + groupGraph[DatabusUris.JSONLD_ID] = groupUri; + groupGraph[DatabusUris.JSONLD_TYPE] = DatabusUris.DATABUS_GROUP; + expandedGraphs.push(groupGraph); artifactGraph[DatabusUris.DATABUS_GROUP_PROPERTY] = [{}]; artifactGraph[DatabusUris.DATABUS_GROUP_PROPERTY][0][DatabusUris.JSONLD_ID] = groupUri; diff --git a/server/app/common/get-jsonld.js b/server/app/common/get-jsonld.js index 0076034..8b8929f 100644 --- a/server/app/common/get-jsonld.js +++ b/server/app/common/get-jsonld.js @@ -35,9 +35,6 @@ module.exports = async function getJsonLd(resourceUri, template, formatting) { var result = JSON.parse(await rp(options)); - console.log(formatting); - console.log(process.env.DATABUS_CONTEXT_URL); - if (formatting == undefined || formatting == 'compacted' || formatting == 'compact') { // Single out jsonld in order to compact the result with the databus context var result = await jsonld.compact(result, defaultContext); @@ -49,7 +46,6 @@ module.exports = async function getJsonLd(resourceUri, template, formatting) { var result = await jsonld.flatten(result); } - console.log(result); return result; } catch (err) { console.log(err); diff --git a/server/app/pages/modules/resource-pages.js b/server/app/pages/modules/resource-pages.js index 5b080cd..6d8971f 100644 --- a/server/app/pages/modules/resource-pages.js +++ b/server/app/pages/modules/resource-pages.js @@ -5,7 +5,6 @@ const DatabusCache = require('../../common/cache/databus-cache'); const ServerUtils = require('../../common/utils/server-utils.js'); const Constants = require('../../common/constants'); const UriUtils = require('../../common/utils/uri-utils'); -const rp = require('request-promise'); const JsonldUtils = require('../../../../public/js/utils/jsonld-utils'); const DatabusUris = require('../../../../public/js/utils/databus-uris'); const { dataid } = require('../../common/queries/sparql'); diff --git a/server/package.json b/server/package.json index ec28ad3..097964a 100644 --- a/server/package.json +++ b/server/package.json @@ -21,11 +21,12 @@ "debug": "~2.6.9", "ejs": ">=3.1.9", "express": "^4.16.4", - "express-openid-connect": "^2.4.0", + "express-openid-connect": "^2.17.0", "express-session": "^1.17.2", "get-random-values": "^1.2.2", "glob": "^7.1.7", "glob-promise": "^4.2.0", + "got": "11.8.2", "http-errors": "~1.6.3", "js-sha256": "^0.9.0", "jsonld": "^8.3.2", @@ -34,7 +35,7 @@ "morgan": "~1.9.1", "node-cache": "^4.2.0", "node-rsa": "^1.1.1", - "openid-client": "^3.10.0", + "openid-client": "^5.6.5", "pem-jwk": "^2.0.0", "rdf-ext": "^1.3.1", "rdf-parse": "^1.8.0",