aboutsummaryrefslogtreecommitdiffstats
path: root/src/internal-server/app/ImageHelper.js
diff options
context:
space:
mode:
authorLibravatar Vijay A <vraravam@users.noreply.github.com>2022-05-16 17:29:24 -0500
committerLibravatar Vijay Aravamudhan <vraravam@users.noreply.github.com>2022-05-16 19:25:46 -0500
commitad48962c335f6cec25bcedb92b4c34b6e4b0522c (patch)
tree8a96d9f83943170e37c7418fe51c212c8e1c2e40 /src/internal-server/app/ImageHelper.js
parentFix recipes github link (#165) (diff)
downloadferdium-app-ad48962c335f6cec25bcedb92b4c34b6e4b0522c.tar.gz
ferdium-app-ad48962c335f6cec25bcedb92b4c34b6e4b0522c.tar.zst
ferdium-app-ad48962c335f6cec25bcedb92b4c34b6e4b0522c.zip
Minor refactoring to extract common function to deduce icon url
Diffstat (limited to 'src/internal-server/app/ImageHelper.js')
-rw-r--r--src/internal-server/app/ImageHelper.js7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/internal-server/app/ImageHelper.js b/src/internal-server/app/ImageHelper.js
index b399d08c4..e7c981a1d 100644
--- a/src/internal-server/app/ImageHelper.js
+++ b/src/internal-server/app/ImageHelper.js
@@ -4,8 +4,9 @@ const { v4: uuid } = require('uuid');
4 4
5const path = require('path'); 5const path = require('path');
6const fs = require('fs-extra'); 6const fs = require('fs-extra');
7const { API_VERSION } = require('../../environment-remote');
7 8
8module.exports = async (icon) => { 9const moveIcon = async (icon) => {
9 const iconsPath = path.join(Env.get('USER_PATH'), 'icons'); 10 const iconsPath = path.join(Env.get('USER_PATH'), 'icons');
10 await fs.ensureDir(iconsPath); 11 await fs.ensureDir(iconsPath);
11 12
@@ -22,3 +23,7 @@ module.exports = async (icon) => {
22 }); 23 });
23 return !icon.moved() ? '-1' : iconId; 24 return !icon.moved() ? '-1' : iconId;
24}; 25};
26
27const deduceIconUrl = (iconId) => iconId ? `http://${Env.get('HOST')}:${Env.get('PORT')}/${API_VERSION}/icon/${iconId}` : null
28
29module.exports = { moveIcon, deduceIconUrl };