express-sweet 1.0.35 → 1.0.36

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.
Files changed (32) hide show
  1. package/CHANGELOG.md +45 -1
  2. package/dist/build.common.js +12 -12
  3. package/dist/build.esm.js +12 -12
  4. package/docs/index.html +41 -36
  5. package/package.json +1 -1
  6. package/types/database/index.d.ts +3 -3
  7. package/types/exceptions/index.d.ts +5 -5
  8. package/types/handlebars_helpers/index.d.ts +6 -6
  9. package/types/index.d.ts +7 -7
  10. package/types/interfaces/{AuthenticationOptions.d.ts → AuthenticationConfig.d.ts} +0 -14
  11. package/types/interfaces/BasicConfig.d.ts +74 -0
  12. package/types/interfaces/FaceMatch.d.ts +1 -1
  13. package/types/interfaces/index.d.ts +9 -9
  14. package/types/middlewares/CORS.d.ts +0 -1
  15. package/types/middlewares/Environment.d.ts +0 -1
  16. package/types/middlewares/{ErrorHandling.d.ts → ErrorHandler.d.ts} +0 -1
  17. package/types/middlewares/Http.d.ts +0 -1
  18. package/types/middlewares/Local.d.ts +0 -1
  19. package/types/middlewares/View.d.ts +0 -1
  20. package/types/middlewares/index.d.ts +8 -8
  21. package/types/routing/Router.d.ts +0 -1
  22. package/types/routing/index.d.ts +1 -1
  23. package/types/services/Authentication.d.ts +0 -1
  24. package/types/services/index.d.ts +3 -3
  25. package/types/utils/index.d.ts +4 -0
  26. package/types/utils/loadAuthenticationConfig.d.ts +8 -0
  27. package/types/utils/loadBasicConfig.d.ts +8 -0
  28. package/types/utils/loadDatabaseConfig.d.ts +8 -0
  29. package/types/utils/loadViewConfig.d.ts +8 -0
  30. package/types/interfaces/Config.d.ts +0 -66
  31. /package/types/interfaces/{DatabaseOptions.d.ts → DatabaseConfig.d.ts} +0 -0
  32. /package/types/interfaces/{ViewOptions.d.ts → ViewConfig.d.ts} +0 -0
package/CHANGELOG.md CHANGED
@@ -1,6 +1,49 @@
1
1
  # Changelog
2
2
  All notable changes to this project will be documented in this file.
3
3
 
4
+ ## [1.0.36] - 2023/7/12
5
+ ### Changed
6
+ - Moved the Ajax determination option (is_ajax) in the authentication configuration (config/authentication) to the basic configuration (config/config).
7
+
8
+ config/config.js:
9
+ ```js
10
+ /**
11
+ * How to determine if it is an ajax request.
12
+ * The default is that if there is an XMLHttpRequest in the request header (req.xhr) returns true.
13
+ * 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)".
14
+ *
15
+ * @type {(req: express.Request) => boolean}
16
+ * @example
17
+ * is_ajax: req => {
18
+ * // If the request URL begins with /api, it is assumed to be Ajax.
19
+ * return /^\/api/.test(req.path);
20
+ * // return !!req.xhr;
21
+ * }
22
+ */
23
+ is_ajax: req => !!req.xhr,
24
+ ```
25
+ - The error handle option (error_handler) in the basic configuration (config/config.js) has been removed and an option to hook error handles (hook_handle_error) added instead.
26
+
27
+ config/config.js:
28
+ ```js
29
+ /**
30
+ * Hooks the default behavior on request errors.
31
+ * If unset, simply returns an error HTTP status. (<code>res.status(err.status||500).end();</code>)
32
+ *
33
+ * @type {(err: any, req: express.Request, res: express.Response, next: express.NextFunction) => void}
34
+ * @example
35
+ * hook_handle_error: (err, req, res, next) => {
36
+ * if (err.status === 404)
37
+ * // If the URL cannot be found, a 404 error screen (views/error-404.hbs) is displayed.
38
+ * res.render('error-404');
39
+ * else
40
+ * // For other errors, unknown error screen (views/error-unknown.hbs) is displayed.
41
+ * res.render('error-unknown');
42
+ * },
43
+ */
44
+ hook_handle_error: undefined,
45
+ ```
46
+
4
47
  ## [1.0.35] - 2023/7/11
5
48
  ### Changed
6
49
  - The URL to redirect to when login fails (failure_redirect) option in the authentication configuration (config/authentication.js) can now be defined with a function.
@@ -626,4 +669,5 @@ All notable changes to this project will be documented in this file.
626
669
  [1.0.32]: https://github.com/takuya-motoshima/express-sweet/compare/v1.0.31...v1.0.32
627
670
  [1.0.33]: https://github.com/takuya-motoshima/express-sweet/compare/v1.0.32...v1.0.33
628
671
  [1.0.34]: https://github.com/takuya-motoshima/express-sweet/compare/v1.0.33...v1.0.34
629
- [1.0.35]: https://github.com/takuya-motoshima/express-sweet/compare/v1.0.34...v1.0.35
672
+ [1.0.35]: https://github.com/takuya-motoshima/express-sweet/compare/v1.0.34...v1.0.35
673
+ [1.0.36]: https://github.com/takuya-motoshima/express-sweet/compare/v1.0.35...v1.0.36