@cocreate/file-server 1.0.15 → 1.0.17

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.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,17 @@
1
+ ## [1.0.17](https://github.com/CoCreate-app/CoCreate-file-server/compare/v1.0.16...v1.0.17) (2022-12-05)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * testing ([496a175](https://github.com/CoCreate-app/CoCreate-file-server/commit/496a17513e9c1cc6628fbb056501a015e9dc7c4e))
7
+
8
+ ## [1.0.16](https://github.com/CoCreate-app/CoCreate-file-server/compare/v1.0.15...v1.0.16) (2022-12-05)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * testing ([7631e2d](https://github.com/CoCreate-app/CoCreate-file-server/commit/7631e2de7cb8b617c4abb1f916603f3496fac453))
14
+
1
15
  ## [1.0.15](https://github.com/CoCreate-app/CoCreate-file-server/compare/v1.0.14...v1.0.15) (2022-12-05)
2
16
 
3
17
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cocreate/file-server",
3
- "version": "1.0.15",
3
+ "version": "1.0.17",
4
4
  "description": "A simple file-server component in vanilla javascript. Easily configured using HTML5 data-attributes and/or JavaScript API.",
5
5
  "keywords": [
6
6
  "file-server",
package/src/index.js CHANGED
@@ -68,7 +68,8 @@ class CoCreateFileSystem {
68
68
  file = file.document[0]
69
69
  if (!file['public'] || file['public'] === "false")
70
70
  return res.status(404).send(`access not allowed`);
71
-
71
+
72
+ console.log('file found', url)
72
73
  let src;
73
74
  if (file['src'])
74
75
  src = file['src'];
@@ -84,11 +85,13 @@ class CoCreateFileSystem {
84
85
  }
85
86
 
86
87
  if (!src) {
87
- res.send('could not find src');
88
+ console.log('src not found')
89
+ // res.send('could not find src');
88
90
  }
89
91
 
90
92
  let contentType = file['content-type'] || mime.lookup(url) || 'text/html';
91
-
93
+ console.log('src', contentType)
94
+
92
95
  if (contentType.startsWith('image/') || contentType.startsWith('audio/') || contentType.startsWith('video/')) {
93
96
  var base64Data = src.replace(/^data:image\/(png|jpeg|jpg);base64,/, '');
94
97
  let file = Buffer.from(base64Data, 'base64');
@@ -99,17 +102,17 @@ class CoCreateFileSystem {
99
102
  res.send(file);
100
103
  } else if (contentType === 'text/html') {
101
104
  try {
102
- console.log('html src', src)
103
105
  let html = await render.HTML(src, organization_id);
104
- console.log('returned html', html)
105
106
  if (html)
106
107
  src = html
107
108
  }
108
109
  catch (err) {
109
110
  console.warn('server-render: ' + err.message)
111
+ } finally {
112
+ console.log('returned html')
113
+ res.type(contentType);
114
+ res.send(src)
110
115
  }
111
- res.type(contentType);
112
- res.send(src)
113
116
  } else {
114
117
  res.type(contentType);
115
118
  res.send(src);