express-sweet 3.0.1 → 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,706 +1,725 @@
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
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
706
725
  [3.0.1]: https://github.com/takuya-motoshima/express-sweet/compare/v3.0.0...v3.0.1