express-sweet-generator 1.0.6 → 1.0.7

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,6 +1,27 @@
1
1
  # Changelog
2
2
  All notable changes to this project will be documented in this file.
3
3
 
4
+ ## [1.0.7] - 2022/10/24
5
+ ### Fixed
6
+ - Added is_ajax option to user authentication.
7
+ config/authentication.js:
8
+ ```js
9
+ /**
10
+ * How to determine if it is an ajax request.
11
+ * The default is that if there is an XMLHttpRequest in the request header (req.xhr) returns true.
12
+ * For example, if there is no XMLHttpRequest in req(express.Request) and the Ajax endpoint starts with /api, a custom Ajax decision can be made like "return /^\/api\//.test(req.path)".
13
+ *
14
+ * @type {(req: express.Request) => boolean}
15
+ * @example
16
+ * is_ajax: req => {
17
+ * // If the request URL begins with /api, it is assumed to be Ajax.
18
+ * return /^\/api/.test(req.path);
19
+ * // return !!req.xhr;
20
+ * }
21
+ */
22
+ is_ajax: req => !!req.xhr
23
+ ```
24
+
4
25
  ## [1.0.6] - 2022/10/20
5
26
  ### Fixed
6
27
  - A request body object has been added to the parameters of the callback function for user authentication.
@@ -101,4 +122,5 @@ All notable changes to this project will be documented in this file.
101
122
  [1.0.3]: https://github.com/takuya-motoshima/express-sweet-generator/compare/v1.0.2...v1.0.3
102
123
  [1.0.4]: https://github.com/takuya-motoshima/express-sweet-generator/compare/v1.0.3...v1.0.4
103
124
  [1.0.5]: https://github.com/takuya-motoshima/express-sweet-generator/compare/v1.0.4...v1.0.5
104
- [1.0.6]: https://github.com/takuya-motoshima/express-sweet-generator/compare/v1.0.5...v1.0.6
125
+ [1.0.6]: https://github.com/takuya-motoshima/express-sweet-generator/compare/v1.0.5...v1.0.6
126
+ [1.0.7]: https://github.com/takuya-motoshima/express-sweet-generator/compare/v1.0.6...v1.0.7
@@ -1,4 +1,4 @@
1
- #!/usr/bin/env node
1
+ #!/usr/bin/env node
2
2
  const ejs = require('ejs');
3
3
  const fs = require('fs-extra');
4
4
  const path = require('path');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "express-sweet-generator",
3
- "version": "1.0.6",
3
+ "version": "1.0.7",
4
4
  "description": "Express Sweet application generator.",
5
5
  "main": "bin/express-sweet-cli.js",
6
6
  "files": [
@@ -94,5 +94,20 @@ module.exports = {
94
94
  * Authenticated user session expiration, defaults to 24 hours (24 * 3600000).
95
95
  * @type {number}
96
96
  */
97
- expiration: 24 * 3600000
97
+ expiration: 24 * 3600000,
98
+
99
+ /**
100
+ * How to determine if it is an ajax request.
101
+ * The default is that if there is an XMLHttpRequest in the request header (req.xhr) returns true.
102
+ * For example, if there is no XMLHttpRequest in req(express.Request) and the Ajax endpoint starts with /api, a custom Ajax decision can be made like "return /^\/api\//.test(req.path)".
103
+ *
104
+ * @type {(req: express.Request) => boolean}
105
+ * @example
106
+ * is_ajax: req => {
107
+ * // If the request URL begins with /api, it is assumed to be Ajax.
108
+ * return /^\/api/.test(req.path);
109
+ * // return !!req.xhr;
110
+ * }
111
+ */
112
+ is_ajax: req => !!req.xhr
98
113
  }
@@ -94,5 +94,20 @@ export default {
94
94
  * Authenticated user session expiration, defaults to 24 hours (24 * 3600000).
95
95
  * @type {number}
96
96
  */
97
- expiration: 24 * 3600000
97
+ expiration: 24 * 3600000,
98
+
99
+ /**
100
+ * How to determine if it is an ajax request.
101
+ * The default is that if there is an XMLHttpRequest in the request header (req.xhr) returns true.
102
+ * For example, if there is no XMLHttpRequest in req(express.Request) and the Ajax endpoint starts with /api, a custom Ajax decision can be made like "return /^\/api\//.test(req.path)".
103
+ *
104
+ * @type {(req: express.Request) => boolean}
105
+ * @example
106
+ * is_ajax: req => {
107
+ * // If the request URL begins with /api, it is assumed to be Ajax.
108
+ * return /^\/api/.test(req.path);
109
+ * // return !!req.xhr;
110
+ * }
111
+ */
112
+ is_ajax: req => !!req.xhr
98
113
  }