@ozdao/prometheus-framework 0.1.16 → 0.1.17

Sign up to get free protection for your applications and to get access to all the features.
Files changed (100) hide show
  1. package/dist/Breadcrumbs.vue_vue_type_style_index_0_lang-579e2c7a.mjs +1945 -0
  2. package/dist/Breadcrumbs.vue_vue_type_style_index_0_lang-cab2bcd2.js +1 -0
  3. package/dist/ButtonFollow-23c4d9fc.mjs +132 -0
  4. package/dist/ButtonFollow-bf5e6d42.js +1 -0
  5. package/dist/CardOrganization-63dcc83b.js +1 -0
  6. package/dist/CardOrganization-e530c9d5.mjs +230 -0
  7. package/dist/Chips-3dac276c.js +1 -0
  8. package/dist/Feed-4d9001aa.mjs +368 -0
  9. package/dist/Feed-51eef23f.js +1 -0
  10. package/dist/Feed-d78d4b91.mjs +439 -0
  11. package/dist/Feed-f4e9769e.js +1 -0
  12. package/dist/Gallery-1f82841a.mjs +357 -0
  13. package/dist/Gallery-dd29c7f6.js +1 -0
  14. package/dist/Image-a2c2ab9c.js +9 -0
  15. package/dist/Image-ad6d4f0f.mjs +477 -0
  16. package/dist/Popup-383abb2e.js +1 -0
  17. package/dist/Popup-f7a5e86b.mjs +76 -0
  18. package/dist/Product-b32fb0e1.js +7 -0
  19. package/dist/Product-d01e3a0d.mjs +839 -0
  20. package/dist/ProductEdit-2b4d1d88.js +1 -0
  21. package/dist/ProductEdit-5e479343.mjs +300 -0
  22. package/dist/ProfileBlogposts-070cb7e9.mjs +65 -0
  23. package/dist/ProfileBlogposts-b6bf0c42.js +1 -0
  24. package/dist/ProfileComments-8a0c489c.mjs +44 -0
  25. package/dist/ProfileComments-f0000ea6.js +1 -0
  26. package/dist/ProfileEvents-8b88287a.js +1 -0
  27. package/dist/ProfileEvents-d978617d.mjs +57 -0
  28. package/dist/ProfileLikes-d5f9f058.js +1 -0
  29. package/dist/ProfileLikes-f5ad4497.mjs +44 -0
  30. package/dist/ProfileOrganizations-422d1fa5.js +1 -0
  31. package/dist/ProfileOrganizations-6b1bc5b2.mjs +213 -0
  32. package/dist/Publics-640d32fc.mjs +123 -0
  33. package/dist/Publics-8595ab7e.js +1 -0
  34. package/dist/Socials-43293869.js +1 -0
  35. package/dist/Tab-dcd62005.js +1 -0
  36. package/dist/UploadImage-dfb36cdb.js +1 -0
  37. package/dist/UploadImage-e4418b43.mjs +83 -0
  38. package/dist/UploadImageMultiple-c9a7b54f.js +1 -0
  39. package/dist/UploadImageMultiple-d2d48f39.mjs +58 -0
  40. package/dist/auth-45a454f2.js +7 -0
  41. package/dist/auth-5cd34aae.mjs +905 -0
  42. package/dist/auth.client.cjs +8 -8
  43. package/dist/auth.client.js +16 -15
  44. package/dist/auth.validation-4b016fa5.js +1 -0
  45. package/dist/auth.validation-a52304cf.mjs +20 -0
  46. package/dist/backoffice.client.cjs +1 -0
  47. package/dist/backoffice.client.js +69 -0
  48. package/dist/carousel.es-cdfb392c.js +5 -0
  49. package/dist/community.client.cjs +1 -1
  50. package/dist/community.client.js +23 -22
  51. package/dist/components/EditImages/EditImages.vue.d.ts +7 -0
  52. package/dist/components/FieldPhone/FieldPhone(script-setup).vue.d.ts +3 -3
  53. package/dist/components/FieldPhone/FieldPhone.vue.d.ts +1 -1
  54. package/dist/events.client.cjs +2 -2
  55. package/dist/events.client.js +17 -16
  56. package/dist/files.server.js +149 -112
  57. package/dist/files.server.mjs +149 -112
  58. package/dist/gallery.server.js +127 -0
  59. package/dist/gallery.server.mjs +128 -0
  60. package/dist/index-2059e444.js +2 -0
  61. package/dist/index-4e469a71.mjs +941 -0
  62. package/dist/landing.client.cjs +1 -1
  63. package/dist/modules/gallery/components/sections/Gallery.vue.d.ts +2 -0
  64. package/dist/modules/icons/navigation/IconChevronRight.vue.d.ts +13 -1
  65. package/dist/modules/mobile/components/Menu/MenuItem.vue.d.ts +14 -2
  66. package/dist/organizations-81e762e7.mjs +122 -0
  67. package/dist/organizations-cf1ab766.js +1 -0
  68. package/dist/organizations.client-b692a78a.mjs +3018 -0
  69. package/dist/organizations.client-bdc9b044.js +3 -0
  70. package/dist/organizations.client.cjs +1 -1
  71. package/dist/organizations.client.js +44 -43
  72. package/dist/style.css +1 -1
  73. package/dist/users.client.cjs +1 -1
  74. package/dist/users.client.js +224 -184
  75. package/dist/vue-draggable-next.esm-bundler-21a209c6.js +10 -0
  76. package/dist/vuex.esm-bundler-685cf29f.js +5 -0
  77. package/package.json +10 -1
  78. package/src/components/EditImages/EditImages.vue +55 -0
  79. package/src/configurator/components/layouts/layoutConfigurator.vue +0 -40
  80. package/src/modules/backoffice/backoffice.client.js +15 -0
  81. package/src/modules/backoffice/components/layouts/Account.vue +48 -58
  82. package/src/modules/backoffice/router/backoffice.js +20 -0
  83. package/src/modules/files/controllers/files.controller.js +27 -131
  84. package/src/modules/files/middlewares/server/index.js +10 -0
  85. package/src/modules/files/middlewares/server/md.js +151 -0
  86. package/src/modules/files/middlewares/server/middlewareMulter.js +121 -0
  87. package/src/modules/files/routes/files.routes.js +20 -6
  88. package/src/modules/gallery/components/sections/Gallery.vue +414 -0
  89. package/src/modules/gallery/controllers/gallery.controller.js +87 -73
  90. package/src/modules/gallery/gallery.client.js +17 -0
  91. package/src/modules/gallery/gallery.server.js +13 -0
  92. package/src/modules/gallery/models/photo.model.js +20 -14
  93. package/src/modules/gallery/routes/gallery.routes.js +18 -9
  94. package/src/modules/gallery/store/gallery.js +25 -19
  95. package/src/modules/icons/navigation/IconChevronRight.vue +14 -2
  96. package/src/modules/mobile/components/Menu/Menu.vue +1 -1
  97. package/src/modules/mobile/components/Menu/MenuItem.vue +8 -2
  98. package/src/modules/users/components/pages/Profile.vue +22 -1
  99. package/src/modules/backoffice/components/pages/Profile.vue +0 -109
  100. package/src/modules/backoffice/components/pages/profile/ProfileEdit.vue +0 -132
@@ -0,0 +1,10 @@
1
+ // middlewareIndexFactory.js
2
+ const middlewareIndexFactory = (db, publicPath) => {
3
+ const middlewareMulter = require("./middlewareMulter")(db, publicPath);
4
+
5
+ return {
6
+ middlewareMulter
7
+ };
8
+ };
9
+
10
+ module.exports = middlewareIndexFactory;
@@ -0,0 +1,151 @@
1
+ const multer = require('multer');
2
+ const path = require('path');
3
+ const fs = require('fs');
4
+
5
+ const createMulterStorage = (folderName, publicPath) => {
6
+
7
+ return multer.diskStorage({
8
+ destination: function (req, file, cb) {
9
+ let user = {};
10
+ try {
11
+ user = JSON.parse(req.cookies.user);
12
+ } catch (err) {
13
+ return cb(new Error('Unable to parse user from cookies'));
14
+ }
15
+
16
+ if (!user._id) {
17
+ return cb(new Error('No user _id found in cookies'));
18
+ }
19
+
20
+ const userUploadPath = path.join(publicPath, 'users', String(user._id), folderName);
21
+
22
+ fs.mkdirSync(userUploadPath, { recursive: true });
23
+
24
+ cb(null, userUploadPath);
25
+ },
26
+ filename: function (req, file, cb) {
27
+ cb(null, Date.now() + path.extname(file.originalname));
28
+ }
29
+ });
30
+ }
31
+
32
+ const createStorage = (folderName, publicPath) => {
33
+
34
+ return multer.diskStorage({
35
+ destination: function (req, file, cb) {
36
+ let user = {};
37
+ try {
38
+ user = JSON.parse(req.cookies.user);
39
+ } catch (err) {
40
+ return cb(new Error('Unable to parse user from cookies'));
41
+ }
42
+
43
+ if (!user._id) {
44
+ return cb(new Error('No user _id found in cookies'));
45
+ }
46
+
47
+ const userUploadPath = path.join(publicPath, folderName);
48
+
49
+ fs.mkdirSync(userUploadPath, { recursive: true });
50
+
51
+ cb(null, userUploadPath);
52
+ },
53
+ filename: function (req, file, cb) {
54
+ cb(null, Date.now() + path.extname(file.originalname));
55
+ }
56
+ });
57
+ }
58
+
59
+ const controllerFactory = (db, publicPath) => {
60
+ const uploadImageController = async (req, res, next) => {
61
+ const upload = multer({ storage: createMulterStorage('blog', publicPath) }).single('file');
62
+
63
+ console.log(req.file)
64
+
65
+ upload(req, res, function(err) {
66
+ if (err instanceof multer.MulterError) {
67
+ console.log(err)
68
+ return res.status(500).json(err);
69
+ } else if (err) {
70
+ console.log(err)
71
+ return res.status(500).json(err);
72
+ }
73
+ if (!req.file) {
74
+ return res.status(400).send({ message: 'No file uploaded.' });
75
+ }
76
+
77
+ const user = JSON.parse(req.cookies.user);
78
+
79
+ res.status(200).send({
80
+ message: 'File uploaded successfully.',
81
+ filename: req.file.filename,
82
+ filepath: `/users/${user._id}/blog/${req.file.filename}`
83
+ });
84
+ });
85
+ };
86
+
87
+ const uploadFileController = async (req, res, next) => {
88
+
89
+ const folderName = req.query.folderName ? req.query.folderName : 'unsorted'; // получаем folderName из параметров запроса
90
+ const upload = multer({ storage: createStorage(folderName, publicPath) }).single('file');
91
+
92
+ console.log(folderName)
93
+ console.log(req.files)
94
+
95
+ upload(req, res, function(err) {
96
+ if (err instanceof multer.MulterError) {
97
+ console.log(err)
98
+ return res.status(500).json(err);
99
+ } else if (err) {
100
+ console.log(err)
101
+ return res.status(500).json(err);
102
+ }
103
+ if (!req.file) {
104
+ return res.status(400).send({ message: 'No file uploaded.' });
105
+ }
106
+
107
+ const user = JSON.parse(req.cookies.user);
108
+
109
+ res.status(200).send({
110
+ message: 'File uploaded successfully.',
111
+ filename: req.file.filename,
112
+ filepath: `/${folderName}/${req.file.filename}`
113
+ });
114
+ });
115
+ };
116
+
117
+ const uploadMultipleFile = async (req, res, next) => {
118
+ const folderName = req.query.folderName; // получаем folderName из параметров запроса
119
+ const upload = multer({ storage: createStorage(folderName) }).array('file');
120
+
121
+ upload(req, res, function(err) {
122
+ if (err instanceof multer.MulterError) {
123
+ console.log(err)
124
+ return res.status(500).json(err);
125
+ } else if (err) {
126
+ console.log(err)
127
+ return res.status(500).json(err);
128
+ }
129
+ if (!req.files || req.files.length === 0) {
130
+ return res.status(400).send({ message: 'No file uploaded.' });
131
+ }
132
+
133
+ const user = JSON.parse(req.cookies.user);
134
+
135
+ // send back all filenames and paths
136
+ res.status(200).send(req.files.map(file => ({
137
+ message: 'File uploaded successfully.',
138
+ filename: file.filename,
139
+ filepath: `/${folderName}/${file.filename}`,
140
+ })));
141
+ });
142
+ };
143
+
144
+ return {
145
+ uploadImageController,
146
+ uploadFileController,
147
+ uploadMultipleFile
148
+ };
149
+ };
150
+
151
+ module.exports = controllerFactory;
@@ -0,0 +1,121 @@
1
+ // middlewareFactory.js
2
+ const sharp = require('sharp');
3
+ const fs = require('fs');
4
+ const path = require('path');
5
+ const multer = require('multer');
6
+
7
+ const createStorage = (folderName, publicPath) => {
8
+ console.log(folderName)
9
+ console.log(publicPath)
10
+
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
+
20
+ // if (!user._id) {
21
+ // return cb(new Error('No user _id found in cookies'));
22
+ // }
23
+
24
+ const userUploadPath = path.join(publicPath, folderName);
25
+
26
+ fs.mkdirSync(userUploadPath, { recursive: true });
27
+
28
+ cb(null, userUploadPath);
29
+ },
30
+ filename: function (req, file, cb) {
31
+ cb(null, Date.now() + path.extname(file.originalname));
32
+ }
33
+ });
34
+ }
35
+
36
+ const createThumbnail = async (originalPath, thumbnailPath) => {
37
+ try {
38
+ await sharp(originalPath)
39
+ .resize(200)
40
+ .toFile(thumbnailPath);
41
+ } catch (error) {
42
+ console.error("Error creating thumbnail:", error);
43
+ }
44
+ };
45
+
46
+
47
+ const middlewareFactory = (db, publicPath) => {
48
+ const uploadSingleFileMiddleware = async (req, res, next) => {
49
+
50
+ const folderName = req.query.folderName ? req.query.folderName : 'unsorted'; // получаем folderName из параметров запроса
51
+ const upload = multer({ storage: createStorage(folderName, publicPath) }).single('file');
52
+ console.log(folderName)
53
+ console.log(publicPath)
54
+
55
+ upload(req, res, function(err) {
56
+ if (err instanceof multer.MulterError) {
57
+ // A Multer error occurred when uploading.
58
+ return res.status(500).json(err);
59
+ } else if (err) {
60
+ // An unknown error occurred when uploading.
61
+ return res.status(500).json(err);
62
+ }
63
+ next(); // Everything went fine.
64
+ });
65
+ }
66
+
67
+ const uploadMultipleFilesMiddleware = async (req, res, next) => {
68
+
69
+
70
+ const folderName = req.query.folderName ? req.query.folderName : 'unsorted'; // получаем folderName из параметров запроса
71
+ const upload = multer({ storage: createStorage(folderName, publicPath) }).array('file');
72
+
73
+ upload(req, res, function(err) {
74
+ if (err instanceof multer.MulterError) {
75
+ return res.status(500).json(err);
76
+ } else if (err) {
77
+ return res.status(500).json(err);
78
+ }
79
+ next();
80
+ });
81
+ }
82
+
83
+ const generatePreviewMiddleware = async (req, res, next) => {
84
+ if (req.file) { // if a single file is uploaded
85
+ try {
86
+ const originalPath = req.file.path;
87
+ const thumbnailPath = path.join(
88
+ path.dirname(originalPath),
89
+ 'thumbnail_' + path.basename(originalPath)
90
+ );
91
+ await createThumbnail(originalPath, thumbnailPath);
92
+ } catch (error) {
93
+ console.error('Error generating preview for single file:', error);
94
+ }
95
+ } else if (req.files) { // if multiple files are uploaded
96
+ try {
97
+ await Promise.all(req.files.map(async file => {
98
+ const originalPath = file.path;
99
+ const thumbnailPath = path.join(
100
+ path.dirname(originalPath),
101
+ 'thumbnail_' + path.basename(originalPath)
102
+ );
103
+ await createThumbnail(originalPath, thumbnailPath);
104
+ }));
105
+ } catch (error) {
106
+ console.error('Error generating previews for multiple files:', error);
107
+ }
108
+ }
109
+ next();
110
+ };
111
+
112
+
113
+
114
+ return {
115
+ uploadSingleFileMiddleware,
116
+ uploadMultipleFilesMiddleware,
117
+ generatePreviewMiddleware
118
+ };
119
+ };
120
+
121
+ module.exports = middlewareFactory;
@@ -1,16 +1,19 @@
1
1
  // Factories
2
2
  const controllerFactory = require("../controllers/files.controller");
3
3
  // Middlewares
4
- const middlewareFactory = require('@pf/src/modules/middlewares/server');
4
+ const middlewareFactoryGlobal = require('@pf/src/modules/middlewares/server');
5
+ const middlewareFactoryFiles = require('../middlewares/server');
5
6
 
6
7
  module.exports = function(app, db, origins, publicPath) {
7
8
  const controller = controllerFactory(db, publicPath);
8
9
 
10
+ const { authJwt } = middlewareFactoryGlobal(db);
11
+ console.log('Public path is ' + publicPath)
12
+ const { middlewareMulter } = middlewareFactoryFiles(db, publicPath);
13
+
9
14
  app.use(function(req, res, next) {
10
15
 
11
16
  const origin = req.headers.origin;
12
-
13
- console.log(origin)
14
17
 
15
18
  if (origins.includes(origin)) {
16
19
  res.setHeader('Access-Control-Allow-Origin', origin);
@@ -20,20 +23,31 @@ module.exports = function(app, db, origins, publicPath) {
20
23
 
21
24
  next();
22
25
  });
23
-
26
+
24
27
  app.post(
25
28
  "/api/upload/image",
29
+ [
30
+ middlewareMulter.uploadSingleFileMiddleware,
31
+ middlewareMulter.generatePreviewMiddleware
32
+ ],
26
33
  controller.uploadFileController
27
34
  );
28
35
 
29
36
  app.post(
30
37
  "/api/upload/file",
38
+ [
39
+ middlewareMulter.uploadSingleFileMiddleware,
40
+ middlewareMulter.generatePreviewMiddleware
41
+ ],
31
42
  controller.uploadFileController
32
43
  );
33
44
 
34
45
  app.post(
35
46
  "/api/upload/multiple",
36
- controller.uploadMultipleFile
47
+ [
48
+ middlewareMulter.uploadMultipleFilesMiddleware,
49
+ middlewareMulter.generatePreviewMiddleware
50
+ ],
51
+ controller.uploadMultipleFileController
37
52
  );
38
-
39
53
  };