html-express-js 4.0.0 → 4.2.0

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/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "html-express-js",
3
- "version": "4.0.0",
3
+ "version": "4.2.0",
4
4
  "description": "An Express template engine to render HTML views using native JavaScript",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
7
7
  "engines": {
8
- "node": ">=16"
8
+ "node": ">=22.19"
9
9
  },
10
10
  "files": [
11
11
  "src/index.js",
@@ -47,15 +47,15 @@
47
47
  "@types/mocha": "^10.0.6",
48
48
  "@types/reload": "^3.2.3",
49
49
  "@types/sinon": "^17.0.3",
50
- "chai": "^5.1.0",
50
+ "chai": "^6.0.1",
51
51
  "chokidar": "^4.0.1",
52
52
  "express": "^5.1.0",
53
53
  "husky": "^9.0.7",
54
54
  "mocha": "^11.0.1",
55
55
  "prettier": "^3.0.3",
56
- "release-it": "17.1.1",
56
+ "release-it": "19.0.4",
57
57
  "reload": "^3.2.0",
58
- "sinon": "^20.0.0",
58
+ "sinon": "^21.0.0",
59
59
  "typescript": "^5.4.3"
60
60
  }
61
61
  }
package/src/index.d.ts CHANGED
@@ -5,9 +5,9 @@
5
5
  * @param {import('express').Request} req
6
6
  * @param {import('express').Response} res
7
7
  * @param {Record<string, any>} [data]
8
- * @returns {Promise<void>} HTML with includes available (appended to state)
8
+ * @returns {Promise<string>} HTML with includes available (appended to state)
9
9
  */
10
- export function renderView(filePath: string, req: import("express").Request, res: import("express").Response, data?: Record<string, any>): Promise<void>;
10
+ export function renderView(filePath: string, req: import("express").Request, res: import("express").Response, data?: Record<string, any>): Promise<string>;
11
11
  /**
12
12
  * Template literal that supports string
13
13
  * interpolating in passed HTML.
@@ -31,7 +31,8 @@ export default function _default(opts?: HTMLExpressOptions): {
31
31
  staticIndexHandler: HTMLExpressStaticIndexHandler;
32
32
  engine: Parameters<import("express").Application["engine"]>[1];
33
33
  };
34
- export type HTMLExpressStaticIndexHandler = () => import("express").RequestHandler;
34
+ export type HTMLExpressStaticAsyncRequestHandler = (req: import("express").Request, res: import("express").Response, next: import("express").NextFunction) => Promise<void>;
35
+ export type HTMLExpressStaticIndexHandler = () => HTMLExpressStaticAsyncRequestHandler;
35
36
  export type HTMLExpressBuildStateHandler = (req: import("express").Request) => Promise<Record<string, any>>;
36
37
  export type HTMLExpressOptions = {
37
38
  /**
package/src/index.js CHANGED
@@ -79,12 +79,13 @@ async function renderFileTemplate(path, data, state) {
79
79
  * @param {import('express').Request} req
80
80
  * @param {import('express').Response} res
81
81
  * @param {Record<string, any>} [data]
82
- * @returns {Promise<void>} HTML with includes available (appended to state)
82
+ * @returns {Promise<string>} HTML with includes available (appended to state)
83
83
  */
84
84
  export async function renderView(filePath, req, res, data = {}) {
85
85
  const requestState = buildRequestState ? await buildRequestState(req) : {};
86
86
  const html = await buildViewHtml(filePath, data, requestState);
87
87
  res.send(html);
88
+ return html;
88
89
  }
89
90
 
90
91
  /**
@@ -126,9 +127,17 @@ export function html(strings, ...data) {
126
127
  return rawHtml;
127
128
  }
128
129
 
130
+ /**
131
+ * @callback HTMLExpressStaticAsyncRequestHandler
132
+ * @param {import('express').Request} req
133
+ * @param {import('express').Response} res
134
+ * @param {import('express').NextFunction} next
135
+ * @returns {Promise<void>}
136
+ */
137
+
129
138
  /**
130
139
  * @callback HTMLExpressStaticIndexHandler
131
- * @returns {import('express').RequestHandler}
140
+ * @returns {HTMLExpressStaticAsyncRequestHandler}
132
141
  */
133
142
 
134
143
  /**