diff --git a/api/package-lock.json b/api/package-lock.json
index aad0f8527..36fecb1f7 100644
--- a/api/package-lock.json
+++ b/api/package-lock.json
@@ -1372,9 +1372,9 @@
}
},
"app-root-path": {
- "version": "2.2.1",
- "resolved": "https://registry.npmjs.org/app-root-path/-/app-root-path-2.2.1.tgz",
- "integrity": "sha512-91IFKeKk7FjfmezPKkwtaRvSpnUc4gDwPAjA1YZ9Gn0q0PPeW+vbeUsZuyDwjI7+QTHhcLen2v25fi/AmhvbJA=="
+ "version": "3.0.0",
+ "resolved": "https://registry.npmjs.org/app-root-path/-/app-root-path-3.0.0.tgz",
+ "integrity": "sha512-qMcx+Gy2UZynHjOHOIXPNvpf+9cjvk3cWrBBK7zg4gH9+clobJRb9NGzcT7mQTcV/6Gm/1WelUtqxVXnNlrwcw=="
},
"append-transform": {
"version": "0.4.0",
@@ -3034,9 +3034,9 @@
"dev": true
},
"camelcase": {
- "version": "5.3.1",
- "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.3.1.tgz",
- "integrity": "sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg=="
+ "version": "6.0.0",
+ "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-6.0.0.tgz",
+ "integrity": "sha512-8KMDF1Vz2gzOq54ONPJS65IvTUaB1cHJ2DMM7MbPmLZljDH1qpzzLsWdiN9pHh6qvkRVDTi/07+eNGch/oLU4w=="
},
"camelcase-keys": {
"version": "6.2.2",
@@ -3047,6 +3047,14 @@
"camelcase": "^5.3.1",
"map-obj": "^4.0.0",
"quick-lru": "^4.0.1"
+ },
+ "dependencies": {
+ "camelcase": {
+ "version": "5.3.1",
+ "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.3.1.tgz",
+ "integrity": "sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==",
+ "dev": true
+ }
}
},
"camelize": {
@@ -3184,14 +3192,12 @@
"is-extglob": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz",
- "integrity": "sha1-qIwCU1eR8C7TfHahueqXc8gz+MI=",
- "optional": true
+ "integrity": "sha1-qIwCU1eR8C7TfHahueqXc8gz+MI="
},
"is-glob": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.1.tgz",
"integrity": "sha512-5G0tKtBTFImOqDnLB2hG6Bp2qcKEFduo4tZu9MT/H6NQv/ghhy30o55ufafxJ/LdH79LLs2Kfrn85TLKyA7BUg==",
- "optional": true,
"requires": {
"is-extglob": "^2.1.1"
}
@@ -3205,8 +3211,7 @@
"normalize-path": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz",
- "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==",
- "optional": true
+ "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA=="
},
"to-regex-range": {
"version": "5.0.1",
@@ -6301,8 +6306,7 @@
"ansi-regex": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz",
- "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=",
- "optional": true
+ "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8="
},
"aproba": {
"version": "1.2.0",
@@ -6323,14 +6327,12 @@
"balanced-match": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz",
- "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=",
- "optional": true
+ "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c="
},
"brace-expansion": {
"version": "1.1.11",
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz",
"integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==",
- "optional": true,
"requires": {
"balanced-match": "^1.0.0",
"concat-map": "0.0.1"
@@ -6345,20 +6347,17 @@
"code-point-at": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/code-point-at/-/code-point-at-1.1.0.tgz",
- "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=",
- "optional": true
+ "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c="
},
"concat-map": {
"version": "0.0.1",
"resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
- "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=",
- "optional": true
+ "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s="
},
"console-control-strings": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/console-control-strings/-/console-control-strings-1.1.0.tgz",
- "integrity": "sha1-PXz0Rk22RG6mRL9LOVB/mFEAjo4=",
- "optional": true
+ "integrity": "sha1-PXz0Rk22RG6mRL9LOVB/mFEAjo4="
},
"core-util-is": {
"version": "1.0.2",
@@ -6475,8 +6474,7 @@
"inherits": {
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz",
- "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=",
- "optional": true
+ "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4="
},
"ini": {
"version": "1.3.5",
@@ -6488,7 +6486,6 @@
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz",
"integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=",
- "optional": true,
"requires": {
"number-is-nan": "^1.0.0"
}
@@ -6503,7 +6500,6 @@
"version": "3.0.4",
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz",
"integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==",
- "optional": true,
"requires": {
"brace-expansion": "^1.1.7"
}
@@ -6511,14 +6507,12 @@
"minimist": {
"version": "0.0.8",
"resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz",
- "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=",
- "optional": true
+ "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0="
},
"minipass": {
"version": "2.3.5",
"resolved": "https://registry.npmjs.org/minipass/-/minipass-2.3.5.tgz",
"integrity": "sha512-Gi1W4k059gyRbyVUZQ4mEqLm0YIUiGYfvxhF6SIlk3ui1WVxMTGfGdQ2SInh3PDrRTVvPKgULkpJtT4RH10+VA==",
- "optional": true,
"requires": {
"safe-buffer": "^5.1.2",
"yallist": "^3.0.0"
@@ -6537,7 +6531,6 @@
"version": "0.5.1",
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz",
"integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=",
- "optional": true,
"requires": {
"minimist": "0.0.8"
}
@@ -6618,8 +6611,7 @@
"number-is-nan": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz",
- "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=",
- "optional": true
+ "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0="
},
"object-assign": {
"version": "4.1.1",
@@ -6631,7 +6623,6 @@
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz",
"integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=",
- "optional": true,
"requires": {
"wrappy": "1"
}
@@ -6717,8 +6708,7 @@
"safe-buffer": {
"version": "5.1.2",
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz",
- "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==",
- "optional": true
+ "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g=="
},
"safer-buffer": {
"version": "2.1.2",
@@ -6754,7 +6744,6 @@
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz",
"integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=",
- "optional": true,
"requires": {
"code-point-at": "^1.0.0",
"is-fullwidth-code-point": "^1.0.0",
@@ -6774,7 +6763,6 @@
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz",
"integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=",
- "optional": true,
"requires": {
"ansi-regex": "^2.0.0"
}
@@ -6818,14 +6806,12 @@
"wrappy": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
- "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=",
- "optional": true
+ "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8="
},
"yallist": {
"version": "3.0.3",
"resolved": "https://registry.npmjs.org/yallist/-/yallist-3.0.3.tgz",
- "integrity": "sha512-S+Zk8DEWE6oKpV+vI3qWkaK+jSbIK86pCwe2IF/xwIpQ8jEuxpw9NyaGjmp9+BoJv5FV2piqCDcoCtStppiq2A==",
- "optional": true
+ "integrity": "sha512-S+Zk8DEWE6oKpV+vI3qWkaK+jSbIK86pCwe2IF/xwIpQ8jEuxpw9NyaGjmp9+BoJv5FV2piqCDcoCtStppiq2A=="
}
}
},
@@ -11129,6 +11115,14 @@
"requires": {
"camelcase": "^5.0.0",
"decamelize": "^1.2.0"
+ },
+ "dependencies": {
+ "camelcase": {
+ "version": "5.3.1",
+ "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.3.1.tgz",
+ "integrity": "sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==",
+ "dev": true
+ }
}
}
}
@@ -11799,8 +11793,7 @@
"picomatch": {
"version": "2.2.2",
"resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.2.2.tgz",
- "integrity": "sha512-q0M/9eZHzmr0AulXyPwNfZjtwZ/RBZlbN3K3CErVrk50T2ASYI7Bye0EvekFY3IP1Nt2DHu0re+V2ZHIpMkuWg==",
- "optional": true
+ "integrity": "sha512-q0M/9eZHzmr0AulXyPwNfZjtwZ/RBZlbN3K3CErVrk50T2ASYI7Bye0EvekFY3IP1Nt2DHu0re+V2ZHIpMkuWg=="
},
"pify": {
"version": "2.3.0",
@@ -13174,15 +13167,15 @@
}
},
"sharp": {
- "version": "0.25.3",
- "resolved": "https://registry.npmjs.org/sharp/-/sharp-0.25.3.tgz",
- "integrity": "sha512-qV3n30NaBEhAjBhFo+d8h5N4X3DHteFdwxXoWUiubk72G0VKT5fX50nlcawGYjPqfFV4Z2e/G9gDPeSGAdn/gg==",
+ "version": "0.25.4",
+ "resolved": "https://registry.npmjs.org/sharp/-/sharp-0.25.4.tgz",
+ "integrity": "sha512-umSzJJ1oBwIOfwFFt/fJ7JgCva9FvrEU2cbbm7u/3hSDZhXvkME8WE5qpaJqLIe2Har5msF5UG4CzYlEg5o3BQ==",
"requires": {
"color": "^3.1.2",
"detect-libc": "^1.0.3",
"node-addon-api": "^3.0.0",
"npmlog": "^4.1.2",
- "prebuild-install": "^5.3.3",
+ "prebuild-install": "^5.3.4",
"semver": "^7.3.2",
"simple-get": "^4.0.0",
"tar": "^6.0.2",
@@ -13867,6 +13860,14 @@
"requires": {
"camelcase": "^5.0.0",
"decamelize": "^1.2.0"
+ },
+ "dependencies": {
+ "camelcase": {
+ "version": "5.3.1",
+ "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.3.1.tgz",
+ "integrity": "sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==",
+ "dev": true
+ }
}
}
}
@@ -14805,6 +14806,13 @@
"lorem-ipsum": "^1.0.3",
"serve-index": "^1.6.3",
"xtend": "^4.0.0"
+ },
+ "dependencies": {
+ "app-root-path": {
+ "version": "2.2.1",
+ "resolved": "https://registry.npmjs.org/app-root-path/-/app-root-path-2.2.1.tgz",
+ "integrity": "sha512-91IFKeKk7FjfmezPKkwtaRvSpnUc4gDwPAjA1YZ9Gn0q0PPeW+vbeUsZuyDwjI7+QTHhcLen2v25fi/AmhvbJA=="
+ }
}
},
"tweetnacl": {
@@ -15517,8 +15525,7 @@
"is-extglob": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz",
- "integrity": "sha1-qIwCU1eR8C7TfHahueqXc8gz+MI=",
- "optional": true
+ "integrity": "sha1-qIwCU1eR8C7TfHahueqXc8gz+MI="
},
"is-glob": {
"version": "4.0.1",
@@ -16332,6 +16339,14 @@
"requires": {
"camelcase": "^5.0.0",
"decamelize": "^1.2.0"
+ },
+ "dependencies": {
+ "camelcase": {
+ "version": "5.3.1",
+ "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.3.1.tgz",
+ "integrity": "sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==",
+ "dev": true
+ }
}
},
"z-schema": {
diff --git a/api/package.json b/api/package.json
index e99c884b2..95b19b492 100644
--- a/api/package.json
+++ b/api/package.json
@@ -21,13 +21,13 @@
"dependencies": {
"@hapi/hapi": "^18.4.1",
"@hapi/joi": "^15.1.1",
- "app-root-path": "^2.2.1",
+ "app-root-path": "^3.0.0",
"async": "^2.6.3",
"babel-loader": "^7.0.0",
"babel-preset-env": "^1.6.0",
"babel-preset-react": "^6.16.0",
"boom": "^7.0.0",
- "camelcase": "^5.3.1",
+ "camelcase": "^6.0.0",
"clone": "^2.1.1",
"dot-prop": "^5.2.0",
"dotenv": "^8.2.0",
@@ -46,7 +46,7 @@
"node-notifier": "^7.0.1",
"react": "^16.13.1",
"react-dom": "^16.13.1",
- "sharp": "^0.25.3",
+ "sharp": "^0.25.4",
"styled-components": "^4.4.1",
"tap-webpack-plugin": "^2.0.0",
"tuxharness": "^2.0.4",
diff --git a/api/server/index.js b/api/server/index.js
index 88bc513a7..355383f3f 100644
--- a/api/server/index.js
+++ b/api/server/index.js
@@ -1,3 +1,4 @@
+const boom = require('boom');
const hapi = require('@hapi/hapi');
const hapiReactViews = require('hapi-react-views');
const notifier = require('node-notifier');
@@ -8,14 +9,27 @@ const config = require('../../config.json');
const log = require('./plugins/log');
const plugins = require('./lib/plugins');
-const { apiPort: port } = config;
+const { apiPort: port, uiPort } = config;
const logger = log.createLogger('server');
const server = hapi.Server({
port,
routes: {
cors: {
- origin: ['http://localhost:3000'],
+ origin: [`http://localhost:${uiPort}`],
+ },
+ validate: {
+ failAction: async (request, h, err) => {
+ if (process.env.NODE_ENV === 'production') {
+ // In prod, log a limited error message and throw the default Bad Request error.
+ console.error('ValidationError:', err.message);
+ throw boom.badRequest('Invalid request payload input');
+ } else {
+ // During development, log and respond with the full error.
+ console.error(err);
+ throw err;
+ }
+ },
},
},
});
diff --git a/api/server/lib/plugins.js b/api/server/lib/plugins.js
index ea2c4156d..981463af8 100644
--- a/api/server/lib/plugins.js
+++ b/api/server/lib/plugins.js
@@ -29,7 +29,7 @@ const plugins = [
{ plugin: viewAlbum, routes: { prefix: '/view' } },
{ plugin: editAlbum, routes: { prefix: '/edit' } },
{ plugin: libGallery },
- { plugin: generatePreview },
+ { plugin: generatePreview, routes: { prefix: '/preview' } },
{ plugin: libGeojson, routes: { prefix: '/geojson' } },
{ plugin: libHome },
{ plugin: libPublic },
diff --git a/api/server/plugins/generate-preview/test/.eslintrc.js b/api/server/plugins/generate-preview/test/.eslintrc.js
deleted file mode 100644
index 1a1e013c0..000000000
--- a/api/server/plugins/generate-preview/test/.eslintrc.js
+++ /dev/null
@@ -1,3 +0,0 @@
-module.exports = {
- extends: '../../../../test.eslintrc.js',
-};
diff --git a/api/server/plugins/generatePreview/lib/index.js b/api/server/plugins/generatePreview/lib/index.js
index 39ee1e2db..a5ae3c706 100644
--- a/api/server/plugins/generatePreview/lib/index.js
+++ b/api/server/plugins/generatePreview/lib/index.js
@@ -1,14 +1,11 @@
-const resizeMod = require('./resize');
+const resizer = require('./resize');
const validation = require('../../../lib/validation');
-const utils = require('../../utils');
-
-const uiPort = utils.config.get('uiPort');
const handler = async (request) => {
try {
const sourcePath = request.payload.image_path;
- const out = await resizeMod.resize(sourcePath);
+ const out = await resizer.resize(sourcePath);
return out;
} catch (error) {
return error;
@@ -18,12 +15,9 @@ const handler = async (request) => {
const register = (server) => {
server.route({
method: 'POST',
- path: '/generate-preview',
+ path: '/generate',
options: {
handler,
- cors: {
- origin: [`http://localhost:${uiPort}`],
- },
tags: ['api', 'jpg', 'resize', 'generator', 'thumbnail'],
validate: {
payload: {
diff --git a/api/server/plugins/generatePreview/lib/resize.js b/api/server/plugins/generatePreview/lib/resize.js
index 53045c987..085c2a022 100644
--- a/api/server/plugins/generatePreview/lib/resize.js
+++ b/api/server/plugins/generatePreview/lib/resize.js
@@ -1,23 +1,35 @@
const boom = require('boom');
+const fs = require('fs');
const sharp = require('sharp');
+const { previewFolderName } = require('../../../../../config.json');
const existsMod = require('../../exists/lib/exists');
const utils = require('../../utils');
async function transformImages(originalPath) {
const dimensions = utils.config.get('resizeDimensions.preview');
const originalMimeType = utils.file.mimeType(originalPath);
+ const paths = originalPath.split('/');
+ const filename = paths.pop();
+ const sourcePath = paths.join('/');
if (originalMimeType !== 'image/jpeg') {
return boom.badRequest(`Transform supports JPEG images, not (${originalMimeType})`);
}
- const image = await sharp(originalPath)
- .rotate() // auto-orient based on the EXIF Orientation tag
- .resize(dimensions.width, dimensions.height)
- .toFile('output.png', (err, info) => info);
+ const outFolder = `${sourcePath}/${previewFolderName}`;
+ const outPath = `${outFolder}/${filename}`;
+ try {
+ await fs.promises.mkdir(outFolder, { recursive: true }); // ensure folder exists without overwriting
+ const meta = await sharp(originalPath)
+ .rotate() // auto-orient based on the EXIF Orientation tag
+ .resize(dimensions.width, dimensions.height)
+ .toFile(outPath);
- return image;
+ return { meta, path: outPath };
+ } catch (error) {
+ return { error: error.message, path: outPath };
+ }
}
/**
@@ -28,7 +40,8 @@ async function transformImages(originalPath) {
const resize = async (sourcePath) => {
try {
const absolutePath = await existsMod.pathExists(sourcePath);
- return await transformImages(absolutePath);
+ const out = await transformImages(absolutePath);
+ return out;
} catch (error) {
return boom.boomify(error);
}
diff --git a/api/server/plugins/public/lib/index.js b/api/server/plugins/public/lib/index.js
index 482ea9274..3e1da1456 100644
--- a/api/server/plugins/public/lib/index.js
+++ b/api/server/plugins/public/lib/index.js
@@ -11,14 +11,32 @@ const staticRouteFavicon = () => ({
},
});
+const staticRoutePublic = () => ({
+ method: 'GET',
+ path: '/public/{path*}',
+ config: {
+ description: 'Static assets in /public folder',
+ tags: ['static'],
+ handler: {
+ directory: {
+ path: path.join(__dirname, '../../../../../public'),
+ listing: true,
+ index: false,
+ redirectToSlash: true,
+ },
+ },
+ },
+});
+
const register = (server) => {
server.route(staticRouteFavicon());
+ server.route(staticRoutePublic());
};
const plugin = {
register,
name: 'public',
- version: '0.3.0',
+ version: '0.4.0',
};
module.exports = { plugin };
diff --git a/api/server/plugins/resize/lib/index.js b/api/server/plugins/resize/lib/index.js
index 219b63918..0cf9a3dfe 100644
--- a/api/server/plugins/resize/lib/index.js
+++ b/api/server/plugins/resize/lib/index.js
@@ -2,9 +2,6 @@ const dotProp = require('dot-prop');
const resizeMod = require('./resize');
const validation = require('../../../lib/validation');
-const utils = require('../../utils');
-
-const uiPort = utils.config.get('uiPort');
async function handler(request, h) {
const sourcePath = request.payload.source_path;
@@ -27,9 +24,6 @@ const register = (server) => {
path: '/resize',
options: {
handler,
- cors: {
- origin: [`http://localhost:${uiPort}`],
- },
tags: ['api'],
validate: {
payload: {
diff --git a/api/server/plugins/walk/lib/index.js b/api/server/plugins/walk/lib/index.js
index 2b037f1e4..a6e740990 100644
--- a/api/server/plugins/walk/lib/index.js
+++ b/api/server/plugins/walk/lib/index.js
@@ -13,9 +13,6 @@ const routeWalkPath = {
return routes.wrapError(e);
}
},
- cors: {
- origin: ['http://localhost:3000'],
- },
tags: ['api'],
validate: {
query: {
diff --git a/config.json b/config.json
index bcb133600..1f0a65863 100644
--- a/config.json
+++ b/config.json
@@ -8,6 +8,7 @@
"thumb": { "width": 185, "height": 45 },
"preview": { "width": 230, "height": 200 }
},
+ "previewFolderName": "_preview",
"supportedFileTypes": {
"photo": ["jpg", "jpeg"],
"video": ["mp4", "webm"]
diff --git a/ui/app/containers/Walk/Contents.jsx b/ui/app/containers/Walk/ListFolders.jsx
similarity index 75%
rename from ui/app/containers/Walk/Contents.jsx
rename to ui/app/containers/Walk/ListFolders.jsx
index 3d66e4d77..69ad33b53 100644
--- a/ui/app/containers/Walk/Contents.jsx
+++ b/ui/app/containers/Walk/ListFolders.jsx
@@ -2,16 +2,14 @@ import React from 'react';
import A from '../../components/A';
import ListItem from '../../components/ListItem';
-import Placeholder from './Placeholder';
import walkUtils from './util';
const { areImages } = walkUtils;
function Contents({ item: file }) {
- const key = `contents-${file.id.replace(/\//, '-') || 'missingId'}`;
if (areImages(file)) {
- return ;
+ return null;
}
if (file.mediumType === 'folder') {
diff --git a/ui/app/containers/Walk/index.jsx b/ui/app/containers/Walk/index.jsx
index 9e89c634d..3cafb669e 100644
--- a/ui/app/containers/Walk/index.jsx
+++ b/ui/app/containers/Walk/index.jsx
@@ -11,7 +11,7 @@ import { makeSelectFiles, makeSelectPath } from './selectors';
import { useInjectSaga } from '../../utils/injectSaga';
import { useInjectReducer } from '../../utils/injectReducer';
-import Contents from './Contents';
+import ListFolders from './ListFolders';
import GenericList from '../../components/GenericList';
function parseQueryString(find, from) {
@@ -42,7 +42,7 @@ function Walk({
,
({ id: f.path, ...f }))}
loading={!files || files.length === 0}
error={false}
diff --git a/ui/package.json b/ui/package.json
index 138237530..45ccb7d30 100644
--- a/ui/package.json
+++ b/ui/package.json
@@ -98,10 +98,10 @@
"redux-saga": "^1.1.3",
"reselect": "4.0.0",
"sanitize.css": "8.0.0",
+ "snyk": "^1.339.1",
"styled-components": "^4.4.1",
"webpack": "^4.42.0",
- "whatwg-fetch": "3.0.0",
- "snyk": "^1.339.1"
+ "whatwg-fetch": "3.0.0"
},
"devDependencies": {
"@babel/cli": "7.4.3",