-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3517 from magda-io/issue/3516
- Loading branch information
Showing
36 changed files
with
251 additions
and
85 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
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,6 +1,6 @@ | ||
FROM node:18-alpine3.18 | ||
|
||
RUN npm install -g [email protected] | ||
RUN npm install -g [email protected] && npm install -g [email protected] | ||
|
||
# Install haveged and run it so that we don't get lockups due to a lack of entropy | ||
RUN apk --no-cache add haveged | ||
|
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,4 +1,4 @@ | ||
FROM node:14-alpine | ||
FROM node:18-alpine | ||
|
||
RUN mkdir -p /usr/src/app | ||
COPY . /usr/src/app | ||
|
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
40 changes: 40 additions & 0 deletions
40
magda-typescript-common/src/getStorageApiResourceAccessUrl.ts
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,40 @@ | ||
import urijs from "urijs"; | ||
|
||
/** | ||
* Get the access url of a storage api resource from [pseudo storage api resource URL](https://github.com/magda-io/magda/issues/3000) | ||
* If the input url is not a pseudo storage api resource URL, return the input url directly | ||
* | ||
* @export | ||
* @param {string} resourceUrl pseudo storage api resource URL or ordinary HTTP access url | ||
* @param {string} storageApiBaseUrl storage api base url | ||
* @param {string} datasetsBucket datasets storage bucket name | ||
* @return {*} | ||
*/ | ||
export default function getStorageApiResourceAccessUrl( | ||
resourceUrl: string, | ||
storageApiBaseUrl: string, | ||
datasetsBucket: string | ||
) { | ||
if (!resourceUrl) { | ||
return resourceUrl; | ||
} | ||
const uri = urijs(resourceUrl); | ||
if (uri.protocol() === "magda" && uri.hostname() === "storage-api") { | ||
// --- convert [pseudo storage api resource URL](https://github.com/magda-io/magda/issues/3000) to http access url | ||
const [datasetId, distributionId, fileName] = uri.segmentCoded(); | ||
const accessUri = urijs(storageApiBaseUrl); | ||
const segments = [ | ||
...accessUri.segmentCoded(), | ||
datasetsBucket, | ||
datasetId, | ||
distributionId, | ||
fileName | ||
]; | ||
return accessUri.segmentCoded(segments).toString(); | ||
} else { | ||
// --- return legacy url directly | ||
// --- legacy url is a HTTP access url generated when create the resource | ||
// --- can be used to access storage api directly | ||
return resourceUrl; | ||
} | ||
} |
29 changes: 6 additions & 23 deletions
29
magda-web-client/src/helpers/getStorageApiResourceAccessUrl.ts
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,27 +1,10 @@ | ||
import { config, DATASETS_BUCKET } from "../config"; | ||
import urijs from "urijs"; | ||
import { default as getStorageApiResourceAccessUrlOriginal } from "@magda/typescript-common/dist/getStorageApiResourceAccessUrl.js"; | ||
|
||
export default function getStorageApiResourceAccessUrl(resourceUrl: string) { | ||
if (!resourceUrl) { | ||
return resourceUrl; | ||
} | ||
const uri = urijs(resourceUrl); | ||
if (uri.protocol() === "magda" && uri.hostname() === "storage-api") { | ||
// --- convert [pseudo storage api resource URL](https://github.com/magda-io/magda/issues/3000) to http access url | ||
const [datasetId, distributionId, fileName] = uri.segmentCoded(); | ||
const accessUri = urijs(config.storageApiBaseUrl); | ||
const segments = [ | ||
...accessUri.segmentCoded(), | ||
DATASETS_BUCKET, | ||
datasetId, | ||
distributionId, | ||
fileName | ||
]; | ||
return accessUri.segmentCoded(segments).toString(); | ||
} else { | ||
// --- return legacy url directly | ||
// --- legacy url is a HTTP access url generated when create the resource | ||
// --- can be used to access storage api directly | ||
return resourceUrl; | ||
} | ||
return getStorageApiResourceAccessUrlOriginal( | ||
resourceUrl, | ||
config.storageApiBaseUrl, | ||
DATASETS_BUCKET | ||
); | ||
} |
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,10 +1,17 @@ | ||
import * as esbuild from "esbuild"; | ||
import { require } from "@magda/esm-utils"; | ||
const pkg = require("./package.json"); | ||
|
||
await esbuild.build({ | ||
entryPoints: ["./src/index.ts"], | ||
bundle: true, | ||
platform: "node", | ||
target: ["es2022"], | ||
outdir: "dist", | ||
inject: ["../cjs-shim.js"], | ||
external: [ | ||
...Object.keys(pkg.dependencies || {}), | ||
...Object.keys(pkg.peerDependencies || {}) | ||
], | ||
format: "esm" | ||
}); |
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
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,7 @@ | ||
import { createRequire } from "node:module"; | ||
import path from "node:path"; | ||
import url from "node:url"; | ||
|
||
globalThis.require = createRequire(import.meta.url); | ||
globalThis.__filename = url.fileURLToPath(import.meta.url); | ||
globalThis.__dirname = path.dirname(__filename); |
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,10 +1,17 @@ | ||
import * as esbuild from "esbuild"; | ||
import { require } from "@magda/esm-utils"; | ||
const pkg = require("./package.json"); | ||
|
||
await esbuild.build({ | ||
entryPoints: ["./src/index.ts"], | ||
bundle: true, | ||
platform: "node", | ||
target: ["es2022"], | ||
outdir: "dist", | ||
inject: ["../cjs-shim.js"], | ||
external: [ | ||
...Object.keys(pkg.dependencies || {}), | ||
...Object.keys(pkg.peerDependencies || {}) | ||
], | ||
format: "esm" | ||
}); |
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
Oops, something went wrong.