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.
- package/.github/dependabot.yml +6 -0
- package/.github/workflows/dependabot-automerge.yml +17 -0
- package/.husky/pre-commit +4 -0
- package/.prettierignore +6 -1
- package/.travis.yml +8 -0
- package/README.md +4 -0
- package/jsconfig.json +9 -0
- package/package.json +7 -2
- package/src/index.js +5 -5
|
@@ -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}}
|
package/.prettierignore
CHANGED
package/.travis.yml
ADDED
package/README.md
CHANGED
package/jsconfig.json
ADDED
package/package.json
CHANGED
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "html-express-js",
|
|
3
|
-
"version": "1.1.
|
|
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 {
|
|
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 {
|
|
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) => {
|