@feardread/fear 1.0.7 → 1.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -101,7 +101,7 @@ exports.read = tryCatch(async (Model, req, res) => {
101
101
  */
102
102
  exports.create = tryCatch(async (Model, req, res) => {
103
103
  const documentData = { ...req.body };
104
-
104
+ console.log('raw document data = ', documentData);
105
105
  // Handle image uploads if present
106
106
  if (documentData.images) {
107
107
  // Parse comma-separated string to array if needed
@@ -109,24 +109,23 @@ exports.create = tryCatch(async (Model, req, res) => {
109
109
  ? documentData.images.split(',').map(item => item.trim())
110
110
  : documentData.images;
111
111
 
112
- const imageLinks = await cloud.uploadImages(imageArray);
113
-
114
- if (imageLinks) {
115
- documentData.images = imageLinks;
116
- console.log('Added Images:', imageLinks);
117
- }
112
+ await cloud.uploadImages(imageArray)
113
+ .then((imageLinks) => {
114
+ if (imageLinks) documentData.images = imageLinks;
115
+ console.log('Uploaded Images:', imageLinks);
116
+ })
117
+ .catch((error) => { console.log('Error Uploading Images:: ', error);});
118
118
  }
119
119
 
120
120
  console.log('Creating document:', documentData);
121
121
 
122
122
  const document = new Model(documentData);
123
- const result = await document.save();
124
-
125
- return res.status(201).json({
126
- result,
127
- success: true,
128
- message: `Document created successfully in ${Model.modelName} collection`
129
- });
123
+ await document.save()
124
+ .then((result) => {
125
+ return res.status(201).json({ result, success: true,
126
+ message: `Document created successfully in ${Model.modelName} collection`});
127
+ })
128
+ .catch((error) => {console.log('Error Saving document :: ', error);});
130
129
  });
131
130
 
132
131
  /**
@@ -82,7 +82,7 @@ const uploadImages = async (files, chunkSize = 3) => {
82
82
 
83
83
  return imageLinks;
84
84
  } catch (error) {
85
- throw new Error(`Image upload failed: ${error.message}`);
85
+ throw new Error(`Image upload failed: ${error}`);
86
86
  }
87
87
  };
88
88
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@feardread/fear",
3
- "version": "1.0.7",
3
+ "version": "1.0.9",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {