diff options
author | 2022-05-16 17:29:24 -0500 | |
---|---|---|
committer | 2022-05-16 19:25:46 -0500 | |
commit | ad48962c335f6cec25bcedb92b4c34b6e4b0522c (patch) | |
tree | 8a96d9f83943170e37c7418fe51c212c8e1c2e40 /src/internal-server/app/ImageHelper.js | |
parent | Fix recipes github link (#165) (diff) | |
download | ferdium-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.js | 7 |
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 | ||
5 | const path = require('path'); | 5 | const path = require('path'); |
6 | const fs = require('fs-extra'); | 6 | const fs = require('fs-extra'); |
7 | const { API_VERSION } = require('../../environment-remote'); | ||
7 | 8 | ||
8 | module.exports = async (icon) => { | 9 | const 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 | |||
27 | const deduceIconUrl = (iconId) => iconId ? `http://${Env.get('HOST')}:${Env.get('PORT')}/${API_VERSION}/icon/${iconId}` : null | ||
28 | |||
29 | module.exports = { moveIcon, deduceIconUrl }; | ||