@cocreate/file-server 1.0.14 → 1.0.16

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.16](https://github.com/CoCreate-app/CoCreate-file-server/compare/v1.0.15...v1.0.16) (2022-12-05)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * testing ([7631e2d](https://github.com/CoCreate-app/CoCreate-file-server/commit/7631e2de7cb8b617c4abb1f916603f3496fac453))
7
+
8
+ ## [1.0.15](https://github.com/CoCreate-app/CoCreate-file-server/compare/v1.0.14...v1.0.15) (2022-12-05)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * console.logs ([e73293f](https://github.com/CoCreate-app/CoCreate-file-server/commit/e73293fbb50330760a42250b773581527e870bd3))
14
+
1
15
  ## [1.0.14](https://github.com/CoCreate-app/CoCreate-file-server/compare/v1.0.13...v1.0.14) (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.14",
3
+ "version": "1.0.16",
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'];
@@ -87,17 +88,18 @@ class CoCreateFileSystem {
87
88
  res.send('could not find src');
88
89
  }
89
90
 
90
- let content_type = file['content_type'] || mime.lookup(url) || 'text/html';
91
-
92
- if (content_type.startsWith('image/') || content_type.startsWith('audio/') || content_type.startsWith('video/')) {
91
+ let contentType = file['content-type'] || mime.lookup(url) || 'text/html';
92
+ console.log('src', contentType)
93
+
94
+ if (contentType.startsWith('image/') || contentType.startsWith('audio/') || contentType.startsWith('video/')) {
93
95
  var base64Data = src.replace(/^data:image\/(png|jpeg|jpg);base64,/, '');
94
96
  let file = Buffer.from(base64Data, 'base64');
95
97
  res.writeHead(200, {
96
- 'Content-Type': content_type,
98
+ 'Content-Type': contentType,
97
99
  'Content-Length': file.length
98
100
  });
99
101
  res.send(file);
100
- } else if (content_type === 'text/html') {
102
+ } else if (contentType === 'text/html') {
101
103
  try {
102
104
  let html = await render.HTML(src, organization_id);
103
105
  if (html)
@@ -105,11 +107,13 @@ class CoCreateFileSystem {
105
107
  }
106
108
  catch (err) {
107
109
  console.warn('server-render: ' + err.message)
110
+ } finally {
111
+ console.log('returned html')
112
+ res.type(contentType);
113
+ res.send(src)
108
114
  }
109
- res.type(content_type);
110
- res.send(src)
111
115
  } else {
112
- res.type(content_type);
116
+ res.type(contentType);
113
117
  res.send(src);
114
118
  }
115
119