express-sweet 2.0.2 → 2.0.4

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 (58) hide show
  1. package/CHANGELOG.md +76 -9
  2. package/LICENSE +1 -1
  3. package/README.md +2193 -20
  4. package/configuration_sample/cjs/authentication.js +103 -0
  5. package/configuration_sample/cjs/config.js +74 -0
  6. package/configuration_sample/cjs/database.js +35 -0
  7. package/configuration_sample/cjs/view.js +36 -0
  8. package/configuration_sample/esm/authentication.js +103 -0
  9. package/configuration_sample/esm/config.js +74 -0
  10. package/configuration_sample/esm/database.js +35 -0
  11. package/configuration_sample/esm/view.js +36 -0
  12. package/dist/build.cjs +22 -22
  13. package/dist/build.mjs +22 -22
  14. package/package.json +8 -11
  15. package/screencaps/belongs-to-many.png +0 -0
  16. package/screencaps/belongs-to.png +0 -0
  17. package/screencaps/demonstration.webp +0 -0
  18. package/screencaps/has-many.png +0 -0
  19. package/screencaps/has-one.png +0 -0
  20. package/types/database/Database.d.ts +3 -171
  21. package/types/database/Model.d.ts +22 -19
  22. package/types/database/loadModels.d.ts +2 -1
  23. package/types/handlebars_helpers/array.d.ts +20 -0
  24. package/types/handlebars_helpers/comparison.d.ts +59 -189
  25. package/types/handlebars_helpers/date.d.ts +4 -4
  26. package/types/handlebars_helpers/html.d.ts +3 -3
  27. package/types/handlebars_helpers/index.d.ts +2 -0
  28. package/types/handlebars_helpers/layouts.d.ts +21 -0
  29. package/types/handlebars_helpers/math.d.ts +14 -21
  30. package/types/handlebars_helpers/number.d.ts +5 -5
  31. package/types/handlebars_helpers/object.d.ts +4 -4
  32. package/types/handlebars_helpers/string.d.ts +8 -13
  33. package/types/interfaces/AuthenticationConfig.d.ts +4 -11
  34. package/types/interfaces/BasicConfig.d.ts +11 -15
  35. package/types/interfaces/ViewConfig.d.ts +1 -3
  36. package/types/middlewares/Authentication.d.ts +3 -1
  37. package/types/middlewares/CORS.d.ts +3 -1
  38. package/types/middlewares/Environment.d.ts +3 -3
  39. package/types/middlewares/ErrorHandler.d.ts +3 -1
  40. package/types/middlewares/Http.d.ts +3 -1
  41. package/types/middlewares/Local.d.ts +3 -1
  42. package/types/middlewares/View.d.ts +6 -2
  43. package/types/mount.d.ts +3 -2
  44. package/types/routing/Router.d.ts +3 -1
  45. package/types/services/Authentication.d.ts +4 -2
  46. package/types/utils/Types.d.ts +2 -2
  47. package/types/utils/isAsyncFunction.d.ts +7 -7
  48. package/types/utils/isFunction.d.ts +8 -8
  49. package/types/utils/loadAuthenticationConfig.d.ts +2 -2
  50. package/types/utils/loadBasicConfig.d.ts +2 -2
  51. package/types/utils/loadDatabaseConfig.d.ts +2 -2
  52. package/types/utils/loadViewConfig.d.ts +2 -2
  53. package/INSTALL-Redis.md +0 -77
  54. package/QUICK_START.md +0 -149
  55. package/screencaps/login.jpg +0 -0
  56. package/screencaps/personal.jpg +0 -0
  57. package/screencaps/user-editing.jpg +0 -0
  58. package/screencaps/users.jpg +0 -0
package/CHANGELOG.md CHANGED
@@ -1,6 +1,74 @@
1
1
  # Changelog
2
2
  All notable changes to this project will be documented in this file.
3
3
 
4
+ ## [2.0.4] - 2025/1/14
5
+ <!-- ## [2.0.4] - Unreleased -->
6
+ ### Changed
7
+ - Refactored variable names.
8
+ - Fix Docker demo.
9
+ - Changed the directory name for storing custom error classes in the demo from `exceptions` to `errors`.
10
+ - Added a section to the README.md API reference about considerations when using the `hasMany` association with the `findAll` method.
11
+
12
+ ### Added
13
+ - **`findObjectInArray` Handlebars helper:** This helper is added to the view, allowing you to find an object in an array based on a specified field name and value.
14
+ ```html
15
+ {{!--
16
+ items is an array of objects: [{id: 123, name: 'Item A'}, {id: 456, name: 'Item B'}]
17
+ This code will output: "Item A"
18
+ --}}
19
+ {{#each items}}
20
+ {{#if (eq id 123)}}
21
+ {{lookup (findObjectInArray ../items 'id' id) 'name'}}
22
+ {{/if}}
23
+ {{/each}}
24
+ ```
25
+
26
+ ## [2.0.3] - 2024/9/3
27
+ ### Changed
28
+ - Add `"type": "module"` to the `package.json` of the esm app generated by `express-sweet-generator`. It is fully esm compliant.
29
+ - `require` was changed to dynamic import.
30
+ - Template engine changed from `express-hbs` to `express-handlebars`.
31
+ However, the `block` and `contentFor` helpers are still available.
32
+ - `database/Database` has been changed from a `sequelize.Sequelize` instance to a `sequelize.Sequelize` class. If you use it in the future, you need to instantiate it.
33
+ - Return type of `mount()` changed from `void` to `Promise<void>`.
34
+ - Return type of `middlewares/CORS.mount()` changed from `void` to `Promise<void>`.
35
+ - Return type of `middlewares/Environment.mount()` changed from `void` to `Promise<void>`.
36
+ - Return type of `middlewares/ErrorHandler.mount()` changed from `void` to `Promise<void>`.
37
+ - Return type of `middlewares/Http.mount()` changed from `void` to `Promise<void>`.
38
+ - Return type of `middlewares/Local.mount()` changed from `void` to `Promise<void>`.
39
+ - Return type of `middlewares/Router.mount()` changed from `void` to `Promise<void>`.
40
+ - Return type of `middlewares/View.mount()` changed from `void` to `Promise<void>`.
41
+ - Return type of `middlewares/View.mountBeforeRender()` changed from `void` to `Promise<void>`.
42
+ - Return type of `middlewares/Authentication.mount()` changed from `void` to `Promise<void>`.
43
+ - Return type of `utils/loadAuthenticationConfig()` changed from `AuthenticationConfig` to `Promise<AuthenticationConfig>`.
44
+ - Return type of `utils/loadBasicConfig()` changed from `BasicConfig` to `Promise<BasicConfig>`.
45
+ - Return type of `utils/loadDatabaseConfig()` changed from `sequelize.Options` to `Promise<sequelize.Options>`.
46
+ - Return type of `utils/loadViewConfig()` changed from `ViewConfig` to `Promise<ViewConfig>`.
47
+ - Return type of `services/Authentication.successRedirect()` changed from `void` to `Promise<void>`.
48
+ - Return type of `services/Authentication.failureRedirect()` changed from `void` to `Promise<void>`.
49
+ - Return type of `database/Model.initialize()` changed from `typeof Model` to `Promise<typeof Model>`.
50
+ - Return type of `database/loadModels()` changed from `void` to `Promise<void>`.
51
+ - DB connection check method has been changed.
52
+ - After:
53
+ ```js
54
+ const expressExtension = require('express-sweet');
55
+
56
+ // Create Database instance.
57
+ const config = await expressExtension.utils.loadDatabaseConfig();
58
+ const database = new expressExtension.database.Database(config.database, config.username, config.password, config);
59
+
60
+ // Check database connection.
61
+ await database.isConnect();
62
+ ```
63
+ - Before:
64
+ ```js
65
+ const expressExtension = require('express-sweet');
66
+
67
+ // Check database connection.
68
+ await expressExtension.database.Database.isConnect();
69
+ ```
70
+ - Update passport from 0.4.1 to 0.7.0
71
+
4
72
  ## [2.0.2] - 2024/9/1
5
73
  ### Changed
6
74
  - Update express from 4.18.3 to 4.19.2.
@@ -14,19 +82,19 @@ All notable changes to this project will be documented in this file.
14
82
 
15
83
  ## [2.0.0] - 2024/3/24
16
84
  ### Changed
17
- - Express Sweet version 2 no longer depends on the AWS SDK.
85
+ - EXPRESS SWEET version 2 no longer depends on the AWS SDK.
18
86
  The `services.AWSRekognitionClient` and `services.AWSSesClient` have been migrated to the [AWS SDK Extension](https://www.npmjs.com/package/aws-sdk-extension) NPM package, so please install from there if needed.
19
87
 
20
88
  ## [1.1.1] - 2024/3/23
21
89
  ### Changed
22
90
  - When cookie security is enabled (`config/authentication.js#cookie_secure`) and the application is running on the HTTP protocol, the following warning message is output upon user authentication.
23
- ```sh
91
+ ```bash
24
92
  Warning: Cookie security must be disabled for user authentication to work over the HTTP protocol (config/authentication.js#cookie_secure)
25
93
  ```
26
94
 
27
95
  ## [1.1.0] - 2024/3/6
28
96
  ### Changed
29
- - Updated Express Sweet's dependency packages.
97
+ - Updated EXPRESS SWEET's dependency packages.
30
98
  - [express](https://www.npmjs.com/package/express) from v4.18.2 to v4.18.3
31
99
  - [multer](https://www.npmjs.com/package/multer) from v1.4.4 to v1.4.5-lts.1
32
100
  - [express-session](https://www.npmjs.com/package/express-session) from v1.17.3 to v1.18.0
@@ -275,11 +343,9 @@ All notable changes to this project will be documented in this file.
275
343
  await book.save({transaction});
276
344
  await transaction.commit();
277
345
 
278
- // Check the update result.
279
- // results in: New title of book: When Im Gone
346
+ // Load updated data.
280
347
  await book.reload();
281
- console.log(`New title of book: ${book.title}`);
282
- } catch (err) {
348
+ } catch (error) {
283
349
  if (transaction)
284
350
  await transaction.rollback();
285
351
  }
@@ -335,7 +401,6 @@ All notable changes to this project will be documented in this file.
335
401
  ## [1.0.3] - 2021/6/13
336
402
  ### Changed
337
403
  - Change the current URL path of a local variable.app.locals.currentPath is a USVString containing an initial '/' followed by the path of the URL not including the query string or fragment.
338
-
339
404
  ```js
340
405
  // For example, when the current URL is "https://example.com/docs/api?q=value", "/docs/api" is set for "app.locals.currentPath".
341
406
  console.log(app.locals.currentPath);
@@ -401,4 +466,6 @@ All notable changes to this project will be documented in this file.
401
466
  [1.1.1]: https://github.com/takuya-motoshima/express-sweet/compare/v1.1.0...v1.1.1
402
467
  [2.0.0]: https://github.com/takuya-motoshima/express-sweet/compare/v1.1.1...v2.0.0
403
468
  [2.0.1]: https://github.com/takuya-motoshima/express-sweet/compare/v2.0.0...v2.0.1
404
- [2.0.2]: https://github.com/takuya-motoshima/express-sweet/compare/v2.0.1...v2.0.2
469
+ [2.0.2]: https://github.com/takuya-motoshima/express-sweet/compare/v2.0.1...v2.0.2
470
+ [2.0.3]: https://github.com/takuya-motoshima/express-sweet/compare/v2.0.2...v2.0.3
471
+ [2.0.4]: https://github.com/takuya-motoshima/express-sweet/compare/v2.0.3...v2.0.4
package/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright 2024 Takuya Motoshima
1
+ Copyright 2025 Takuya Motoshima
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
4