@ozdao/prometheus-framework 0.1.15 → 0.1.17
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/Breadcrumbs.vue_vue_type_style_index_0_lang-579e2c7a.mjs +1945 -0
- package/dist/Breadcrumbs.vue_vue_type_style_index_0_lang-cab2bcd2.js +1 -0
- package/dist/ButtonFollow-23c4d9fc.mjs +132 -0
- package/dist/ButtonFollow-bf5e6d42.js +1 -0
- package/dist/CardOrganization-63dcc83b.js +1 -0
- package/dist/CardOrganization-e530c9d5.mjs +230 -0
- package/dist/Chips-3dac276c.js +1 -0
- package/dist/Feed-4d9001aa.mjs +368 -0
- package/dist/Feed-51eef23f.js +1 -0
- package/dist/Feed-d78d4b91.mjs +439 -0
- package/dist/Feed-f4e9769e.js +1 -0
- package/dist/Gallery-1f82841a.mjs +357 -0
- package/dist/Gallery-dd29c7f6.js +1 -0
- package/dist/Image-a2c2ab9c.js +9 -0
- package/dist/Image-ad6d4f0f.mjs +477 -0
- package/dist/Popup-383abb2e.js +1 -0
- package/dist/Popup-f7a5e86b.mjs +76 -0
- package/dist/Product-b32fb0e1.js +7 -0
- package/dist/Product-d01e3a0d.mjs +839 -0
- package/dist/ProductEdit-2b4d1d88.js +1 -0
- package/dist/ProductEdit-5e479343.mjs +300 -0
- package/dist/ProfileBlogposts-070cb7e9.mjs +65 -0
- package/dist/ProfileBlogposts-b6bf0c42.js +1 -0
- package/dist/ProfileComments-8a0c489c.mjs +44 -0
- package/dist/ProfileComments-f0000ea6.js +1 -0
- package/dist/ProfileEvents-8b88287a.js +1 -0
- package/dist/ProfileEvents-d978617d.mjs +57 -0
- package/dist/ProfileLikes-d5f9f058.js +1 -0
- package/dist/ProfileLikes-f5ad4497.mjs +44 -0
- package/dist/ProfileOrganizations-422d1fa5.js +1 -0
- package/dist/ProfileOrganizations-6b1bc5b2.mjs +213 -0
- package/dist/Publics-640d32fc.mjs +123 -0
- package/dist/Publics-8595ab7e.js +1 -0
- package/dist/Socials-43293869.js +1 -0
- package/dist/Tab-dcd62005.js +1 -0
- package/dist/UploadImage-dfb36cdb.js +1 -0
- package/dist/UploadImage-e4418b43.mjs +83 -0
- package/dist/UploadImageMultiple-c9a7b54f.js +1 -0
- package/dist/UploadImageMultiple-d2d48f39.mjs +58 -0
- package/dist/auth-45a454f2.js +7 -0
- package/dist/auth-5cd34aae.mjs +905 -0
- package/dist/auth.client.cjs +8 -8
- package/dist/auth.client.js +42 -42
- package/dist/auth.validation-4b016fa5.js +1 -0
- package/dist/auth.validation-a52304cf.mjs +20 -0
- package/dist/backoffice.client.cjs +1 -0
- package/dist/backoffice.client.js +69 -0
- package/dist/carousel.es-cdfb392c.js +5 -0
- package/dist/community.client.cjs +1 -1
- package/dist/community.client.js +23 -22
- package/dist/components/EditImages/EditImages.vue.d.ts +7 -0
- package/dist/components/FieldPhone/FieldPhone(script-setup).vue.d.ts +3 -3
- package/dist/components/FieldPhone/FieldPhone.vue.d.ts +1 -1
- package/dist/events.client.cjs +2 -2
- package/dist/events.client.js +17 -16
- package/dist/files.server.js +149 -112
- package/dist/files.server.mjs +149 -112
- package/dist/gallery.server.js +127 -0
- package/dist/gallery.server.mjs +128 -0
- package/dist/index-2059e444.js +2 -0
- package/dist/index-4e469a71.mjs +941 -0
- package/dist/landing.client.cjs +1 -1
- package/dist/modules/gallery/components/sections/Gallery.vue.d.ts +2 -0
- package/dist/modules/icons/navigation/IconChevronRight.vue.d.ts +13 -1
- package/dist/modules/mobile/components/Menu/MenuItem.vue.d.ts +14 -2
- package/dist/organizations-81e762e7.mjs +122 -0
- package/dist/organizations-cf1ab766.js +1 -0
- package/dist/organizations.client-b692a78a.mjs +3018 -0
- package/dist/organizations.client-bdc9b044.js +3 -0
- package/dist/organizations.client.cjs +1 -1
- package/dist/organizations.client.js +44 -43
- package/dist/style.css +1 -1
- package/dist/users.client.cjs +1 -1
- package/dist/users.client.js +224 -184
- package/dist/vue-draggable-next.esm-bundler-21a209c6.js +10 -0
- package/dist/vuex.esm-bundler-685cf29f.js +5 -0
- package/package.json +10 -1
- package/src/components/EditImages/EditImages.vue +55 -0
- package/src/configurator/components/layouts/layoutConfigurator.vue +0 -40
- package/src/modules/auth/components/pages/EnterCode.vue +0 -1
- package/src/modules/backoffice/backoffice.client.js +15 -0
- package/src/modules/backoffice/components/layouts/Account.vue +48 -58
- package/src/modules/backoffice/router/backoffice.js +20 -0
- package/src/modules/files/controllers/files.controller.js +27 -131
- package/src/modules/files/middlewares/server/index.js +10 -0
- package/src/modules/files/middlewares/server/md.js +151 -0
- package/src/modules/files/middlewares/server/middlewareMulter.js +121 -0
- package/src/modules/files/routes/files.routes.js +20 -6
- package/src/modules/gallery/components/sections/Gallery.vue +414 -0
- package/src/modules/gallery/controllers/gallery.controller.js +87 -73
- package/src/modules/gallery/gallery.client.js +17 -0
- package/src/modules/gallery/gallery.server.js +13 -0
- package/src/modules/gallery/models/photo.model.js +20 -14
- package/src/modules/gallery/routes/gallery.routes.js +18 -9
- package/src/modules/gallery/store/gallery.js +25 -19
- package/src/modules/icons/navigation/IconChevronRight.vue +14 -2
- package/src/modules/mobile/components/Menu/Menu.vue +1 -1
- package/src/modules/mobile/components/Menu/MenuItem.vue +8 -2
- package/src/modules/users/components/pages/Profile.vue +22 -1
- package/src/modules/backoffice/components/pages/Profile.vue +0 -109
- package/src/modules/backoffice/components/pages/profile/ProfileEdit.vue +0 -132
package/dist/events.client.js
CHANGED
@@ -1,15 +1,16 @@
|
|
1
|
-
import { r as Tr, a as Cn, s as Ut, c as yl, u as qr, b as zr, d as gl, S as wl, _ as bl } from "./Feed-
|
2
|
-
import { e as
|
1
|
+
import { r as Tr, a as Cn, s as Ut, c as yl, u as qr, b as zr, d as gl, S as wl, _ as bl } from "./Feed-4d9001aa.mjs";
|
2
|
+
import { e as Wc } from "./Feed-4d9001aa.mjs";
|
3
3
|
import { openBlock as D, createElementBlock as L, createStaticVNode as _l, ref as G, onMounted as Ke, createVNode as _e, TransitionGroup as Oa, withCtx as ve, Fragment as ye, renderList as Oe, createBlock as fe, createCommentVNode as F, Transition as Dt, normalizeClass as ke, createElementVNode as le, unref as p, toDisplayString as Le, watch as kt, resolveComponent as kl, resolveDynamicComponent as pa, reactive as ea, defineComponent as ze, useSlots as Vt, toRef as Aa, nextTick as St, computed as K, onUnmounted as xr, mergeProps as Be, isRef as Gr, createSlots as Je, renderSlot as ne, normalizeProps as Ve, guardReactiveProps as Xe, Teleport as Dl, h as Tl, render as Kr, withKeys as he, withModifiers as Ae, normalizeStyle as dt, createTextVNode as mt, onBeforeUpdate as xl, withDirectives as Ca, vShow as Pa, getCurrentScope as Ml, onScopeDispose as Cl } from "vue";
|
4
4
|
import { _ as Pn } from "./EmptyState-34d85f10.mjs";
|
5
5
|
import { _ as $n } from "./_plugin-vue_export-helper-dad06003.mjs";
|
6
6
|
import { useRoute as Ra, useRouter as Mr } from "vue-router";
|
7
|
-
import { _ as Pl, S as $l, C as Ol } from "./Breadcrumbs.vue_vue_type_style_index_0_lang-
|
8
|
-
import { a as Al, b as Sl, c as Yl } from "./Image-
|
9
|
-
import { _ as Nl } from "./Popup-
|
10
|
-
import { s as rt, F as Qr, _ as On
|
11
|
-
import { _ as
|
12
|
-
import { a as
|
7
|
+
import { _ as Pl, S as $l, C as Ol } from "./Breadcrumbs.vue_vue_type_style_index_0_lang-579e2c7a.mjs";
|
8
|
+
import { a as Al, b as Sl, c as Yl } from "./Image-ad6d4f0f.mjs";
|
9
|
+
import { _ as Nl } from "./Popup-f7a5e86b.mjs";
|
10
|
+
import { s as rt, F as Qr, _ as On } from "./auth-5cd34aae.mjs";
|
11
|
+
import { _ as El } from "./UploadImage-e4418b43.mjs";
|
12
|
+
import { a as Ul } from "./organizations-81e762e7.mjs";
|
13
|
+
import { a as Il } from "./index-4e469a71.mjs";
|
13
14
|
import { s as ka } from "./globals-96ba60e4.mjs";
|
14
15
|
import "vue-i18n";
|
15
16
|
import "./Chips-03ff0c34.mjs";
|
@@ -26,7 +27,7 @@ function Vl(e, a) {
|
|
26
27
|
return D(), L("svg", Hl, Wl);
|
27
28
|
}
|
28
29
|
const Fl = /* @__PURE__ */ $n(Rl, [["render", Vl]]);
|
29
|
-
const Bl = { class: "today-events" },
|
30
|
+
const Bl = { class: "today-events" }, Ic = {
|
30
31
|
__name: "List",
|
31
32
|
props: {
|
32
33
|
category: {
|
@@ -8517,7 +8518,7 @@ const Jd = {
|
|
8517
8518
|
name: t.value.owner.target.profile.name,
|
8518
8519
|
photo: t.value.owner.target.profile.photo
|
8519
8520
|
});
|
8520
|
-
const A = await
|
8521
|
+
const A = await Ul.read({
|
8521
8522
|
user: rt.user._id,
|
8522
8523
|
postable: rt.user._id,
|
8523
8524
|
limit: 100
|
@@ -8575,7 +8576,7 @@ const Jd = {
|
|
8575
8576
|
}
|
8576
8577
|
return (A, U) => p(t) ? (D(), L("article", Jd, [
|
8577
8578
|
le("div", Xd, [
|
8578
|
-
_e(
|
8579
|
+
_e(El, {
|
8579
8580
|
photo: p(t).cover,
|
8580
8581
|
"onUpdate:photo": U[0] || (U[0] = (_) => p(t).cover = _),
|
8581
8582
|
uploadPath: "users/" + rt.user._id + "/events",
|
@@ -8681,7 +8682,7 @@ const Jd = {
|
|
8681
8682
|
}, xn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
8682
8683
|
__proto__: null,
|
8683
8684
|
default: cc
|
8684
|
-
}, Symbol.toStringTag, { value: "Module" })), Ma =
|
8685
|
+
}, Symbol.toStringTag, { value: "Module" })), Ma = Il.create({
|
8685
8686
|
baseURL: process.env.API_URL,
|
8686
8687
|
withCredentials: !0
|
8687
8688
|
}), zt = ea({
|
@@ -8907,7 +8908,7 @@ const mc = {
|
|
8907
8908
|
}, wc = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
8908
8909
|
__proto__: null,
|
8909
8910
|
default: gc
|
8910
|
-
}, Symbol.toStringTag, { value: "Module" })),
|
8911
|
+
}, Symbol.toStringTag, { value: "Module" })), Rc = [
|
8911
8912
|
{
|
8912
8913
|
path: "events",
|
8913
8914
|
component: Zl,
|
@@ -8968,7 +8969,7 @@ export {
|
|
8968
8969
|
Zl as EventsLayout,
|
8969
8970
|
gc as EventsPage,
|
8970
8971
|
bl as Feed,
|
8971
|
-
|
8972
|
-
|
8973
|
-
|
8972
|
+
Ic as List,
|
8973
|
+
Rc as eventsRoutes,
|
8974
|
+
Wc as eventsStore
|
8974
8975
|
};
|
package/dist/files.server.js
CHANGED
@@ -1,137 +1,162 @@
|
|
1
1
|
"use strict";
|
2
2
|
const _commonjsHelpers = require("./_commonjsHelpers-3b53548e.js");
|
3
|
-
const
|
4
|
-
const require$$
|
5
|
-
const require$$
|
3
|
+
const index = require("./index-21dfdbd9.js");
|
4
|
+
const require$$0 = require("sharp");
|
5
|
+
const require$$1 = require("fs");
|
6
|
+
const require$$2 = require("path");
|
7
|
+
const require$$3 = require("multer");
|
6
8
|
require("jsonwebtoken");
|
7
9
|
require("mongodb");
|
8
|
-
const multer = require$$0;
|
9
|
-
const path = require$$1;
|
10
|
-
const fs = require$$2;
|
11
|
-
const createMulterStorage = (folderName, publicPath) => {
|
12
|
-
return multer.diskStorage({
|
13
|
-
destination: function(req, file, cb) {
|
14
|
-
let user = {};
|
15
|
-
try {
|
16
|
-
user = JSON.parse(req.cookies.user);
|
17
|
-
} catch (err) {
|
18
|
-
return cb(new Error("Unable to parse user from cookies"));
|
19
|
-
}
|
20
|
-
if (!user._id) {
|
21
|
-
return cb(new Error("No user _id found in cookies"));
|
22
|
-
}
|
23
|
-
const userUploadPath = path.join(publicPath, "users", String(user._id), folderName);
|
24
|
-
fs.mkdirSync(userUploadPath, { recursive: true });
|
25
|
-
cb(null, userUploadPath);
|
26
|
-
},
|
27
|
-
filename: function(req, file, cb) {
|
28
|
-
cb(null, Date.now() + path.extname(file.originalname));
|
29
|
-
}
|
30
|
-
});
|
31
|
-
};
|
32
|
-
const createStorage = (folderName, publicPath) => {
|
33
|
-
return multer.diskStorage({
|
34
|
-
destination: function(req, file, cb) {
|
35
|
-
let user = {};
|
36
|
-
try {
|
37
|
-
user = JSON.parse(req.cookies.user);
|
38
|
-
} catch (err) {
|
39
|
-
return cb(new Error("Unable to parse user from cookies"));
|
40
|
-
}
|
41
|
-
if (!user._id) {
|
42
|
-
return cb(new Error("No user _id found in cookies"));
|
43
|
-
}
|
44
|
-
const userUploadPath = path.join(publicPath, folderName);
|
45
|
-
fs.mkdirSync(userUploadPath, { recursive: true });
|
46
|
-
cb(null, userUploadPath);
|
47
|
-
},
|
48
|
-
filename: function(req, file, cb) {
|
49
|
-
cb(null, Date.now() + path.extname(file.originalname));
|
50
|
-
}
|
51
|
-
});
|
52
|
-
};
|
53
10
|
const controllerFactory$1 = (db, publicPath) => {
|
54
|
-
const uploadImageController = async (req, res, next) => {
|
55
|
-
const upload = multer({ storage: createMulterStorage("blog", publicPath) }).single("file");
|
56
|
-
console.log(req.file);
|
57
|
-
upload(req, res, function(err) {
|
58
|
-
if (err instanceof multer.MulterError) {
|
59
|
-
console.log(err);
|
60
|
-
return res.status(500).json(err);
|
61
|
-
} else if (err) {
|
62
|
-
console.log(err);
|
63
|
-
return res.status(500).json(err);
|
64
|
-
}
|
65
|
-
if (!req.file) {
|
66
|
-
return res.status(400).send({ message: "No file uploaded." });
|
67
|
-
}
|
68
|
-
const user = JSON.parse(req.cookies.user);
|
69
|
-
res.status(200).send({
|
70
|
-
message: "File uploaded successfully.",
|
71
|
-
filename: req.file.filename,
|
72
|
-
filepath: `/users/${user._id}/blog/${req.file.filename}`
|
73
|
-
});
|
74
|
-
});
|
75
|
-
};
|
76
11
|
const uploadFileController = async (req, res, next) => {
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
upload(req, res, function(err) {
|
82
|
-
if (err instanceof multer.MulterError) {
|
83
|
-
console.log(err);
|
84
|
-
return res.status(500).json(err);
|
85
|
-
} else if (err) {
|
86
|
-
console.log(err);
|
87
|
-
return res.status(500).json(err);
|
88
|
-
}
|
89
|
-
if (!req.file) {
|
90
|
-
return res.status(400).send({ message: "No file uploaded." });
|
91
|
-
}
|
92
|
-
JSON.parse(req.cookies.user);
|
12
|
+
if (!req.file) {
|
13
|
+
return res.status(400).send({ message: "No file uploaded." });
|
14
|
+
}
|
15
|
+
try {
|
93
16
|
res.status(200).send({
|
94
17
|
message: "File uploaded successfully.",
|
95
18
|
filename: req.file.filename,
|
96
|
-
filepath: `/${folderName}/${req.file.filename}`
|
19
|
+
filepath: `/${req.query.folderName || "unsorted"}/${req.file.filename}`
|
97
20
|
});
|
98
|
-
})
|
21
|
+
} catch (error) {
|
22
|
+
console.error("Error in uploadFileController:", error);
|
23
|
+
return res.status(500).send({ message: "Error during file processing." });
|
24
|
+
}
|
99
25
|
};
|
100
|
-
const
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
return res.status(500).json(err);
|
107
|
-
} else if (err) {
|
108
|
-
console.log(err);
|
109
|
-
return res.status(500).json(err);
|
110
|
-
}
|
111
|
-
if (!req.files || req.files.length === 0) {
|
112
|
-
return res.status(400).send({ message: "No file uploaded." });
|
113
|
-
}
|
114
|
-
JSON.parse(req.cookies.user);
|
115
|
-
res.status(200).send(req.files.map((file) => ({
|
26
|
+
const uploadMultipleFileController = async (req, res, next) => {
|
27
|
+
if (!req.files || req.files.length === 0) {
|
28
|
+
return res.status(400).send({ message: "No files uploaded." });
|
29
|
+
}
|
30
|
+
try {
|
31
|
+
const fileResponses = req.files.map((file) => ({
|
116
32
|
message: "File uploaded successfully.",
|
117
33
|
filename: file.filename,
|
118
|
-
filepath: `/${folderName}/${file.filename}`
|
119
|
-
}))
|
120
|
-
|
34
|
+
filepath: `/${req.query.folderName || "unsorted"}/${file.filename}`
|
35
|
+
}));
|
36
|
+
res.status(200).send(fileResponses);
|
37
|
+
} catch (error) {
|
38
|
+
console.error("Error in uploadMultipleFileController:", error);
|
39
|
+
return res.status(500).send({ message: "Error during files processing." });
|
40
|
+
}
|
121
41
|
};
|
122
42
|
return {
|
123
|
-
uploadImageController,
|
124
43
|
uploadFileController,
|
125
|
-
|
44
|
+
uploadMultipleFileController
|
126
45
|
};
|
127
46
|
};
|
128
47
|
var files_controller = controllerFactory$1;
|
48
|
+
var middlewareMulter;
|
49
|
+
var hasRequiredMiddlewareMulter;
|
50
|
+
function requireMiddlewareMulter() {
|
51
|
+
if (hasRequiredMiddlewareMulter)
|
52
|
+
return middlewareMulter;
|
53
|
+
hasRequiredMiddlewareMulter = 1;
|
54
|
+
const sharp = require$$0;
|
55
|
+
const fs = require$$1;
|
56
|
+
const path = require$$2;
|
57
|
+
const multer = require$$3;
|
58
|
+
const createStorage = (folderName, publicPath) => {
|
59
|
+
console.log(folderName);
|
60
|
+
console.log(publicPath);
|
61
|
+
return multer.diskStorage({
|
62
|
+
destination: function(req, file, cb) {
|
63
|
+
const userUploadPath = path.join(publicPath, folderName);
|
64
|
+
fs.mkdirSync(userUploadPath, { recursive: true });
|
65
|
+
cb(null, userUploadPath);
|
66
|
+
},
|
67
|
+
filename: function(req, file, cb) {
|
68
|
+
cb(null, Date.now() + path.extname(file.originalname));
|
69
|
+
}
|
70
|
+
});
|
71
|
+
};
|
72
|
+
const createThumbnail = async (originalPath, thumbnailPath) => {
|
73
|
+
try {
|
74
|
+
await sharp(originalPath).resize(200).toFile(thumbnailPath);
|
75
|
+
} catch (error) {
|
76
|
+
console.error("Error creating thumbnail:", error);
|
77
|
+
}
|
78
|
+
};
|
79
|
+
const middlewareFactory = (db, publicPath) => {
|
80
|
+
const uploadSingleFileMiddleware = async (req, res, next) => {
|
81
|
+
const folderName = req.query.folderName ? req.query.folderName : "unsorted";
|
82
|
+
const upload = multer({ storage: createStorage(folderName, publicPath) }).single("file");
|
83
|
+
console.log(folderName);
|
84
|
+
console.log(publicPath);
|
85
|
+
upload(req, res, function(err) {
|
86
|
+
if (err instanceof multer.MulterError) {
|
87
|
+
return res.status(500).json(err);
|
88
|
+
} else if (err) {
|
89
|
+
return res.status(500).json(err);
|
90
|
+
}
|
91
|
+
next();
|
92
|
+
});
|
93
|
+
};
|
94
|
+
const uploadMultipleFilesMiddleware = async (req, res, next) => {
|
95
|
+
const folderName = req.query.folderName ? req.query.folderName : "unsorted";
|
96
|
+
const upload = multer({ storage: createStorage(folderName, publicPath) }).array("file");
|
97
|
+
upload(req, res, function(err) {
|
98
|
+
if (err instanceof multer.MulterError) {
|
99
|
+
return res.status(500).json(err);
|
100
|
+
} else if (err) {
|
101
|
+
return res.status(500).json(err);
|
102
|
+
}
|
103
|
+
next();
|
104
|
+
});
|
105
|
+
};
|
106
|
+
const generatePreviewMiddleware = async (req, res, next) => {
|
107
|
+
if (req.file) {
|
108
|
+
try {
|
109
|
+
const originalPath = req.file.path;
|
110
|
+
const thumbnailPath = path.join(
|
111
|
+
path.dirname(originalPath),
|
112
|
+
"thumbnail_" + path.basename(originalPath)
|
113
|
+
);
|
114
|
+
await createThumbnail(originalPath, thumbnailPath);
|
115
|
+
} catch (error) {
|
116
|
+
console.error("Error generating preview for single file:", error);
|
117
|
+
}
|
118
|
+
} else if (req.files) {
|
119
|
+
try {
|
120
|
+
await Promise.all(req.files.map(async (file) => {
|
121
|
+
const originalPath = file.path;
|
122
|
+
const thumbnailPath = path.join(
|
123
|
+
path.dirname(originalPath),
|
124
|
+
"thumbnail_" + path.basename(originalPath)
|
125
|
+
);
|
126
|
+
await createThumbnail(originalPath, thumbnailPath);
|
127
|
+
}));
|
128
|
+
} catch (error) {
|
129
|
+
console.error("Error generating previews for multiple files:", error);
|
130
|
+
}
|
131
|
+
}
|
132
|
+
next();
|
133
|
+
};
|
134
|
+
return {
|
135
|
+
uploadSingleFileMiddleware,
|
136
|
+
uploadMultipleFilesMiddleware,
|
137
|
+
generatePreviewMiddleware
|
138
|
+
};
|
139
|
+
};
|
140
|
+
middlewareMulter = middlewareFactory;
|
141
|
+
return middlewareMulter;
|
142
|
+
}
|
143
|
+
const middlewareIndexFactory = (db, publicPath) => {
|
144
|
+
const middlewareMulter2 = requireMiddlewareMulter()(db, publicPath);
|
145
|
+
return {
|
146
|
+
middlewareMulter: middlewareMulter2
|
147
|
+
};
|
148
|
+
};
|
149
|
+
var server = middlewareIndexFactory;
|
129
150
|
const controllerFactory = files_controller;
|
151
|
+
const middlewareFactoryGlobal = index.server;
|
152
|
+
const middlewareFactoryFiles = server;
|
130
153
|
var files_routes = function(app, db, origins, publicPath) {
|
131
|
-
const controller = controllerFactory(
|
154
|
+
const controller = controllerFactory();
|
155
|
+
middlewareFactoryGlobal(db);
|
156
|
+
console.log("Public path is " + publicPath);
|
157
|
+
const { middlewareMulter: middlewareMulter2 } = middlewareFactoryFiles(db, publicPath);
|
132
158
|
app.use(function(req, res, next) {
|
133
159
|
const origin = req.headers.origin;
|
134
|
-
console.log(origin);
|
135
160
|
if (origins.includes(origin)) {
|
136
161
|
res.setHeader("Access-Control-Allow-Origin", origin);
|
137
162
|
}
|
@@ -140,15 +165,27 @@ var files_routes = function(app, db, origins, publicPath) {
|
|
140
165
|
});
|
141
166
|
app.post(
|
142
167
|
"/api/upload/image",
|
168
|
+
[
|
169
|
+
middlewareMulter2.uploadSingleFileMiddleware,
|
170
|
+
middlewareMulter2.generatePreviewMiddleware
|
171
|
+
],
|
143
172
|
controller.uploadFileController
|
144
173
|
);
|
145
174
|
app.post(
|
146
175
|
"/api/upload/file",
|
176
|
+
[
|
177
|
+
middlewareMulter2.uploadSingleFileMiddleware,
|
178
|
+
middlewareMulter2.generatePreviewMiddleware
|
179
|
+
],
|
147
180
|
controller.uploadFileController
|
148
181
|
);
|
149
182
|
app.post(
|
150
183
|
"/api/upload/multiple",
|
151
|
-
|
184
|
+
[
|
185
|
+
middlewareMulter2.uploadMultipleFilesMiddleware,
|
186
|
+
middlewareMulter2.generatePreviewMiddleware
|
187
|
+
],
|
188
|
+
controller.uploadMultipleFileController
|
152
189
|
);
|
153
190
|
};
|
154
191
|
const filesController = files_controller;
|
package/dist/files.server.mjs
CHANGED
@@ -1,136 +1,161 @@
|
|
1
1
|
import { g as getDefaultExportFromCjs } from "./_commonjsHelpers-83b1d755.mjs";
|
2
|
-
import
|
3
|
-
import require$$
|
4
|
-
import require$$
|
2
|
+
import { s as server$1 } from "./index-fa8d5df4.mjs";
|
3
|
+
import require$$0 from "sharp";
|
4
|
+
import require$$1 from "fs";
|
5
|
+
import require$$2 from "path";
|
6
|
+
import require$$3 from "multer";
|
5
7
|
import "jsonwebtoken";
|
6
8
|
import "mongodb";
|
7
|
-
const multer = require$$0;
|
8
|
-
const path = require$$1;
|
9
|
-
const fs = require$$2;
|
10
|
-
const createMulterStorage = (folderName, publicPath) => {
|
11
|
-
return multer.diskStorage({
|
12
|
-
destination: function(req, file, cb) {
|
13
|
-
let user = {};
|
14
|
-
try {
|
15
|
-
user = JSON.parse(req.cookies.user);
|
16
|
-
} catch (err) {
|
17
|
-
return cb(new Error("Unable to parse user from cookies"));
|
18
|
-
}
|
19
|
-
if (!user._id) {
|
20
|
-
return cb(new Error("No user _id found in cookies"));
|
21
|
-
}
|
22
|
-
const userUploadPath = path.join(publicPath, "users", String(user._id), folderName);
|
23
|
-
fs.mkdirSync(userUploadPath, { recursive: true });
|
24
|
-
cb(null, userUploadPath);
|
25
|
-
},
|
26
|
-
filename: function(req, file, cb) {
|
27
|
-
cb(null, Date.now() + path.extname(file.originalname));
|
28
|
-
}
|
29
|
-
});
|
30
|
-
};
|
31
|
-
const createStorage = (folderName, publicPath) => {
|
32
|
-
return multer.diskStorage({
|
33
|
-
destination: function(req, file, cb) {
|
34
|
-
let user = {};
|
35
|
-
try {
|
36
|
-
user = JSON.parse(req.cookies.user);
|
37
|
-
} catch (err) {
|
38
|
-
return cb(new Error("Unable to parse user from cookies"));
|
39
|
-
}
|
40
|
-
if (!user._id) {
|
41
|
-
return cb(new Error("No user _id found in cookies"));
|
42
|
-
}
|
43
|
-
const userUploadPath = path.join(publicPath, folderName);
|
44
|
-
fs.mkdirSync(userUploadPath, { recursive: true });
|
45
|
-
cb(null, userUploadPath);
|
46
|
-
},
|
47
|
-
filename: function(req, file, cb) {
|
48
|
-
cb(null, Date.now() + path.extname(file.originalname));
|
49
|
-
}
|
50
|
-
});
|
51
|
-
};
|
52
9
|
const controllerFactory$1 = (db, publicPath) => {
|
53
|
-
const uploadImageController = async (req, res, next) => {
|
54
|
-
const upload = multer({ storage: createMulterStorage("blog", publicPath) }).single("file");
|
55
|
-
console.log(req.file);
|
56
|
-
upload(req, res, function(err) {
|
57
|
-
if (err instanceof multer.MulterError) {
|
58
|
-
console.log(err);
|
59
|
-
return res.status(500).json(err);
|
60
|
-
} else if (err) {
|
61
|
-
console.log(err);
|
62
|
-
return res.status(500).json(err);
|
63
|
-
}
|
64
|
-
if (!req.file) {
|
65
|
-
return res.status(400).send({ message: "No file uploaded." });
|
66
|
-
}
|
67
|
-
const user = JSON.parse(req.cookies.user);
|
68
|
-
res.status(200).send({
|
69
|
-
message: "File uploaded successfully.",
|
70
|
-
filename: req.file.filename,
|
71
|
-
filepath: `/users/${user._id}/blog/${req.file.filename}`
|
72
|
-
});
|
73
|
-
});
|
74
|
-
};
|
75
10
|
const uploadFileController = async (req, res, next) => {
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
upload(req, res, function(err) {
|
81
|
-
if (err instanceof multer.MulterError) {
|
82
|
-
console.log(err);
|
83
|
-
return res.status(500).json(err);
|
84
|
-
} else if (err) {
|
85
|
-
console.log(err);
|
86
|
-
return res.status(500).json(err);
|
87
|
-
}
|
88
|
-
if (!req.file) {
|
89
|
-
return res.status(400).send({ message: "No file uploaded." });
|
90
|
-
}
|
91
|
-
JSON.parse(req.cookies.user);
|
11
|
+
if (!req.file) {
|
12
|
+
return res.status(400).send({ message: "No file uploaded." });
|
13
|
+
}
|
14
|
+
try {
|
92
15
|
res.status(200).send({
|
93
16
|
message: "File uploaded successfully.",
|
94
17
|
filename: req.file.filename,
|
95
|
-
filepath: `/${folderName}/${req.file.filename}`
|
18
|
+
filepath: `/${req.query.folderName || "unsorted"}/${req.file.filename}`
|
96
19
|
});
|
97
|
-
})
|
20
|
+
} catch (error) {
|
21
|
+
console.error("Error in uploadFileController:", error);
|
22
|
+
return res.status(500).send({ message: "Error during file processing." });
|
23
|
+
}
|
98
24
|
};
|
99
|
-
const
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
return res.status(500).json(err);
|
106
|
-
} else if (err) {
|
107
|
-
console.log(err);
|
108
|
-
return res.status(500).json(err);
|
109
|
-
}
|
110
|
-
if (!req.files || req.files.length === 0) {
|
111
|
-
return res.status(400).send({ message: "No file uploaded." });
|
112
|
-
}
|
113
|
-
JSON.parse(req.cookies.user);
|
114
|
-
res.status(200).send(req.files.map((file) => ({
|
25
|
+
const uploadMultipleFileController = async (req, res, next) => {
|
26
|
+
if (!req.files || req.files.length === 0) {
|
27
|
+
return res.status(400).send({ message: "No files uploaded." });
|
28
|
+
}
|
29
|
+
try {
|
30
|
+
const fileResponses = req.files.map((file) => ({
|
115
31
|
message: "File uploaded successfully.",
|
116
32
|
filename: file.filename,
|
117
|
-
filepath: `/${folderName}/${file.filename}`
|
118
|
-
}))
|
119
|
-
|
33
|
+
filepath: `/${req.query.folderName || "unsorted"}/${file.filename}`
|
34
|
+
}));
|
35
|
+
res.status(200).send(fileResponses);
|
36
|
+
} catch (error) {
|
37
|
+
console.error("Error in uploadMultipleFileController:", error);
|
38
|
+
return res.status(500).send({ message: "Error during files processing." });
|
39
|
+
}
|
120
40
|
};
|
121
41
|
return {
|
122
|
-
uploadImageController,
|
123
42
|
uploadFileController,
|
124
|
-
|
43
|
+
uploadMultipleFileController
|
125
44
|
};
|
126
45
|
};
|
127
46
|
var files_controller = controllerFactory$1;
|
47
|
+
var middlewareMulter;
|
48
|
+
var hasRequiredMiddlewareMulter;
|
49
|
+
function requireMiddlewareMulter() {
|
50
|
+
if (hasRequiredMiddlewareMulter)
|
51
|
+
return middlewareMulter;
|
52
|
+
hasRequiredMiddlewareMulter = 1;
|
53
|
+
const sharp = require$$0;
|
54
|
+
const fs = require$$1;
|
55
|
+
const path = require$$2;
|
56
|
+
const multer = require$$3;
|
57
|
+
const createStorage = (folderName, publicPath) => {
|
58
|
+
console.log(folderName);
|
59
|
+
console.log(publicPath);
|
60
|
+
return multer.diskStorage({
|
61
|
+
destination: function(req, file, cb) {
|
62
|
+
const userUploadPath = path.join(publicPath, folderName);
|
63
|
+
fs.mkdirSync(userUploadPath, { recursive: true });
|
64
|
+
cb(null, userUploadPath);
|
65
|
+
},
|
66
|
+
filename: function(req, file, cb) {
|
67
|
+
cb(null, Date.now() + path.extname(file.originalname));
|
68
|
+
}
|
69
|
+
});
|
70
|
+
};
|
71
|
+
const createThumbnail = async (originalPath, thumbnailPath) => {
|
72
|
+
try {
|
73
|
+
await sharp(originalPath).resize(200).toFile(thumbnailPath);
|
74
|
+
} catch (error) {
|
75
|
+
console.error("Error creating thumbnail:", error);
|
76
|
+
}
|
77
|
+
};
|
78
|
+
const middlewareFactory = (db, publicPath) => {
|
79
|
+
const uploadSingleFileMiddleware = async (req, res, next) => {
|
80
|
+
const folderName = req.query.folderName ? req.query.folderName : "unsorted";
|
81
|
+
const upload = multer({ storage: createStorage(folderName, publicPath) }).single("file");
|
82
|
+
console.log(folderName);
|
83
|
+
console.log(publicPath);
|
84
|
+
upload(req, res, function(err) {
|
85
|
+
if (err instanceof multer.MulterError) {
|
86
|
+
return res.status(500).json(err);
|
87
|
+
} else if (err) {
|
88
|
+
return res.status(500).json(err);
|
89
|
+
}
|
90
|
+
next();
|
91
|
+
});
|
92
|
+
};
|
93
|
+
const uploadMultipleFilesMiddleware = async (req, res, next) => {
|
94
|
+
const folderName = req.query.folderName ? req.query.folderName : "unsorted";
|
95
|
+
const upload = multer({ storage: createStorage(folderName, publicPath) }).array("file");
|
96
|
+
upload(req, res, function(err) {
|
97
|
+
if (err instanceof multer.MulterError) {
|
98
|
+
return res.status(500).json(err);
|
99
|
+
} else if (err) {
|
100
|
+
return res.status(500).json(err);
|
101
|
+
}
|
102
|
+
next();
|
103
|
+
});
|
104
|
+
};
|
105
|
+
const generatePreviewMiddleware = async (req, res, next) => {
|
106
|
+
if (req.file) {
|
107
|
+
try {
|
108
|
+
const originalPath = req.file.path;
|
109
|
+
const thumbnailPath = path.join(
|
110
|
+
path.dirname(originalPath),
|
111
|
+
"thumbnail_" + path.basename(originalPath)
|
112
|
+
);
|
113
|
+
await createThumbnail(originalPath, thumbnailPath);
|
114
|
+
} catch (error) {
|
115
|
+
console.error("Error generating preview for single file:", error);
|
116
|
+
}
|
117
|
+
} else if (req.files) {
|
118
|
+
try {
|
119
|
+
await Promise.all(req.files.map(async (file) => {
|
120
|
+
const originalPath = file.path;
|
121
|
+
const thumbnailPath = path.join(
|
122
|
+
path.dirname(originalPath),
|
123
|
+
"thumbnail_" + path.basename(originalPath)
|
124
|
+
);
|
125
|
+
await createThumbnail(originalPath, thumbnailPath);
|
126
|
+
}));
|
127
|
+
} catch (error) {
|
128
|
+
console.error("Error generating previews for multiple files:", error);
|
129
|
+
}
|
130
|
+
}
|
131
|
+
next();
|
132
|
+
};
|
133
|
+
return {
|
134
|
+
uploadSingleFileMiddleware,
|
135
|
+
uploadMultipleFilesMiddleware,
|
136
|
+
generatePreviewMiddleware
|
137
|
+
};
|
138
|
+
};
|
139
|
+
middlewareMulter = middlewareFactory;
|
140
|
+
return middlewareMulter;
|
141
|
+
}
|
142
|
+
const middlewareIndexFactory = (db, publicPath) => {
|
143
|
+
const middlewareMulter2 = requireMiddlewareMulter()(db, publicPath);
|
144
|
+
return {
|
145
|
+
middlewareMulter: middlewareMulter2
|
146
|
+
};
|
147
|
+
};
|
148
|
+
var server = middlewareIndexFactory;
|
128
149
|
const controllerFactory = files_controller;
|
150
|
+
const middlewareFactoryGlobal = server$1;
|
151
|
+
const middlewareFactoryFiles = server;
|
129
152
|
var files_routes = function(app, db, origins, publicPath) {
|
130
|
-
const controller = controllerFactory(
|
153
|
+
const controller = controllerFactory();
|
154
|
+
middlewareFactoryGlobal(db);
|
155
|
+
console.log("Public path is " + publicPath);
|
156
|
+
const { middlewareMulter: middlewareMulter2 } = middlewareFactoryFiles(db, publicPath);
|
131
157
|
app.use(function(req, res, next) {
|
132
158
|
const origin = req.headers.origin;
|
133
|
-
console.log(origin);
|
134
159
|
if (origins.includes(origin)) {
|
135
160
|
res.setHeader("Access-Control-Allow-Origin", origin);
|
136
161
|
}
|
@@ -139,15 +164,27 @@ var files_routes = function(app, db, origins, publicPath) {
|
|
139
164
|
});
|
140
165
|
app.post(
|
141
166
|
"/api/upload/image",
|
167
|
+
[
|
168
|
+
middlewareMulter2.uploadSingleFileMiddleware,
|
169
|
+
middlewareMulter2.generatePreviewMiddleware
|
170
|
+
],
|
142
171
|
controller.uploadFileController
|
143
172
|
);
|
144
173
|
app.post(
|
145
174
|
"/api/upload/file",
|
175
|
+
[
|
176
|
+
middlewareMulter2.uploadSingleFileMiddleware,
|
177
|
+
middlewareMulter2.generatePreviewMiddleware
|
178
|
+
],
|
146
179
|
controller.uploadFileController
|
147
180
|
);
|
148
181
|
app.post(
|
149
182
|
"/api/upload/multiple",
|
150
|
-
|
183
|
+
[
|
184
|
+
middlewareMulter2.uploadMultipleFilesMiddleware,
|
185
|
+
middlewareMulter2.generatePreviewMiddleware
|
186
|
+
],
|
187
|
+
controller.uploadMultipleFileController
|
151
188
|
);
|
152
189
|
};
|
153
190
|
const filesController = files_controller;
|