@feardread/fear 1.0.9 → 1.1.1

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.
@@ -59,22 +59,13 @@ exports.all = tryCatch(async (Model, req, res) => {
59
59
  exports.read = tryCatch(async (Model, req, res) => {
60
60
  const { id } = req.params;
61
61
 
62
- if (!id) {
62
+ if (!id || !isValidObjectId(id)) {
63
63
  return res.status(400).json({
64
64
  result: null,
65
65
  success: false,
66
- message: "Document ID is required"
66
+ message: "Invalid or Missing Document ID"
67
67
  });
68
68
  }
69
-
70
- if (!isValidObjectId(id)) {
71
- return res.status(400).json({
72
- result: null,
73
- success: false,
74
- message: "Invalid document ID format"
75
- });
76
- }
77
-
78
69
  const result = await Model.findById(id).exec();
79
70
 
80
71
  if (!result) {
@@ -101,20 +92,14 @@ exports.read = tryCatch(async (Model, req, res) => {
101
92
  */
102
93
  exports.create = tryCatch(async (Model, req, res) => {
103
94
  const documentData = { ...req.body };
104
- console.log('raw document data = ', documentData);
105
95
  // Handle image uploads if present
106
96
  if (documentData.images) {
107
- // Parse comma-separated string to array if needed
108
- const imageArray = typeof documentData.images === 'string'
109
- ? documentData.images.split(',').map(item => item.trim())
110
- : documentData.images;
111
-
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);});
97
+
98
+ documentData.images.split(',').map(item => item.trim());
99
+
100
+ const imageLinks = await cloud.uploadImages(documentData.images);
101
+
102
+ if ( imageLinks ) documentData.images = imageLinks;
118
103
  }
119
104
 
120
105
  console.log('Creating document:', documentData);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@feardread/fear",
3
- "version": "1.0.9",
3
+ "version": "1.1.1",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {