html-express-js 1.1.0 → 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.
@@ -0,0 +1,6 @@
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: npm
4
+ directory: '/'
5
+ schedule:
6
+ interval: monthly
@@ -0,0 +1,17 @@
1
+ name: Dependabot auto-merge
2
+ on: pull_request
3
+
4
+ permissions:
5
+ pull-requests: write
6
+ contents: write
7
+
8
+ jobs:
9
+ dependabot:
10
+ runs-on: ubuntu-latest
11
+ if: ${{ github.actor == 'dependabot[bot]' }}
12
+ steps:
13
+ - name: Enable auto-merge for Dependabot PRs
14
+ run: gh pr merge --auto --squash "$PR_URL"
15
+ env:
16
+ PR_URL: ${{github.event.pull_request.html_url}}
17
+ GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env sh
2
+ . "$(dirname -- "$0")/_/husky.sh"
3
+
4
+ npm run format
package/.prettierignore CHANGED
@@ -1,2 +1,7 @@
1
1
  package*.json
2
- node_modules
2
+ node_modules
3
+ .husky
4
+ LICENSE
5
+ .gitignore
6
+ .npmrc
7
+ .prettierignore
package/.travis.yml ADDED
@@ -0,0 +1,8 @@
1
+ language: node_js
2
+ node_js:
3
+ - '16'
4
+ branches:
5
+ only:
6
+ - master
7
+ script:
8
+ - npm test
package/README.md CHANGED
@@ -1,3 +1,7 @@
1
+ ![build](https://img.shields.io/travis/markcellus/html-express-js)
2
+ ![npm](https://img.shields.io/npm/v/html-express-js)
3
+ ![node](https://img.shields.io/node/v/html-express-js)
4
+
1
5
  # html-express-js
2
6
 
3
7
  ## Features
package/jsconfig.json ADDED
@@ -0,0 +1,9 @@
1
+ {
2
+ "compilerOptions": {
3
+ "checkJs": true,
4
+ "maxNodeModuleJsDepth": 1,
5
+ "moduleResolution": "nodenext",
6
+ "module": "es2022",
7
+ "target": "es2022"
8
+ }
9
+ }
package/package.json CHANGED
@@ -1,13 +1,17 @@
1
1
  {
2
2
  "name": "html-express-js",
3
- "version": "1.1.0",
3
+ "version": "1.1.1",
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
+ "engines": {
8
+ "node": ">=16"
9
+ },
7
10
  "scripts": {
8
11
  "format": "prettier --write '**/*'",
9
12
  "test": "prettier --check '**/*'",
10
- "start": "node ./example/server.js"
13
+ "start": "node ./example/server.js",
14
+ "prepare": "husky install"
11
15
  },
12
16
  "repository": {
13
17
  "type": "git",
@@ -32,6 +36,7 @@
32
36
  "devDependencies": {
33
37
  "chokidar": "^3.5.3",
34
38
  "express": "^4.18.1",
39
+ "husky": "^8.0.1",
35
40
  "prettier": "^2.7.1",
36
41
  "release-it": "^15.0.0",
37
42
  "reload": "^3.2.0"
package/src/index.js CHANGED
@@ -12,7 +12,7 @@ const glob = promisify(g);
12
12
  * @param {string} path - The path to html file
13
13
  * @param {object} [data]
14
14
  * @param {object} [state] - Page-level attributes
15
- * @returns {string} HTML
15
+ * @returns {Promise<string>} HTML
16
16
  */
17
17
  async function renderHtmlFileTemplate(path, data, state) {
18
18
  const { view } = await import(path);
@@ -30,7 +30,7 @@ async function renderHtmlFileTemplate(path, data, state) {
30
30
  * @param {string} filePath - The path to html file
31
31
  * @param {object} data - Data to be made available in view
32
32
  * @param {object} instanceOptions - Options passed to original instantiation
33
- * @returns {string} HTML with includes available (appended to state)
33
+ * @returns {Promise<string>} HTML with includes available (appended to state)
34
34
  */
35
35
  async function renderHtmlFile(filePath, data = {}, instanceOptions = {}) {
36
36
  const state = {
@@ -74,9 +74,9 @@ export function html(strings, ...data) {
74
74
  * @param {object} options.viewsDir - The directory that houses any potential index files
75
75
  * @param {string} [options.notFoundView] - The path of a file relative to the views
76
76
  * directory that should be served as 404 when no matching index page exists. Defaults to `404/index`.
77
- * @returns {function} - Middleware function
77
+ * @returns {import('express').RequestHandler} - Middleware function
78
78
  */
79
- export function staticIndexHandler(options = {}) {
79
+ export function staticIndexHandler(options) {
80
80
  const notFoundView = options.notFoundView || `404/index`;
81
81
 
82
82
  return async function (req, res, next) {
@@ -105,7 +105,7 @@ export function staticIndexHandler(options = {}) {
105
105
  *
106
106
  * @param {object} [opts]
107
107
  * @param {object} [opts.includesDir]
108
- * @returns {Function}
108
+ * @returns {(path: string, options: object, callback: (e: any, rendered?: string) => void) => void}
109
109
  */
110
110
  export default function (opts = {}) {
111
111
  return async (filePath, data, callback) => {