codehooks-js 1.2.9 → 1.2.10
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/index.js +4 -0
- package/package.json +1 -1
- package/types/index.d.ts +12 -1
- package/webserver.mjs +4 -4
package/index.js
CHANGED
package/package.json
CHANGED
package/types/index.d.ts
CHANGED
|
@@ -839,7 +839,7 @@ declare class Codehooks {
|
|
|
839
839
|
): void;
|
|
840
840
|
|
|
841
841
|
/**
|
|
842
|
-
* Serve static file content
|
|
842
|
+
* Serve static file content from a source code diretory
|
|
843
843
|
* @param {Object} options - {route: "/", default: "index.html", directory: "/static"}
|
|
844
844
|
* @returns void
|
|
845
845
|
*/
|
|
@@ -849,6 +849,17 @@ declare class Codehooks {
|
|
|
849
849
|
response: httpResponse,
|
|
850
850
|
next: nextFunction
|
|
851
851
|
) => any)[]) => void;
|
|
852
|
+
/**
|
|
853
|
+
* Serve file content from a blob storage diretory
|
|
854
|
+
* @param {Object} options - {route: "/documents", directory: "/docs"}
|
|
855
|
+
* @returns void
|
|
856
|
+
*/
|
|
857
|
+
storage: (options: any,
|
|
858
|
+
...hook: ((
|
|
859
|
+
request: httpRequest,
|
|
860
|
+
response: httpResponse,
|
|
861
|
+
next: nextFunction
|
|
862
|
+
) => any)[]) => void;
|
|
852
863
|
/**
|
|
853
864
|
* Configuration settings
|
|
854
865
|
* @param {string} key
|
package/webserver.mjs
CHANGED
|
@@ -16,7 +16,7 @@ function promisify(cb, fn) {
|
|
|
16
16
|
|
|
17
17
|
const defaultOptions = { route: '/public', default: "index.html", directory: "/" };
|
|
18
18
|
|
|
19
|
-
export function serveStatic(options, app, filestore, hook) {
|
|
19
|
+
export function serveStatic(options, app, filestore, hook, fsoptions) {
|
|
20
20
|
if (!options) {
|
|
21
21
|
options = defaultOptions;
|
|
22
22
|
}
|
|
@@ -65,7 +65,7 @@ export function serveStatic(options, app, filestore, hook) {
|
|
|
65
65
|
// get mime type
|
|
66
66
|
const type = mime.getType(filePath)
|
|
67
67
|
console.debug('Serve file', filePath, type)
|
|
68
|
-
const filestream = await filestore.getReadStream(filePath);
|
|
68
|
+
const filestream = await filestore.getReadStream(filePath, fsoptions);
|
|
69
69
|
res.set('Content-Type', type || 'application/octet-stream');
|
|
70
70
|
if (options.headers) {
|
|
71
71
|
res.headers(options.headers);
|
|
@@ -133,7 +133,7 @@ async function ejs(viewFile, data, settings, cb) {
|
|
|
133
133
|
if (tmplCache[viewFile]) {
|
|
134
134
|
tmpl = tmplCache[viewFile];
|
|
135
135
|
} else {
|
|
136
|
-
const txtfile = await _coho_fs.readFile(`${settings.views}/${viewFile}.ejs
|
|
136
|
+
const txtfile = await _coho_fs.readFile(`${settings.views}/${viewFile}.ejs`, {source: true});
|
|
137
137
|
//console.log('Txtfile', txtfile)
|
|
138
138
|
tmplCache[viewFile] = engine.compile(txtfile);
|
|
139
139
|
tmpl = tmplCache[viewFile];
|
|
@@ -161,7 +161,7 @@ async function handlebars(viewFile, data, settings, cb) {
|
|
|
161
161
|
//console.log('Layout file', layoutFile)
|
|
162
162
|
engine.registerPartial('layout', layoutFile);
|
|
163
163
|
}
|
|
164
|
-
const txtfile = await _coho_fs.readFile(`${settings.views}/${viewFile}.hbs
|
|
164
|
+
const txtfile = await _coho_fs.readFile(`${settings.views}/${viewFile}.hbs`, {source: true});
|
|
165
165
|
//console.log('Txtfile', txtfile)
|
|
166
166
|
tmplCache[viewFile] = engine.compile(txtfile);
|
|
167
167
|
tmpl = tmplCache[viewFile];
|