express-sweet 3.0.0 → 3.0.2

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