express-sweet 3.0.1 → 4.0.0

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 (40) hide show
  1. package/CHANGELOG.md +719 -706
  2. package/README.md +206 -57
  3. package/configuration_sample/cjs/config.js +5 -4
  4. package/configuration_sample/cjs/upload.js +91 -0
  5. package/configuration_sample/esm/config.js +5 -4
  6. package/configuration_sample/esm/upload.js +91 -0
  7. package/dist/build.cjs +41 -35
  8. package/dist/build.mjs +41 -35
  9. package/package.json +6 -4
  10. package/types/database/Model.d.ts +2 -2
  11. package/types/handlebars_helpers/object.d.ts +2 -2
  12. package/types/index.d.ts +1 -43
  13. package/types/interfaces/{BasicConfig.d.ts → AppConfig.d.ts} +8 -7
  14. package/types/interfaces/DatabaseConfig.d.ts +1 -0
  15. package/types/interfaces/UploadConfig.d.ts +73 -0
  16. package/types/interfaces/index.d.ts +6 -2
  17. package/types/middlewares/corsPolicy.d.ts +28 -0
  18. package/types/middlewares/{Environment.d.ts → envLoader.d.ts} +13 -15
  19. package/types/middlewares/errorHandler.d.ts +32 -0
  20. package/types/middlewares/globalVars.d.ts +25 -0
  21. package/types/middlewares/index.d.ts +19 -11
  22. package/types/middlewares/localVars.d.ts +44 -0
  23. package/types/middlewares/passportAuth.d.ts +15 -0
  24. package/types/middlewares/requestParser.d.ts +27 -0
  25. package/types/{routing/Router.d.ts → middlewares/routeMapper.d.ts} +14 -16
  26. package/types/middlewares/viewEngine.d.ts +49 -0
  27. package/types/mount.d.ts +33 -1
  28. package/types/utils/Types.d.ts +17 -11
  29. package/types/utils/index.d.ts +7 -3
  30. package/types/utils/loadAppConfig.d.ts +17 -0
  31. package/types/utils/loadUploadConfig.d.ts +20 -0
  32. package/types/middlewares/Authentication.d.ts +0 -52
  33. package/types/middlewares/CORS.d.ts +0 -30
  34. package/types/middlewares/ErrorHandler.d.ts +0 -34
  35. package/types/middlewares/Global.d.ts +0 -27
  36. package/types/middlewares/Http.d.ts +0 -29
  37. package/types/middlewares/Local.d.ts +0 -42
  38. package/types/middlewares/View.d.ts +0 -49
  39. package/types/routing/index.d.ts +0 -37
  40. package/types/utils/loadBasicConfig.d.ts +0 -17
package/CHANGELOG.md CHANGED
@@ -1,706 +1,719 @@
1
- # Changelog
2
-
3
- All notable changes to this project will be documented in this file.
4
-
5
- ## [3.0.1] - 2025/9/2
6
-
7
- ### Changed
8
-
9
- - Add pool configuration examples and JSDoc documentation to sample database configuration.
10
- - [ESM Configuration](configuration_sample/esm/database.js)
11
- - [CJS Configuration](configuration_sample/cjs/database.js)
12
-
13
- ## [3.0.0] - 2025/8/26
14
-
15
- This release introduces significant improvements to database layer architecture and adds configurable logging support.
16
-
17
- ### Breaking Changes
18
-
19
- **Database Layer Refactoring**
20
- - `Database` class removed → Use `DatabaseManager` singleton pattern
21
- - All models now share a single database connection for improved performance
22
- - Enhanced database management with connection testing and graceful shutdown
23
-
24
- ### Added
25
-
26
- #### Database Management
27
- - **`DatabaseManager.getInstance()`** - Get singleton Sequelize database instance
28
- - **`DatabaseManager.isConnected()`** - Test database connectivity
29
- - **`DatabaseManager.getConfig()`** - Access original database configuration
30
- - **`DatabaseManager.getSequelizeOptions()`** - Access runtime Sequelize options
31
- - **`DatabaseManager.close()`** - Graceful database connection shutdown
32
-
33
- #### Logging Configuration
34
- - **`config/logging.js`** - Morgan logging configuration support
35
-
36
- Create `config/logging.js` to customize HTTP request logging:
37
- ```js
38
- // config/logging.js
39
- export default {
40
- format: 'combined', // Options: 'combined', 'common', 'dev', 'short', 'tiny'
41
- skip: (req, res) => {
42
- // Skip logging for health check endpoints
43
- return req.path === '/health';
44
- }
45
- };
46
- ```
47
-
48
- **Default behavior**: Uses 'combined' format with no skip conditions if config file is not provided.
49
-
50
- ### Changed
51
-
52
- - Updated `sequelize` dependency from v6.37.1 to v6.37.7
53
-
54
- ### Migration Guide
55
-
56
- **Database Usage Migration:**
57
- ```js
58
- // v2.x - Old way
59
- import * as expx from 'express-sweet';
60
-
61
- const config = await expx.utils.loadDatabaseConfig();
62
- const db = new expx.database.Database(config.database, config.username, config.password, config);
63
-
64
- // v3.x - New way
65
- import * as expx from 'express-sweet';
66
-
67
- const db = await expx.database.DatabaseManager.getInstance();
68
- ```
69
-
70
- ## [2.0.9] - 2025/8/12
71
-
72
- ### Added
73
-
74
- - Added `getConfig()` method to Database class to retrieve the current database configuration object containing all sequelize options.
75
-
76
- ### Changed
77
-
78
- - Updated `multer` dependency from v1.4.5-lts.1 to v2.0.2 for improved file upload handling and security enhancements.
79
-
80
- ## [2.0.8] - 2025/7/29
81
-
82
- ### Changed
83
-
84
- - Updated the usage example of the `isConnect` method in the `Database` class in the README reference.
85
-
86
- ## [2.0.7] - 2025/7/22
87
-
88
- ### Changed
89
-
90
- - Updated dependencies to address vulnerabilities
91
- - `express`: 4.19.2 => 4.21.2
92
- - `express-session`: 1.18.0 => 1.18.2
93
- - `body-parser`: 1.19.0 => 2.2.0
94
- - `cookie-parser`: 1.4.4 => 1.4.7
95
- - `morgan`: 1.10.0 => 1.10.1
96
- - `rollup`: 4.21.2 => 4.45.1
97
-
98
- ## [2.0.6] - 2025/2/9
99
-
100
- ### Fixed
101
-
102
- - Fixed a bug that caused redirection to fail when a path with query parameters was set for the logout redirect URL (`failure_redirect` in `config/authentication.js`).
103
-
104
- ## [2.0.5] - 2025/2/4
105
-
106
- ### Added
107
-
108
- - Added a Handlebars helper, available for use in views, to replace HTML tags in a string.
109
-
110
- Example:
111
-
112
- ```html
113
- {{!-- results in: lorem ipsum dolor sit amet --}}
114
- {{{stripTags '<a href="https://example.com">lorem ipsum <strong>dolor</strong> <em>sit</em> amet</a>'}}}
115
-
116
- {{!-- results in: lorem ipsum <strong>dolor</strong> sit amet --}}
117
- {{{stripTags '<a href="https://example.com">lorem ipsum <strong>dolor</strong> <em>sit</em> amet</a>' '<strong>' ''}}}
118
-
119
- {{!-- results in: 🍩lorem ipsum 🍩dolor🍩 🍩sit🍩 amet🍩 --}}
120
- {{{stripTags '<a href="https://example.com">lorem ipsum <strong>dolor</strong> <em>sit</em> amet</a>' [] '🍩'}}}
121
- ```
122
-
123
- ## [2.0.4] - 2025/1/14
124
-
125
- ### Changed
126
-
127
- - Refactored variable names.
128
- - Fix Docker demo.
129
- - Changed the directory name for storing custom error classes in the demo from `exceptions` to `errors`.
130
- - Added a section to the README.md API reference about considerations when using the `hasMany` association with the `findAll` method.
131
-
132
- ### Added
133
-
134
- - **`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.
135
-
136
- Example:
137
-
138
- ```html
139
- {{!--
140
- items is an array of objects: [{id: 123, name: 'Item A'}, {id: 456, name: 'Item B'}]
141
- This code will output: "Item A"
142
- --}}
143
- {{#each items}}
144
- {{#if (eq id 123)}}
145
- {{lookup (findObjectInArray ../items 'id' id) 'name'}}
146
- {{/if}}
147
- {{/each}}
148
- ```
149
-
150
- ## [2.0.3] - 2024/9/3
151
-
152
- ### Changed
153
-
154
- - Add `"type": "module"` to the `package.json` of the esm app generated by `express-sweet-generator`. It is fully esm compliant.
155
- - `require` was changed to dynamic import.
156
- - Template engine changed from `express-hbs` to `express-handlebars`.
157
- However, the `block` and `contentFor` helpers are still available.
158
- - `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.
159
- - Return type of `mount()` changed from `void` to `Promise<void>`.
160
- - Return type of `middlewares/CORS.mount()` changed from `void` to `Promise<void>`.
161
- - Return type of `middlewares/Environment.mount()` changed from `void` to `Promise<void>`.
162
- - Return type of `middlewares/ErrorHandler.mount()` changed from `void` to `Promise<void>`.
163
- - Return type of `middlewares/Http.mount()` changed from `void` to `Promise<void>`.
164
- - Return type of `middlewares/Local.mount()` changed from `void` to `Promise<void>`.
165
- - Return type of `middlewares/Router.mount()` changed from `void` to `Promise<void>`.
166
- - Return type of `middlewares/View.mount()` changed from `void` to `Promise<void>`.
167
- - Return type of `middlewares/View.mountBeforeRender()` changed from `void` to `Promise<void>`.
168
- - Return type of `middlewares/Authentication.mount()` changed from `void` to `Promise<void>`.
169
- - Return type of `utils/loadAuthenticationConfig()` changed from `AuthenticationConfig` to `Promise<AuthenticationConfig>`.
170
- - Return type of `utils/loadBasicConfig()` changed from `BasicConfig` to `Promise<BasicConfig>`.
171
- - Return type of `utils/loadDatabaseConfig()` changed from `sequelize.Options` to `Promise<sequelize.Options>`.
172
- - Return type of `utils/loadViewConfig()` changed from `ViewConfig` to `Promise<ViewConfig>`.
173
- - Return type of `services/Authentication.successRedirect()` changed from `void` to `Promise<void>`.
174
- - Return type of `services/Authentication.failureRedirect()` changed from `void` to `Promise<void>`.
175
- - Return type of `database/Model.initialize()` changed from `typeof Model` to `Promise<typeof Model>`.
176
- - Return type of `database/loadModels()` changed from `void` to `Promise<void>`.
177
- - DB connection check method has been changed.
178
- - After:
179
- ```js
180
- const expx = require('express-sweet');
181
-
182
- // Create Database instance.
183
- const config = await expx.utils.loadDatabaseConfig();
184
- const database = new expx.database.Database(config.database, config.username, config.password, config);
185
-
186
- // Check database connection.
187
- await database.isConnect();
188
- ```
189
- - Before:
190
- ```js
191
- const expx = require('express-sweet');
192
-
193
- // Check database connection.
194
- await expx.database.Database.isConnect();
195
- ```
196
- - Update passport from 0.4.1 to 0.7.0
197
-
198
- ## [2.0.2] - 2024/9/1
199
-
200
- ### Changed
201
-
202
- - Update express from 4.18.3 to 4.19.2.
203
- - Update rollup from 2.79.1 to 4.21.2.
204
- - Rename build files (build.common.js => build.cjs, build.esm.js => build.mjs).
205
- - The express package was excluded from the build file. Instead, users should install express on their own.
206
-
207
- ## [2.0.1] - 2024/4/5
208
-
209
- ### Changed
210
-
211
- - Removed [nodejs-shared](https://www.npmjs.com/package/nodejs-shared) package dependency.
212
-
213
- ## [2.0.0] - 2024/3/24
214
-
215
- ### Changed
216
-
217
- - EXPRESS SWEET version 2 no longer depends on the AWS SDK.
218
- 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.
219
-
220
- ## [1.1.1] - 2024/3/23
221
-
222
- ### Changed
223
-
224
- - 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.
225
- ```bash
226
- Warning: Cookie security must be disabled for user authentication to work over the HTTP protocol (config/authentication.js#cookie_secure)
227
- ```
228
-
229
- ## [1.1.0] - 2024/3/6
230
-
231
- ### Changed
232
-
233
- - Updated EXPRESS SWEET's dependency packages.
234
- - [express](https://www.npmjs.com/package/express) from v4.18.2 to v4.18.3
235
- - [multer](https://www.npmjs.com/package/multer) from v1.4.4 to v1.4.5-lts.1
236
- - [express-session](https://www.npmjs.com/package/express-session) from v1.17.3 to v1.18.0
237
- - [sequelize](https://www.npmjs.com/package/sequelize) from v6.32.0 to v6.37.1
238
- - [mariadb](https://www.npmjs.com/package/mariadb) from v2.4.0 to v3.2.3
239
- - [moment](https://www.npmjs.com/package/moment) from v2.29.4 to v2.30.1
240
-
241
- ## [1.0.44] - 2023/12/30
242
-
243
- ### Changed
244
-
245
- - The `Secure` and `HttpOnly` attributes of the session cookie can now be set from the authentication configuration file (`config/authentication.js`).
246
-
247
- ## [1.0.43] - 2023/12/30
248
-
249
- ### Changed
250
-
251
- - The cookie name for storing session IDs can now be set in the `cookie_name` field of the authentication configuration file (`config/authentication.js`).
252
-
253
- ## [1.0.42] - 2023/8/31
254
-
255
- ### Changed
256
-
257
- - Update TypeScript version from 4.8.4 to 5.2.2.
258
- - Update redis dependency package used for user authentication.
259
- - Updated redis package version from 4.3.1 to 4.6.8.
260
- [Here](https://github.com/redis/node-redis/blob/master/CHANGELOG.md) are the changes.
261
- - Updated connect-redis package version from 6.1.3 to 7.1.0.
262
- [Here](https://github.com/tj/connect-redis/releases) are the changes.
263
-
264
-
265
- ## [1.0.41] - 2023/8/4
266
-
267
- ### Changed
268
-
269
- - Added an option to the method that searches for faces in the collection to throw an exception if a face is not found or if multiple faces are found.
270
-
271
- ## [1.0.40] - 2023/8/4
272
-
273
- ### Changed
274
-
275
- - Fixed to return null instead of throwing an error when looking for faces in the collection using images without faces (<code>AWSRekognitionClient.searchFaces()</code>).
276
-
277
- ## [1.0.39] - 2023/7/24
278
-
279
- ### Changed
280
-
281
- - Changed exception class name.
282
- <table>
283
- <thead>
284
- <tr>
285
- <th>Before Class Name</th>
286
- <th>After class name</th>
287
- <th>Instance member</th>
288
- <th>Description</th>
289
- </tr>
290
- </thead>
291
- <tbody>
292
- <tr>
293
- <td>CollectionCreationError</td>
294
- <td>FaceCollectionCreateFailed</td>
295
- <td>
296
- <ul>
297
- <li>name: Error Name.</li>
298
- <li>collectionId: Collection ID.</li>
299
- <li>httpStatusCode: HTTP status code.</li>
300
- </ul>
301
- </td>
302
- <td>Thrown when face collection creation (<code>AWSRekognitionClient.createCollection()</code>) fails.</td>
303
- </tr>
304
- <tr>
305
- <td>CollectionDeletionError</td>
306
- <td>FaceCollectionDeleteFailed</td>
307
- <td>
308
- <ul>
309
- <li>name: Error Name.</li>
310
- <li>collectionId: Collection ID.</li>
311
- <li>httpStatusCode: HTTP status code.</li>
312
- </ul>
313
- </td>
314
- <td>Thrown when deleting a face collection (<code>AWSRekognitionClient.deleteCollection()</code>) fails.</td>
315
- </tr>
316
- <tr>
317
- <td>FaceIndexError</td>
318
- <td>FaceIndexFailed</td>
319
- <td>
320
- <ul>
321
- <li>name: Error Name.</li>
322
- <li>collectionId: Collection ID.</li>
323
- </ul>
324
- </td>
325
- <td>Thrown when face indexing (<code>AWSRekognitionClient.indexFace()</code>) fails.</td>
326
- </tr>
327
- <tr>
328
- <td>MissingFaceInImageError</td>
329
- <td>FaceMissingInPhoto</td>
330
- <td>
331
- <ul>
332
- <li>name: Error Name.</li>
333
- </ul>
334
- </td>
335
- <td>Thrown if the face to index (<code>AWSRekognitionClient.indexFace()</code>) is not in the photo.</td>
336
- </tr>
337
- <tr>
338
- <td>MultipleFacesInImageError</td>
339
- <td>FacesMultipleInPhoto</td>
340
- <td>
341
- <ul>
342
- <li>name: Error Name.</li>
343
- </ul>
344
- </td>
345
- <td>Thrown when there are multiple faces to index (<code>AWSRekognitionClient.indexFace()</code>) in a photo.</td>
346
- </tr>
347
- </tbody>
348
- </table>
349
-
350
- ## [1.0.38] - 2023/7/17
351
-
352
- ### Fixed
353
-
354
- - Fixed a bug that login user data (req.user) could not be referenced in the function called just before view rendering (config/view.js#beforeRender).
355
-
356
- ## [1.0.37] - 2023/7/17
357
-
358
- ### Changed
359
-
360
- - The beforeRender option in the view configuration (config/view.js) can now specify asynchronous functions.
361
-
362
- ### Added
363
-
364
- - New Math-related view helpers have been added.
365
-
366
- ## [1.0.36] - 2023/7/12
367
-
368
- ### Changed
369
-
370
- - Moved the Ajax determination option (is_ajax) in the authentication configuration (config/authentication.js) to the basic configuration (config/config.js).
371
- - 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.
372
-
373
- ## [1.0.35] - 2023/7/11
374
-
375
- ### Changed
376
-
377
- - 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.
378
- - The arguments of the failureRedirect method of the authentication service class (services/Authentication) have changed. The argument to the Authentication.failureRedirect method used to be just express.Response, but now it requires express.Request and express.Response.
379
-
380
- ## [1.0.34] - 2023/7/1
381
-
382
- ### Changed
383
-
384
- - Changed the response status code from 403 to 401 when asynchronous communication requiring authentication fails to authenticate.
385
-
386
- ## [1.0.33] - 2023/7/1
387
-
388
- ### Added
389
-
390
- - Added regular expression comparison view helper.
391
-
392
- ## [1.0.32] - 2023/7/1
393
-
394
- ### Fixed
395
-
396
- - Fixed a bug that cookies (req.cookies) cannot be referenced in the hook function before view rendering (config/view.js#beforeRender).
397
-
398
- ## [1.0.31] - 2023/6/29
399
-
400
- ### Changed
401
-
402
- - Changed helper function names in the view (Handlebars) from SnakeCase to CamelCase.
403
- |After|Before|Description|
404
- |--|--|--|
405
- |notEmpty|not_empty|Check that it is not empty.|
406
- |formatDate|format_date|Use moment to format the date.|
407
- |cacheBusting|cache_busting|Returns the Assets path containing the file update time parameter.|
408
- |jsonStringify|json_stringify|Stringify an object using JSON.stringify.|
409
- |jsonParse|json_parse|Parses the given string using JSON.parse.|
410
- |formatBytes|format_bytes|Convert bytes to just the right units(KB, MB, GB, TB, PB, EB, ZB, YB).|
411
-
412
- ### Added
413
-
414
- - Added view helper to convert numeric values to strings with language-sensitive representations.
415
-
416
- ## [1.0.30] - 2023/6/26
417
-
418
- ### Changed
419
-
420
- - Fixed AWS Rekognition credentials passing.
421
-
422
- ## [1.0.29] - 2023/6/20
423
-
424
- ### Changed
425
-
426
- - Changed class private variables and methods from soft private to hard private.
427
-
428
- ### Added
429
-
430
- - Added AWS SES email sending client class.
431
-
432
- ## [1.0.28] - 2023/6/16
433
-
434
- ### Changed
435
-
436
- - Updated AWS SDK version from 2 to 3.
437
-
438
- ## [1.0.27] - 2023/6/12
439
-
440
- ### Changed
441
-
442
- - Request object has been added to the arguments of the beforeRender function in the view configuration (config/view.js).
443
-
444
- ## [1.0.26] - 2023/6/11
445
-
446
- ### Changed
447
-
448
- - Update Sequelize from v5 to v6.
449
- - Changed the framework debug log to output only when the environment variable EXPRESS_DEBUG is defined.
450
- .env:
451
- ```
452
- EXPRESS_DEBUG=true
453
- ```
454
-
455
- ## [1.0.25] - 2022/11/24
456
-
457
- ### Added
458
-
459
- - Added formatBytes view helper to convert bytes to appropriate units.
460
-
461
- ## [1.0.24] - 2022/10/24
462
-
463
- ### Added
464
-
465
- - Added is_ajax option to user authentication (config/authentication.js).
466
-
467
- ## [1.0.23] - 2022/10/20
468
-
469
- ### Added
470
-
471
- - A request body object has been added to the parameters of the callback function for user authentication.
472
-
473
- ## [1.0.22] - 2022/7/27
474
-
475
- ### Added
476
-
477
- - You can now set hook functions that are called before the view is rendered. Hook functions can be used, for example, to set local variables that can be used in the view.
478
-
479
- ## [1.0.21] - 2022/526
480
-
481
- ### Added
482
-
483
- - Added an option to the face indexing method to retrieve details (gender, emotion, age group) of indexed faces.
484
-
485
- ## [1.0.20] - 2022/5/25
486
-
487
- ### Added
488
-
489
- - Added an option to get details (emotion, gender, age group) to the face detection method.
490
-
491
- ## [1.0.19] - 2022/5/20
492
-
493
- ### Added
494
-
495
- - Add date format helper to view.
496
-
497
- ## [1.0.18] - 2022/5/18
498
-
499
- ### Added
500
-
501
- - User authentication sessions can now be stored in redis. To use redis for session storage, simply add the following option to config/authentication.js. Please give it a try.
502
- config/authentication.js:
503
- ```json
504
- session_store: 'redis',
505
- redis_host: 'redis://localhost:6379'
506
- ```
507
-
508
- ## [1.0.17] - 2022/5/17
509
-
510
- ### Changed
511
-
512
- - Updated documentation and refactored variable names.
513
-
514
- ## [1.0.16] - 2022/2/14
515
-
516
- ### Fixed
517
-
518
- - I forgot to include the build file, so I added the build file.
519
-
520
- ## [1.0.15] - 2022/2/14
521
-
522
- ### Changed
523
-
524
- - Changed the type of 'config/authentication.js#allow_unauthenticated' from'string[]' to'(string|RegExp)[]}'.
525
-
526
- ## [1.0.14] - 2022/1/17
527
-
528
- ### Changed
529
-
530
- - empty view helper can now check any type. Previously I could only check arrays.
531
-
532
- ## [1.0.13] - 2021/12/13
533
-
534
- ### Added
535
-
536
- - The model's begin method now accepts the transaction option.
537
- ```js
538
- let transaction;
539
- try {
540
- transaction = await BookModel.begin({
541
- isolationLevel: BookModel.Transaction.ISOLATION_LEVELS.REPEATABLE_READ,
542
- type: BookModel.Transaction.TYPES.DEFERRED,
543
- });
544
- const book = await BookModel.findOne({where: {id: 1}}, {transaction});
545
- book.title = 'When Im Gone';
546
- await book.save({transaction});
547
- await transaction.commit();
548
-
549
- // Load updated data.
550
- await book.reload();
551
- } catch (error) {
552
- if (transaction)
553
- await transaction.rollback();
554
- }
555
- ```
556
-
557
- ## [1.0.12] - 2021/11/16
558
-
559
- ### Added
560
-
561
- - Added a method to the model that can execute raw SQL. As there are often use cases in which it is just easier to execute raw / already prepared SQL queries, you can use the Model.query method.
562
- ```js
563
- // By default the function will return two arguments - a results array, and an object containing metadata (such as amount of affected rows, etc).
564
- // Note that since this is a raw query, the metadata are dialect specific.
565
- const [results, metadata] = await BookModel.query("UPDATE book SET title = 'When Im Gone' WHERE id = 1");
566
-
567
- // In cases where you don't need to access the metadata you can pass in a query type to tell sequelize how to format the results. For example, for a simple select query you could do:
568
- // We didn't need to destructure the result here - the results were returned directly
569
- const users = await BookModel.query("SELECT * FROM book", {type: BookModel.QueryTypes.SELECT});
570
- ```
571
-
572
- ## [1.0.11] - 2021/11/10
573
-
574
- ### Fixed
575
-
576
- - Fixed a bug that the database config was read before NODE_ENV was set and the database config matching NODE_ENV could not be read.
577
-
578
- ## [1.0.10] - 2021/10/19
579
-
580
- ### Changed
581
-
582
- - Added face similarity found to face search results in collection.
583
-
584
- ## [1.0.9] - 2021/10/13
585
-
586
- ### Changed
587
-
588
- - Updated dependent package'sharp'from 0.25.4 to 0.29.1.
589
- This update statically links sharp's pre-built libvips binaries, eliminating the need to install Phton.
590
- Click [here](https://sharp.pixelplumbing.com/changelog) for sharp change log.
591
-
592
- ## [1.0.8] - 2021/9/25
593
-
594
- ### Fixed
595
-
596
- - Fixed a bug where the default router couldn't aqua from the endpoint URL.
597
-
598
- ## [1.0.7] - 2021/8/13
599
-
600
- ### Added
601
-
602
- - Added where member functions to Model class.
603
-
604
- ## [1.0.6] - 2021/8/13
605
-
606
- ### Added
607
-
608
- - Added fn, col and literal member functions to Model class.
609
-
610
- ## [1.0.5] - 2021/8/12
611
-
612
- ### Changed
613
-
614
- - Changed the maximum size per field for multipart (multipart/form-data) requests from 1MB to unlimited.
615
-
616
- ## [1.0.4] - 2021/6/13
617
-
618
- ### Fixed
619
-
620
- - Fixed a bug where the referrer URL was set in app.locals.currentPath instead of the current URL.
621
-
622
- ## [1.0.3] - 2021/6/13
623
-
624
- ### Changed
625
-
626
- - 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.
627
- ```js
628
- // For example, when the current URL is "https://example.com/docs/api?q=value", "/docs/api" is set for "app.locals.currentPath".
629
- console.log(app.locals.currentPath);
630
- ```
631
-
632
- ## [1.0.2] - 2021//6/10
633
-
634
- ### Changed
635
-
636
- - Updated rollup from version 2.44 to 2.51.
637
-
638
- ### Fixed
639
-
640
- - Fixed a bug where preloading models failed in cjs.
641
-
642
- ## [1.0.1] - 2021/6/2
643
-
644
- ### Fixed
645
-
646
- - Fixed a bug that caused an error when reading options defined in ESM's default Export.
647
-
648
- [1.0.1]: https://github.com/takuya-motoshima/express-sweet/compare/v1.0.0...v1.0.1
649
- [1.0.2]: https://github.com/takuya-motoshima/express-sweet/compare/v1.0.1...v1.0.2
650
- [1.0.3]: https://github.com/takuya-motoshima/express-sweet/compare/v1.0.2...v1.0.3
651
- [1.0.4]: https://github.com/takuya-motoshima/express-sweet/compare/v1.0.3...v1.0.4
652
- [1.0.5]: https://github.com/takuya-motoshima/express-sweet/compare/v1.0.4...v1.0.5
653
- [1.0.6]: https://github.com/takuya-motoshima/express-sweet/compare/v1.0.5...v1.0.6
654
- [1.0.7]: https://github.com/takuya-motoshima/express-sweet/compare/v1.0.6...v1.0.7
655
- [1.0.8]: https://github.com/takuya-motoshima/express-sweet/compare/v1.0.7...v1.0.8
656
- [1.0.9]: https://github.com/takuya-motoshima/express-sweet/compare/v1.0.8...v1.0.9
657
- [1.0.10]: https://github.com/takuya-motoshima/express-sweet/compare/v1.0.9...v1.0.10
658
- [1.0.11]: https://github.com/takuya-motoshima/express-sweet/compare/v1.0.10...v1.0.11
659
- [1.0.12]: https://github.com/takuya-motoshima/express-sweet/compare/v1.0.11...v1.0.12
660
- [1.0.13]: https://github.com/takuya-motoshima/express-sweet/compare/v1.0.12...v1.0.13
661
- [1.0.14]: https://github.com/takuya-motoshima/express-sweet/compare/v1.0.13...v1.0.14
662
- [1.0.15]: https://github.com/takuya-motoshima/express-sweet/compare/v1.0.14...v1.0.15
663
- [1.0.16]: https://github.com/takuya-motoshima/express-sweet/compare/v1.0.15...v1.0.16
664
- [1.0.17]: https://github.com/takuya-motoshima/express-sweet/compare/v1.0.16...v1.0.17
665
- [1.0.18]: https://github.com/takuya-motoshima/express-sweet/compare/v1.0.17...v1.0.18
666
- [1.0.19]: https://github.com/takuya-motoshima/express-sweet/compare/v1.0.18...v1.0.19
667
- [1.0.20]: https://github.com/takuya-motoshima/express-sweet/compare/v1.0.19...v1.0.20
668
- [1.0.21]: https://github.com/takuya-motoshima/express-sweet/compare/v1.0.20...v1.0.21
669
- [1.0.22]: https://github.com/takuya-motoshima/express-sweet/compare/v1.0.21...v1.0.22
670
- [1.0.23]: https://github.com/takuya-motoshima/express-sweet/compare/v1.0.22...v1.0.23
671
- [1.0.24]: https://github.com/takuya-motoshima/express-sweet/compare/v1.0.23...v1.0.24
672
- [1.0.25]: https://github.com/takuya-motoshima/express-sweet/compare/v1.0.24...v1.0.25
673
- [1.0.26]: https://github.com/takuya-motoshima/express-sweet/compare/v1.0.25...v1.0.26
674
- [1.0.27]: https://github.com/takuya-motoshima/express-sweet/compare/v1.0.26...v1.0.27
675
- [1.0.28]: https://github.com/takuya-motoshima/express-sweet/compare/v1.0.27...v1.0.28
676
- [1.0.29]: https://github.com/takuya-motoshima/express-sweet/compare/v1.0.28...v1.0.29
677
- [1.0.30]: https://github.com/takuya-motoshima/express-sweet/compare/v1.0.29...v1.0.30
678
- [1.0.31]: https://github.com/takuya-motoshima/express-sweet/compare/v1.0.30...v1.0.31
679
- [1.0.32]: https://github.com/takuya-motoshima/express-sweet/compare/v1.0.31...v1.0.32
680
- [1.0.33]: https://github.com/takuya-motoshima/express-sweet/compare/v1.0.32...v1.0.33
681
- [1.0.34]: https://github.com/takuya-motoshima/express-sweet/compare/v1.0.33...v1.0.34
682
- [1.0.35]: https://github.com/takuya-motoshima/express-sweet/compare/v1.0.34...v1.0.35
683
- [1.0.36]: https://github.com/takuya-motoshima/express-sweet/compare/v1.0.35...v1.0.36
684
- [1.0.37]: https://github.com/takuya-motoshima/express-sweet/compare/v1.0.36...v1.0.37
685
- [1.0.38]: https://github.com/takuya-motoshima/express-sweet/compare/v1.0.37...v1.0.38
686
- [1.0.39]: https://github.com/takuya-motoshima/express-sweet/compare/v1.0.38...v1.0.39
687
- [1.0.40]: https://github.com/takuya-motoshima/express-sweet/compare/v1.0.39...v1.0.40
688
- [1.0.41]: https://github.com/takuya-motoshima/express-sweet/compare/v1.0.40...v1.0.41
689
- [1.0.42]: https://github.com/takuya-motoshima/express-sweet/compare/v1.0.41...v1.0.42
690
- [1.0.43]: https://github.com/takuya-motoshima/express-sweet/compare/v1.0.42...v1.0.43
691
- [1.0.44]: https://github.com/takuya-motoshima/express-sweet/compare/v1.0.43...v1.0.44
692
- [1.0.45]: https://github.com/takuya-motoshima/express-sweet/compare/v1.0.44...v1.0.45
693
- [1.1.0]: https://github.com/takuya-motoshima/express-sweet/compare/v1.0.45...v1.1.0
694
- [1.1.1]: https://github.com/takuya-motoshima/express-sweet/compare/v1.1.0...v1.1.1
695
- [2.0.0]: https://github.com/takuya-motoshima/express-sweet/compare/v1.1.1...v2.0.0
696
- [2.0.1]: https://github.com/takuya-motoshima/express-sweet/compare/v2.0.0...v2.0.1
697
- [2.0.2]: https://github.com/takuya-motoshima/express-sweet/compare/v2.0.1...v2.0.2
698
- [2.0.3]: https://github.com/takuya-motoshima/express-sweet/compare/v2.0.2...v2.0.3
699
- [2.0.4]: https://github.com/takuya-motoshima/express-sweet/compare/v2.0.3...v2.0.4
700
- [2.0.5]: https://github.com/takuya-motoshima/express-sweet/compare/v2.0.4...v2.0.5
701
- [2.0.6]: https://github.com/takuya-motoshima/express-sweet/compare/v2.0.5...v2.0.6
702
- [2.0.7]: https://github.com/takuya-motoshima/express-sweet/compare/v2.0.6...v2.0.7
703
- [2.0.8]: https://github.com/takuya-motoshima/express-sweet/compare/v2.0.7...v2.0.8
704
- [2.0.9]: https://github.com/takuya-motoshima/express-sweet/compare/v2.0.8...v2.0.9
705
- [3.0.0]: https://github.com/takuya-motoshima/express-sweet/compare/v2.0.9...v3.0.0
706
- [3.0.1]: https://github.com/takuya-motoshima/express-sweet/compare/v3.0.0...v3.0.1
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ ## [Unreleased]
6
+
7
+ ### Breaking Changes
8
+
9
+ **Middleware Architecture Refactoring**
10
+ - All middleware components have been refactored from class-based to function-based architecture
11
+ - Middleware naming updated to follow Express.js conventions (2-word composition pattern)
12
+
13
+ **Middleware Name Changes:**
14
+ | Previous (Class-based) | Current (Function-based) |
15
+ |------------------------|--------------------------|
16
+ | `CORS` | `corsPolicy` |
17
+ | `Environment` | `envLoader` |
18
+ | `ErrorHandler` | `errorHandler` |
19
+ | `Http` | `requestParser` |
20
+ | `Local` | `localVars` |
21
+ | `Router` | `routeMapper` |
22
+ | `View` | `viewEngine` |
23
+ | `Authentication` | `passportAuth` |
24
+ | `Global` | `globalVars` |
25
+
26
+ **Migration Notes:**
27
+ - These are internal changes and do not affect the public API
28
+ - The `mount()` function handles all middleware automatically
29
+ - No changes required in application code for standard usage
30
+
31
+ **Express 5 Migration**
32
+ - **Requires Node.js 18.x or higher**
33
+ - Upgraded from Express 4.21.2 to Express 5.2.1
34
+ - Note: `express-handlebars` remains at v7.1.3 to maintain Node.js 18+ compatibility (v8 requires Node.js 20+)
35
+ - Route patterns with regex parameters no longer support `/:param(\\d+)` syntax
36
+ - Use RegExp with named capture groups instead: `/^\/(?<userId>\d+)$/`
37
+ - See migration example in Changed section below
38
+ - For more details on Express 5 changes, see:
39
+ - [Express 5 Migration Guide](https://expressjs.com/en/guide/migrating-5.html)
40
+ - [Express.js Release Notes](https://expressjs.com/en/changelog/)
41
+
42
+ ### Added
43
+
44
+ **File Upload Support (Multer)**
45
+ - Added dynamic file upload middleware using Multer
46
+ - New `config/upload.js` configuration file for flexible upload handling
47
+ - Support for single file, multiple files (array), and multiple field uploads
48
+ - Both memory storage and disk storage options
49
+ - Request-based middleware resolution for route-specific upload configurations
50
+ - Sample configurations added:
51
+ - [ESM Configuration](configuration_sample/esm/upload.js)
52
+ - [CJS Configuration](configuration_sample/cjs/upload.js)
53
+
54
+ ### Changed
55
+
56
+ **Express 5 Compatibility Updates**
57
+ - Added `query parser: 'extended'` setting in HTTP middleware to maintain Express 4 behavior for nested query objects
58
+ - Added `multer().none()` middleware to parse `multipart/form-data` requests without files
59
+
60
+ **Route Pattern Migration Example**
61
+ ```js
62
+ // Before (Express 4)
63
+ router.get('/:userId(\\d+)', (req, res) => {
64
+ const userId = req.params.userId; // Works
65
+ });
66
+
67
+ // After (Express 5)
68
+ router.get(/^\/(?<userId>\d+)$/, (req, res) => {
69
+ const userId = req.params.userId; // Works with named capture group
70
+ });
71
+ ```
72
+
73
+ ### Fixed
74
+
75
+ - Fixed `ERR_INVALID_URL` error when invalid Host header values are provided
76
+ - `baseUrl` is now set to `undefined` when URL construction fails, allowing graceful error handling via `rewrite_base_url` hook or template checks
77
+
78
+ ## [3.0.2] - 2025-11-28
79
+
80
+ ### Changed
81
+
82
+ **CORS Middleware Enhancements**
83
+ - Added `Authorization` header support for Bearer token and API key authentication
84
+ - Added cache control headers (`Cache-Control`, `If-None-Match`, `If-Modified-Since`) for conditional requests
85
+ - Added `Range` header support for partial content and resumable downloads
86
+ - Added `X-CSRF-Token` header support for CSRF protection
87
+ - Added explicit handling for OPTIONS preflight requests
88
+
89
+ **Demo Improvements**
90
+ - Added new REST API demo showcasing CORS functionality with simple CRUD endpoints
91
+
92
+ ## [3.0.1] - 2025-09-02
93
+
94
+ ### Changed
95
+
96
+ - Added pool configuration examples and JSDoc documentation to sample database configuration.
97
+ - [ESM Configuration](configuration_sample/esm/database.js)
98
+ - [CJS Configuration](configuration_sample/cjs/database.js)
99
+
100
+ ## [3.0.0] - 2025-08-26
101
+
102
+ This release introduces significant improvements to database layer architecture and adds configurable logging support.
103
+
104
+ ### Breaking Changes
105
+
106
+ **Database Layer Refactoring**
107
+ - `Database` class removed → Use `DatabaseManager` singleton pattern
108
+ - All models now share a single database connection for improved performance
109
+ - Enhanced database management with connection testing and graceful shutdown
110
+
111
+ ### Added
112
+
113
+ #### Database Management
114
+ - **`DatabaseManager.getInstance()`** - Get singleton Sequelize database instance
115
+ - **`DatabaseManager.isConnected()`** - Test database connectivity
116
+ - **`DatabaseManager.getConfig()`** - Access original database configuration
117
+ - **`DatabaseManager.getSequelizeOptions()`** - Access runtime Sequelize options
118
+ - **`DatabaseManager.close()`** - Graceful database connection shutdown
119
+
120
+ #### Logging Configuration
121
+ - **`config/logging.js`** - Morgan logging configuration support
122
+
123
+ Create `config/logging.js` to customize HTTP request logging:
124
+ ```js
125
+ // config/logging.js
126
+ export default {
127
+ format: 'combined', // Options: 'combined', 'common', 'dev', 'short', 'tiny'
128
+ skip: (req, res) => {
129
+ // Skip logging for health check endpoints
130
+ return req.path === '/health';
131
+ }
132
+ };
133
+ ```
134
+
135
+ **Default behavior**: Uses 'combined' format with no skip conditions if config file is not provided.
136
+
137
+ ### Changed
138
+
139
+ - Updated `sequelize` dependency from v6.37.1 to v6.37.7
140
+
141
+ ### Migration Guide
142
+
143
+ **Database Usage Migration:**
144
+ ```js
145
+ // v2.x - Old way
146
+ import * as expx from 'express-sweet';
147
+
148
+ const config = await expx.utils.loadDatabaseConfig();
149
+ const db = new expx.database.Database(config.database, config.username, config.password, config);
150
+
151
+ // v3.x - New way
152
+ import * as expx from 'express-sweet';
153
+
154
+ const db = await expx.database.DatabaseManager.getInstance();
155
+ ```
156
+
157
+ ## [2.0.9] - 2025-08-12
158
+
159
+ ### Added
160
+
161
+ - Added `getConfig()` method to Database class to retrieve the current database configuration object containing all sequelize options.
162
+
163
+ ### Changed
164
+
165
+ - Updated `multer` dependency from v1.4.5-lts.1 to v2.0.2 for improved file upload handling and security enhancements.
166
+
167
+ ## [2.0.8] - 2025-07-29
168
+
169
+ ### Changed
170
+
171
+ - Updated the usage example of the `isConnect` method in the `Database` class in the README reference.
172
+
173
+ ## [2.0.7] - 2025-07-22
174
+
175
+ ### Changed
176
+
177
+ - Updated dependencies to address vulnerabilities
178
+ - `express`: 4.19.2 => 4.21.2
179
+ - `express-session`: 1.18.0 => 1.18.2
180
+ - `body-parser`: 1.19.0 => 2.2.0
181
+ - `cookie-parser`: 1.4.4 => 1.4.7
182
+ - `morgan`: 1.10.0 => 1.10.1
183
+ - `rollup`: 4.21.2 => 4.45.1
184
+
185
+ ## [2.0.6] - 2025-02-09
186
+
187
+ ### Fixed
188
+
189
+ - Fixed a bug that caused logout redirection to fail when the redirect URL contained query parameters.
190
+
191
+ ## [2.0.5] - 2025-02-04
192
+
193
+ ### Added
194
+
195
+ - Added a Handlebars helper, available for use in views, to replace HTML tags in a string.
196
+
197
+ Example:
198
+
199
+ ```html
200
+ {{!-- results in: lorem ipsum dolor sit amet --}}
201
+ {{{stripTags '<a href="https://example.com">lorem ipsum <strong>dolor</strong> <em>sit</em> amet</a>'}}}
202
+
203
+ {{!-- results in: lorem ipsum <strong>dolor</strong> sit amet --}}
204
+ {{{stripTags '<a href="https://example.com">lorem ipsum <strong>dolor</strong> <em>sit</em> amet</a>' '<strong>' ''}}}
205
+
206
+ {{!-- results in: 🍩lorem ipsum 🍩dolor🍩 🍩sit🍩 amet🍩 --}}
207
+ {{{stripTags '<a href="https://example.com">lorem ipsum <strong>dolor</strong> <em>sit</em> amet</a>' [] '🍩'}}}
208
+ ```
209
+
210
+ ## [2.0.4] - 2025-01-14
211
+
212
+ ### Changed
213
+
214
+ - Refactored variable names.
215
+ - Fixed Docker demo.
216
+ - Changed the directory name for storing custom error classes in the demo from `exceptions` to `errors`.
217
+ - Added a section to the README.md API reference about considerations when using the `hasMany` association with the `findAll` method.
218
+
219
+ ### Added
220
+
221
+ - **`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.
222
+
223
+ Example:
224
+
225
+ ```html
226
+ {{!--
227
+ items is an array of objects: [{id: 123, name: 'Item A'}, {id: 456, name: 'Item B'}]
228
+ This code will output: "Item A"
229
+ --}}
230
+ {{#each items}}
231
+ {{#if (eq id 123)}}
232
+ {{lookup (findObjectInArray ../items 'id' id) 'name'}}
233
+ {{/if}}
234
+ {{/each}}
235
+ ```
236
+
237
+ ## [2.0.3] - 2024-09-03
238
+
239
+ > **Note:** This version used class-based middleware with names like `CORS`, `Environment`, `ErrorHandler`, `Http`, `Local`, `Router`, `View`, and `Authentication`. In v3.x and later, these were refactored to function-based middleware with new names (`corsPolicy`, `envLoader`, `errorHandler`, `requestParser`, `localVars`, `routeMapper`, `viewEngine`, `passportAuth`). The items listed below reflect the naming and structure used in v2.0.3.
240
+
241
+ ### Breaking Changes
242
+
243
+ **Template Engine Migration**
244
+ - Template engine changed from `express-hbs` to `express-handlebars`.
245
+ However, the `block` and `contentFor` helpers are still available for backward compatibility.
246
+
247
+ **Database Layer Changes**
248
+ - `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.
249
+ - DB connection check method has been changed.
250
+ - After:
251
+ ```js
252
+ const expx = require('express-sweet');
253
+
254
+ // Create Database instance.
255
+ const config = await expx.utils.loadDatabaseConfig();
256
+ const database = new expx.database.Database(config.database, config.username, config.password, config);
257
+
258
+ // Check database connection.
259
+ await database.isConnect();
260
+ ```
261
+ - Before:
262
+ ```js
263
+ const expx = require('express-sweet');
264
+
265
+ // Check database connection.
266
+ await expx.database.Database.isConnect();
267
+ ```
268
+
269
+ **Async Function Signature Changes**
270
+ - All middleware mount methods, configuration loaders, authentication services, and database initialization functions now return `Promise` types instead of synchronous return types. This change enables asynchronous configuration loading and proper async/await usage throughout the framework.
271
+
272
+ ### Changed
273
+
274
+ - Added `"type": "module"` to the `package.json` of the ESM app generated by `express-sweet-generator`. It is now fully ESM compliant.
275
+ - `require` was changed to dynamic import.
276
+ - Updated passport from 0.4.1 to 0.7.0
277
+
278
+ ## [2.0.2] - 2024-09-01
279
+
280
+ ### Changed
281
+
282
+ - Updated express from 4.18.3 to 4.19.2.
283
+ - Updated rollup from 2.79.1 to 4.21.2.
284
+ - Renamed build files (build.common.js => build.cjs, build.esm.js => build.mjs).
285
+ - The express package was excluded from the build file. Instead, users should install express on their own.
286
+
287
+ ## [2.0.1] - 2024-04-05
288
+
289
+ ### Changed
290
+
291
+ - Removed [nodejs-shared](https://www.npmjs.com/package/nodejs-shared) package dependency.
292
+
293
+ ## [2.0.0] - 2024-03-24
294
+
295
+ ### Breaking Changes
296
+
297
+ **AWS SDK Removal**
298
+ - EXPRESS SWEET version 2 no longer depends on the AWS SDK.
299
+ 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.
300
+
301
+ ## [1.1.1] - 2024-03-23
302
+
303
+ ### Changed
304
+
305
+ - When cookie security is enabled and the application runs over HTTP, a warning message is now displayed during user authentication to prevent authentication issues caused by secure cookie settings incompatible with the HTTP protocol.
306
+
307
+ ## [1.1.0] - 2024-03-06
308
+
309
+ ### Changed
310
+
311
+ - Updated EXPRESS SWEET's dependency packages.
312
+ - [express](https://www.npmjs.com/package/express) from v4.18.2 to v4.18.3
313
+ - [multer](https://www.npmjs.com/package/multer) from v1.4.4 to v1.4.5-lts.1
314
+ - [express-session](https://www.npmjs.com/package/express-session) from v1.17.3 to v1.18.0
315
+ - [sequelize](https://www.npmjs.com/package/sequelize) from v6.32.0 to v6.37.1
316
+ - [mariadb](https://www.npmjs.com/package/mariadb) from v2.4.0 to v3.2.3
317
+ - [moment](https://www.npmjs.com/package/moment) from v2.29.4 to v2.30.1
318
+
319
+ ## [1.0.44] - 2023-12-30
320
+
321
+ ### Changed
322
+
323
+ - The `Secure` and `HttpOnly` attributes of session cookies can now be configured through the authentication configuration file.
324
+
325
+ ## [1.0.43] - 2023-12-30
326
+
327
+ ### Changed
328
+
329
+ - Session cookie name is now configurable through the authentication configuration file.
330
+
331
+ ## [1.0.42] - 2023-08-31
332
+
333
+ ### Changed
334
+
335
+ - Updated TypeScript version from 4.8.4 to 5.2.2.
336
+ - Updated redis dependency packages used for user authentication.
337
+ - Updated redis package version from 4.3.1 to 4.6.8.
338
+ [Here](https://github.com/redis/node-redis/blob/master/CHANGELOG.md) are the changes.
339
+ - Updated connect-redis package version from 6.1.3 to 7.1.0.
340
+ [Here](https://github.com/tj/connect-redis/releases) are the changes.
341
+
342
+
343
+ ## [1.0.41] - 2023-08-04
344
+
345
+ ### Changed
346
+
347
+ - Added an option to the method that searches for faces in the collection to throw an exception if a face is not found or if multiple faces are found.
348
+
349
+ ## [1.0.40] - 2023-08-04
350
+
351
+ ### Changed
352
+
353
+ - Fixed to return null instead of throwing an error when looking for faces in the collection using images without faces (<code>AWSRekognitionClient.searchFaces()</code>).
354
+
355
+ ## [1.0.39] - 2023-07-24
356
+
357
+ ### Changed
358
+
359
+ - Renamed AWS Rekognition exception classes to more descriptive names. All face-related error classes now follow a consistent naming pattern with "Face" prefix and "Failed"/"Missing"/"Multiple" suffixes for better clarity and error handling.
360
+
361
+ ## [1.0.38] - 2023-07-17
362
+
363
+ ### Fixed
364
+
365
+ - Fixed a bug that prevented login user data from being referenced in the view rendering hook function.
366
+
367
+ ## [1.0.37] - 2023-07-17
368
+
369
+ ### Changed
370
+
371
+ - The view rendering hook function now supports asynchronous functions for async operations before rendering.
372
+
373
+ ### Added
374
+
375
+ - New Math-related view helpers have been added.
376
+
377
+ ## [1.0.36] - 2023-07-12
378
+
379
+ ### Changed
380
+
381
+ - Moved the Ajax determination option (`is_ajax`) from authentication configuration to application configuration.
382
+ - The error handler option has been replaced with a hookable error handling mechanism (`hook_handle_error`) for more flexible error processing.
383
+
384
+ ## [1.0.35] - 2023-07-11
385
+
386
+ ### Changed
387
+
388
+ - The login failure redirect URL option can now be defined as a function for dynamic redirect behavior.
389
+ - Authentication service's `failureRedirect` method signature changed to accept both request and response objects instead of response only.
390
+
391
+ ## [1.0.34] - 2023-07-01
392
+
393
+ ### Changed
394
+
395
+ - Changed the response status code from 403 to 401 when asynchronous communication requiring authentication fails to authenticate.
396
+
397
+ ## [1.0.33] - 2023-07-01
398
+
399
+ ### Added
400
+
401
+ - Added regular expression comparison view helper.
402
+
403
+ ## [1.0.32] - 2023-07-01
404
+
405
+ ### Fixed
406
+
407
+ - Fixed a bug that prevented cookies from being accessed in the view rendering hook function.
408
+
409
+ ## [1.0.31] - 2023-06-29
410
+
411
+ ### Changed
412
+
413
+ - Changed helper function names in the view (Handlebars) from SnakeCase to CamelCase.
414
+ |After|Before|Description|
415
+ |--|--|--|
416
+ |notEmpty|not_empty|Check that it is not empty.|
417
+ |formatDate|format_date|Use moment to format the date.|
418
+ |cacheBusting|cache_busting|Returns the Assets path containing the file update time parameter.|
419
+ |jsonStringify|json_stringify|Stringify an object using JSON.stringify.|
420
+ |jsonParse|json_parse|Parses the given string using JSON.parse.|
421
+ |formatBytes|format_bytes|Convert bytes to just the right units(KB, MB, GB, TB, PB, EB, ZB, YB).|
422
+
423
+ ### Added
424
+
425
+ - Added view helper to convert numeric values to strings with language-sensitive representations.
426
+
427
+ ## [1.0.30] - 2023-06-26
428
+
429
+ ### Changed
430
+
431
+ - Fixed AWS Rekognition credentials passing.
432
+
433
+ ## [1.0.29] - 2023-06-20
434
+
435
+ ### Changed
436
+
437
+ - Changed class private variables and methods from soft private to hard private.
438
+
439
+ ### Added
440
+
441
+ - Added AWS SES email sending client class.
442
+
443
+ ## [1.0.28] - 2023-06-16
444
+
445
+ ### Changed
446
+
447
+ - Updated AWS SDK version from 2 to 3.
448
+
449
+ ## [1.0.27] - 2023-06-12
450
+
451
+ ### Changed
452
+
453
+ - The view rendering hook function now receives the request object as an argument for accessing request data during rendering.
454
+
455
+ ## [1.0.26] - 2023-06-11
456
+
457
+ ### Changed
458
+
459
+ - Updated Sequelize from v5 to v6.
460
+ - Changed the framework debug log to output only when the environment variable SWEET_DEBUG is defined.
461
+ .env:
462
+ ```
463
+ SWEET_DEBUG=true
464
+ ```
465
+
466
+ ## [1.0.25] - 2022-11-24
467
+
468
+ ### Added
469
+
470
+ - Added formatBytes view helper to convert bytes to appropriate units.
471
+
472
+ ## [1.0.24] - 2022-10-24
473
+
474
+ ### Added
475
+
476
+ - Added Ajax request detection option to authentication configuration for custom XHR/fetch request handling.
477
+
478
+ ## [1.0.23] - 2022-10-20
479
+
480
+ ### Added
481
+
482
+ - A request body object has been added to the parameters of the callback function for user authentication.
483
+
484
+ ## [1.0.22] - 2022-07-27
485
+
486
+ ### Added
487
+
488
+ - You can now set hook functions that are called before the view is rendered. Hook functions can be used, for example, to set local variables that can be used in the view.
489
+
490
+ ## [1.0.21] - 2022-05-26
491
+
492
+ ### Added
493
+
494
+ - Added an option to the face indexing method to retrieve details (gender, emotion, age group) of indexed faces.
495
+
496
+ ## [1.0.20] - 2022-05-25
497
+
498
+ ### Added
499
+
500
+ - Added an option to get details (emotion, gender, age group) to the face detection method.
501
+
502
+ ## [1.0.19] - 2022-05-20
503
+
504
+ ### Added
505
+
506
+ - Add date format helper to view.
507
+
508
+ ## [1.0.18] - 2022-05-18
509
+
510
+ ### Added
511
+
512
+ - User authentication sessions can now be stored in redis. To use redis for session storage, simply add the following option to config/authentication.js. Please give it a try.
513
+ config/authentication.js:
514
+ ```json
515
+ session_store: 'redis',
516
+ redis_host: 'redis://localhost:6379'
517
+ ```
518
+
519
+ ## [1.0.17] - 2022-05-17
520
+
521
+ ### Changed
522
+
523
+ - Updated documentation and refactored variable names.
524
+
525
+ ## [1.0.16] - 2022-02-14
526
+
527
+ ### Fixed
528
+
529
+ - I forgot to include the build file, so I added the build file.
530
+
531
+ ## [1.0.15] - 2022-02-14
532
+
533
+ ### Changed
534
+
535
+ - The unauthenticated route pattern option now accepts both string and RegExp patterns for more flexible route matching.
536
+
537
+ ## [1.0.14] - 2022-01-17
538
+
539
+ ### Changed
540
+
541
+ - The empty view helper can now check any type. Previously it could only check arrays.
542
+
543
+ ## [1.0.13] - 2021-12-13
544
+
545
+ ### Added
546
+
547
+ - The model's begin method now accepts the transaction option.
548
+ ```js
549
+ let transaction;
550
+ try {
551
+ transaction = await BookModel.begin({
552
+ isolationLevel: BookModel.Transaction.ISOLATION_LEVELS.REPEATABLE_READ,
553
+ type: BookModel.Transaction.TYPES.DEFERRED,
554
+ });
555
+ const book = await BookModel.findOne({where: {id: 1}}, {transaction});
556
+ book.title = 'When Im Gone';
557
+ await book.save({transaction});
558
+ await transaction.commit();
559
+
560
+ // Load updated data.
561
+ await book.reload();
562
+ } catch (error) {
563
+ if (transaction)
564
+ await transaction.rollback();
565
+ }
566
+ ```
567
+
568
+ ## [1.0.12] - 2021-11-16
569
+
570
+ ### Added
571
+
572
+ - Added a method to the model that can execute raw SQL. As there are often use cases in which it is just easier to execute raw / already prepared SQL queries, you can use the Model.query method.
573
+ ```js
574
+ // By default the function will return two arguments - a results array, and an object containing metadata (such as amount of affected rows, etc).
575
+ // Note that since this is a raw query, the metadata are dialect specific.
576
+ const [results, metadata] = await BookModel.query("UPDATE book SET title = 'When Im Gone' WHERE id = 1");
577
+
578
+ // In cases where you don't need to access the metadata you can pass in a query type to tell sequelize how to format the results. For example, for a simple select query you could do:
579
+ // We didn't need to destructure the result here - the results were returned directly
580
+ const users = await BookModel.query("SELECT * FROM book", {type: BookModel.QueryTypes.SELECT});
581
+ ```
582
+
583
+ ## [1.0.11] - 2021-11-10
584
+
585
+ ### Fixed
586
+
587
+ - Fixed a bug where the database config was read before NODE_ENV was set, preventing the correct database config from being loaded.
588
+
589
+ ## [1.0.10] - 2021-10-19
590
+
591
+ ### Changed
592
+
593
+ - Added face similarity score to face search results in collection.
594
+
595
+ ## [1.0.9] - 2021-10-13
596
+
597
+ ### Changed
598
+
599
+ - Updated dependent package 'sharp' from 0.25.4 to 0.29.1.
600
+ This update statically links sharp's pre-built libvips binaries, eliminating the need to install Python.
601
+ Click [here](https://sharp.pixelplumbing.com/changelog) for sharp change log.
602
+
603
+ ## [1.0.8] - 2021-09-25
604
+
605
+ ### Fixed
606
+
607
+ - Fixed a bug where the default router couldn't be accessed from the endpoint URL.
608
+
609
+ ## [1.0.7] - 2021-08-13
610
+
611
+ ### Added
612
+
613
+ - Added where member functions to Model class.
614
+
615
+ ## [1.0.6] - 2021-08-13
616
+
617
+ ### Added
618
+
619
+ - Added fn, col and literal member functions to Model class.
620
+
621
+ ## [1.0.5] - 2021-08-12
622
+
623
+ ### Changed
624
+
625
+ - Changed the maximum size per field for multipart (multipart/form-data) requests from 1MB to unlimited.
626
+
627
+ ## [1.0.4] - 2021-06-13
628
+
629
+ ### Fixed
630
+
631
+ - Fixed a bug where the referrer URL was set in app.locals.currentPath instead of the current URL.
632
+
633
+ ## [1.0.3] - 2021-06-13
634
+
635
+ ### Changed
636
+
637
+ - Changed 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.
638
+ ```js
639
+ // For example, when the current URL is "https://example.com/docs/api?q=value", "/docs/api" is set for "app.locals.currentPath".
640
+ console.log(app.locals.currentPath);
641
+ ```
642
+
643
+ ## [1.0.2] - 2021-06-10
644
+
645
+ ### Changed
646
+
647
+ - Updated rollup from version 2.44 to 2.51.
648
+
649
+ ### Fixed
650
+
651
+ - Fixed a bug where preloading models failed in cjs.
652
+
653
+ ## [1.0.1] - 2021-06-02
654
+
655
+ ### Fixed
656
+
657
+ - Fixed a bug that caused an error when reading options defined in ESM's default Export.
658
+
659
+ [1.0.1]: https://github.com/takuya-motoshima/express-sweet/compare/v1.0.0...v1.0.1
660
+ [1.0.2]: https://github.com/takuya-motoshima/express-sweet/compare/v1.0.1...v1.0.2
661
+ [1.0.3]: https://github.com/takuya-motoshima/express-sweet/compare/v1.0.2...v1.0.3
662
+ [1.0.4]: https://github.com/takuya-motoshima/express-sweet/compare/v1.0.3...v1.0.4
663
+ [1.0.5]: https://github.com/takuya-motoshima/express-sweet/compare/v1.0.4...v1.0.5
664
+ [1.0.6]: https://github.com/takuya-motoshima/express-sweet/compare/v1.0.5...v1.0.6
665
+ [1.0.7]: https://github.com/takuya-motoshima/express-sweet/compare/v1.0.6...v1.0.7
666
+ [1.0.8]: https://github.com/takuya-motoshima/express-sweet/compare/v1.0.7...v1.0.8
667
+ [1.0.9]: https://github.com/takuya-motoshima/express-sweet/compare/v1.0.8...v1.0.9
668
+ [1.0.10]: https://github.com/takuya-motoshima/express-sweet/compare/v1.0.9...v1.0.10
669
+ [1.0.11]: https://github.com/takuya-motoshima/express-sweet/compare/v1.0.10...v1.0.11
670
+ [1.0.12]: https://github.com/takuya-motoshima/express-sweet/compare/v1.0.11...v1.0.12
671
+ [1.0.13]: https://github.com/takuya-motoshima/express-sweet/compare/v1.0.12...v1.0.13
672
+ [1.0.14]: https://github.com/takuya-motoshima/express-sweet/compare/v1.0.13...v1.0.14
673
+ [1.0.15]: https://github.com/takuya-motoshima/express-sweet/compare/v1.0.14...v1.0.15
674
+ [1.0.16]: https://github.com/takuya-motoshima/express-sweet/compare/v1.0.15...v1.0.16
675
+ [1.0.17]: https://github.com/takuya-motoshima/express-sweet/compare/v1.0.16...v1.0.17
676
+ [1.0.18]: https://github.com/takuya-motoshima/express-sweet/compare/v1.0.17...v1.0.18
677
+ [1.0.19]: https://github.com/takuya-motoshima/express-sweet/compare/v1.0.18...v1.0.19
678
+ [1.0.20]: https://github.com/takuya-motoshima/express-sweet/compare/v1.0.19...v1.0.20
679
+ [1.0.21]: https://github.com/takuya-motoshima/express-sweet/compare/v1.0.20...v1.0.21
680
+ [1.0.22]: https://github.com/takuya-motoshima/express-sweet/compare/v1.0.21...v1.0.22
681
+ [1.0.23]: https://github.com/takuya-motoshima/express-sweet/compare/v1.0.22...v1.0.23
682
+ [1.0.24]: https://github.com/takuya-motoshima/express-sweet/compare/v1.0.23...v1.0.24
683
+ [1.0.25]: https://github.com/takuya-motoshima/express-sweet/compare/v1.0.24...v1.0.25
684
+ [1.0.26]: https://github.com/takuya-motoshima/express-sweet/compare/v1.0.25...v1.0.26
685
+ [1.0.27]: https://github.com/takuya-motoshima/express-sweet/compare/v1.0.26...v1.0.27
686
+ [1.0.28]: https://github.com/takuya-motoshima/express-sweet/compare/v1.0.27...v1.0.28
687
+ [1.0.29]: https://github.com/takuya-motoshima/express-sweet/compare/v1.0.28...v1.0.29
688
+ [1.0.30]: https://github.com/takuya-motoshima/express-sweet/compare/v1.0.29...v1.0.30
689
+ [1.0.31]: https://github.com/takuya-motoshima/express-sweet/compare/v1.0.30...v1.0.31
690
+ [1.0.32]: https://github.com/takuya-motoshima/express-sweet/compare/v1.0.31...v1.0.32
691
+ [1.0.33]: https://github.com/takuya-motoshima/express-sweet/compare/v1.0.32...v1.0.33
692
+ [1.0.34]: https://github.com/takuya-motoshima/express-sweet/compare/v1.0.33...v1.0.34
693
+ [1.0.35]: https://github.com/takuya-motoshima/express-sweet/compare/v1.0.34...v1.0.35
694
+ [1.0.36]: https://github.com/takuya-motoshima/express-sweet/compare/v1.0.35...v1.0.36
695
+ [1.0.37]: https://github.com/takuya-motoshima/express-sweet/compare/v1.0.36...v1.0.37
696
+ [1.0.38]: https://github.com/takuya-motoshima/express-sweet/compare/v1.0.37...v1.0.38
697
+ [1.0.39]: https://github.com/takuya-motoshima/express-sweet/compare/v1.0.38...v1.0.39
698
+ [1.0.40]: https://github.com/takuya-motoshima/express-sweet/compare/v1.0.39...v1.0.40
699
+ [1.0.41]: https://github.com/takuya-motoshima/express-sweet/compare/v1.0.40...v1.0.41
700
+ [1.0.42]: https://github.com/takuya-motoshima/express-sweet/compare/v1.0.41...v1.0.42
701
+ [1.0.43]: https://github.com/takuya-motoshima/express-sweet/compare/v1.0.42...v1.0.43
702
+ [1.0.44]: https://github.com/takuya-motoshima/express-sweet/compare/v1.0.43...v1.0.44
703
+ [1.0.45]: https://github.com/takuya-motoshima/express-sweet/compare/v1.0.44...v1.0.45
704
+ [1.1.0]: https://github.com/takuya-motoshima/express-sweet/compare/v1.0.45...v1.1.0
705
+ [1.1.1]: https://github.com/takuya-motoshima/express-sweet/compare/v1.1.0...v1.1.1
706
+ [2.0.0]: https://github.com/takuya-motoshima/express-sweet/compare/v1.1.1...v2.0.0
707
+ [2.0.1]: https://github.com/takuya-motoshima/express-sweet/compare/v2.0.0...v2.0.1
708
+ [2.0.2]: https://github.com/takuya-motoshima/express-sweet/compare/v2.0.1...v2.0.2
709
+ [2.0.3]: https://github.com/takuya-motoshima/express-sweet/compare/v2.0.2...v2.0.3
710
+ [2.0.4]: https://github.com/takuya-motoshima/express-sweet/compare/v2.0.3...v2.0.4
711
+ [2.0.5]: https://github.com/takuya-motoshima/express-sweet/compare/v2.0.4...v2.0.5
712
+ [2.0.6]: https://github.com/takuya-motoshima/express-sweet/compare/v2.0.5...v2.0.6
713
+ [2.0.7]: https://github.com/takuya-motoshima/express-sweet/compare/v2.0.6...v2.0.7
714
+ [2.0.8]: https://github.com/takuya-motoshima/express-sweet/compare/v2.0.7...v2.0.8
715
+ [2.0.9]: https://github.com/takuya-motoshima/express-sweet/compare/v2.0.8...v2.0.9
716
+ [3.0.0]: https://github.com/takuya-motoshima/express-sweet/compare/v2.0.9...v3.0.0
717
+ [3.0.1]: https://github.com/takuya-motoshima/express-sweet/compare/v3.0.0...v3.0.1
718
+ [3.0.2]: https://github.com/takuya-motoshima/express-sweet/compare/v3.0.1...v3.0.2
719
+ [Unreleased]: https://github.com/takuya-motoshima/express-sweet/compare/v3.0.2...HEAD