express-sweet 2.0.8 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. package/CHANGELOG.md +244 -173
  2. package/README.md +1031 -2112
  3. package/configuration_sample/cjs/authentication.js +50 -15
  4. package/configuration_sample/cjs/config.js +38 -21
  5. package/configuration_sample/cjs/logging.js +41 -0
  6. package/configuration_sample/cjs/view.js +19 -1
  7. package/configuration_sample/esm/authentication.js +48 -15
  8. package/configuration_sample/esm/config.js +39 -22
  9. package/configuration_sample/esm/logging.js +41 -0
  10. package/configuration_sample/esm/view.js +20 -2
  11. package/dist/build.cjs +9 -9
  12. package/dist/build.mjs +9 -9
  13. package/package.json +11 -6
  14. package/types/database/DatabaseManager.d.ts +95 -0
  15. package/types/database/Model.d.ts +183 -20
  16. package/types/database/index.d.ts +47 -3
  17. package/types/database/loadModels.d.ts +19 -4
  18. package/types/handlebars_helpers/array.d.ts +3 -1
  19. package/types/handlebars_helpers/comparison.d.ts +55 -19
  20. package/types/handlebars_helpers/date.d.ts +3 -1
  21. package/types/handlebars_helpers/html.d.ts +6 -2
  22. package/types/handlebars_helpers/index.d.ts +73 -9
  23. package/types/handlebars_helpers/layouts.d.ts +5 -1
  24. package/types/handlebars_helpers/math.d.ts +21 -7
  25. package/types/handlebars_helpers/number.d.ts +3 -1
  26. package/types/handlebars_helpers/object.d.ts +6 -2
  27. package/types/handlebars_helpers/string.d.ts +9 -3
  28. package/types/index.d.ts +92 -5
  29. package/types/interfaces/AuthenticationConfig.d.ts +38 -1
  30. package/types/interfaces/BasicConfig.d.ts +26 -1
  31. package/types/interfaces/DatabaseConfig.d.ts +45 -1
  32. package/types/interfaces/LoggingConfig.d.ts +49 -0
  33. package/types/interfaces/ViewConfig.d.ts +21 -2
  34. package/types/interfaces/index.d.ts +25 -11
  35. package/types/middlewares/Authentication.d.ts +43 -6
  36. package/types/middlewares/CORS.d.ts +23 -5
  37. package/types/middlewares/Environment.d.ts +30 -4
  38. package/types/middlewares/ErrorHandler.d.ts +27 -5
  39. package/types/middlewares/Global.d.ts +20 -6
  40. package/types/middlewares/Http.d.ts +22 -5
  41. package/types/middlewares/Local.d.ts +35 -8
  42. package/types/middlewares/View.d.ts +39 -8
  43. package/types/middlewares/index.d.ts +47 -7
  44. package/types/mount.d.ts +16 -3
  45. package/types/routing/Router.d.ts +49 -7
  46. package/types/routing/index.d.ts +37 -1
  47. package/types/services/Authentication.d.ts +79 -16
  48. package/types/services/index.d.ts +33 -1
  49. package/types/types/global.d.ts +29 -8
  50. package/types/utils/Types.d.ts +5 -3
  51. package/types/utils/index.d.ts +71 -9
  52. package/types/utils/isArray.d.ts +12 -3
  53. package/types/utils/isAsyncFunction.d.ts +12 -5
  54. package/types/utils/isFunction.d.ts +13 -6
  55. package/types/utils/isObject.d.ts +14 -3
  56. package/types/utils/isString.d.ts +15 -4
  57. package/types/utils/loadAuthenticationConfig.d.ts +13 -3
  58. package/types/utils/loadBasicConfig.d.ts +13 -3
  59. package/types/utils/loadDatabaseConfig.d.ts +34 -3
  60. package/types/utils/loadLoggingConfig.d.ts +16 -0
  61. package/types/utils/loadViewConfig.d.ts +28 -3
  62. package/types/database/Database.d.ts +0 -11
  63. package/types/interfaces/BoundingBox.d.ts +0 -25
  64. package/types/interfaces/FaceDetails.d.ts +0 -30
  65. package/types/interfaces/FaceDetailsEmotions.d.ts +0 -40
  66. package/types/interfaces/FaceMatch.d.ts +0 -31
  67. package/types/interfaces/IndexFaceDetails.d.ts +0 -29
  68. package/types/interfaces/RekognitionOptions.d.ts +0 -26
  69. package/types/interfaces/SesOptions.d.ts +0 -27
package/CHANGELOG.md CHANGED
@@ -1,6 +1,74 @@
1
1
  # Changelog
2
+
2
3
  All notable changes to this project will be documented in this file.
3
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
+
4
72
  ## [2.0.8] - 2025/7/29
5
73
 
6
74
  ### Changed
@@ -12,12 +80,12 @@ All notable changes to this project will be documented in this file.
12
80
  ### Changed
13
81
 
14
82
  - Updated dependencies to address vulnerabilities
15
- - `express`: 4.19.2 => 4.21.2
16
- - `express-session`: 1.18.0 => 1.18.2
17
- - `body-parser`: 1.19.0 => 2.2.0
18
- - `cookie-parser`: 1.4.4 => 1.4.7
19
- - `morgan`: 1.10.0 => 1.10.1
20
- - `rollup`: 4.21.2 => 4.45.1
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
21
89
 
22
90
  ## [2.0.6] - 2025/2/9
23
91
 
@@ -31,18 +99,18 @@ All notable changes to this project will be documented in this file.
31
99
 
32
100
  - Added a Handlebars helper, available for use in views, to replace HTML tags in a string.
33
101
 
34
- Example:
102
+ Example:
35
103
 
36
- ```html
37
- {{!-- results in: lorem ipsum dolor sit amet --}}
38
- {{{stripTags '<a href="https://example.com">lorem ipsum <strong>dolor</strong> <em>sit</em> amet</a>'}}}
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>'}}}
39
107
 
40
- {{!-- results in: lorem ipsum <strong>dolor</strong> sit amet --}}
41
- {{{stripTags '<a href="https://example.com">lorem ipsum <strong>dolor</strong> <em>sit</em> amet</a>' '<strong>' ''}}}
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>' ''}}}
42
110
 
43
- {{!-- results in: 🍩lorem ipsum 🍩dolor🍩 🍩sit🍩 amet🍩 --}}
44
- {{{stripTags '<a href="https://example.com">lorem ipsum <strong>dolor</strong> <em>sit</em> amet</a>' [] '🍩'}}}
45
- ```
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
+ ```
46
114
 
47
115
  ## [2.0.4] - 2025/1/14
48
116
 
@@ -57,19 +125,19 @@ All notable changes to this project will be documented in this file.
57
125
 
58
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.
59
127
 
60
- Example:
128
+ Example:
61
129
 
62
- ```html
63
- {{!--
64
- items is an array of objects: [{id: 123, name: 'Item A'}, {id: 456, name: 'Item B'}]
65
- This code will output: "Item A"
66
- --}}
67
- {{#each items}}
68
- {{#if (eq id 123)}}
69
- {{lookup (findObjectInArray ../items 'id' id) 'name'}}
70
- {{/if}}
71
- {{/each}}
72
- ```
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
+ ```
73
141
 
74
142
  ## [2.0.3] - 2024/9/3
75
143
 
@@ -78,7 +146,7 @@ All notable changes to this project will be documented in this file.
78
146
  - Add `"type": "module"` to the `package.json` of the esm app generated by `express-sweet-generator`. It is fully esm compliant.
79
147
  - `require` was changed to dynamic import.
80
148
  - Template engine changed from `express-hbs` to `express-handlebars`.
81
- However, the `block` and `contentFor` helpers are still available.
149
+ However, the `block` and `contentFor` helpers are still available.
82
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.
83
151
  - Return type of `mount()` changed from `void` to `Promise<void>`.
84
152
  - Return type of `middlewares/CORS.mount()` changed from `void` to `Promise<void>`.
@@ -99,24 +167,24 @@ All notable changes to this project will be documented in this file.
99
167
  - Return type of `database/Model.initialize()` changed from `typeof Model` to `Promise<typeof Model>`.
100
168
  - Return type of `database/loadModels()` changed from `void` to `Promise<void>`.
101
169
  - DB connection check method has been changed.
102
- - After:
103
- ```js
104
- const expressExtension = require('express-sweet');
105
-
106
- // Create Database instance.
107
- const config = await expressExtension.utils.loadDatabaseConfig();
108
- const database = new expressExtension.database.Database(config.database, config.username, config.password, config);
109
-
110
- // Check database connection.
111
- await database.isConnect();
112
- ```
113
- - Before:
114
- ```js
115
- const expressExtension = require('express-sweet');
116
-
117
- // Check database connection.
118
- await expressExtension.database.Database.isConnect();
119
- ```
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
+ ```
120
188
  - Update passport from 0.4.1 to 0.7.0
121
189
 
122
190
  ## [2.0.2] - 2024/9/1
@@ -139,7 +207,7 @@ All notable changes to this project will be documented in this file.
139
207
  ### Changed
140
208
 
141
209
  - EXPRESS SWEET version 2 no longer depends on the AWS SDK.
142
- 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.
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.
143
211
 
144
212
  ## [1.1.1] - 2024/3/23
145
213
 
@@ -155,12 +223,12 @@ All notable changes to this project will be documented in this file.
155
223
  ### Changed
156
224
 
157
225
  - Updated EXPRESS SWEET's dependency packages.
158
- - [express](https://www.npmjs.com/package/express) from v4.18.2 to v4.18.3
159
- - [multer](https://www.npmjs.com/package/multer) from v1.4.4 to v1.4.5-lts.1
160
- - [express-session](https://www.npmjs.com/package/express-session) from v1.17.3 to v1.18.0
161
- - [sequelize](https://www.npmjs.com/package/sequelize) from v6.32.0 to v6.37.1
162
- - [mariadb](https://www.npmjs.com/package/mariadb) from v2.4.0 to v3.2.3
163
- - [moment](https://www.npmjs.com/package/moment) from v2.29.4 to v2.30.1
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
164
232
 
165
233
  ## [1.0.44] - 2023/12/30
166
234
 
@@ -180,10 +248,10 @@ All notable changes to this project will be documented in this file.
180
248
 
181
249
  - Update TypeScript version from 4.8.4 to 5.2.2.
182
250
  - Update redis dependency package used for user authentication.
183
- - Updated redis package version from 4.3.1 to 4.6.8.
184
- [Here](https://github.com/redis/node-redis/blob/master/CHANGELOG.md) are the changes.
185
- - Updated connect-redis package version from 6.1.3 to 7.1.0.
186
- [Here](https://github.com/tj/connect-redis/releases) are the changes.
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.
187
255
 
188
256
 
189
257
  ## [1.0.41] - 2023/8/4
@@ -203,73 +271,73 @@ All notable changes to this project will be documented in this file.
203
271
  ### Changed
204
272
 
205
273
  - Changed exception class name.
206
- <table>
207
- <thead>
208
- <tr>
209
- <th>Before Class Name</th>
210
- <th>After class name</th>
211
- <th>Instance member</th>
212
- <th>Description</th>
213
- </tr>
214
- </thead>
215
- <tbody>
216
- <tr>
217
- <td>CollectionCreationError</td>
218
- <td>FaceCollectionCreateFailed</td>
219
- <td>
220
- <ul>
221
- <li>name: Error Name.</li>
222
- <li>collectionId: Collection ID.</li>
223
- <li>httpStatusCode: HTTP status code.</li>
224
- </ul>
225
- </td>
226
- <td>Thrown when face collection creation (<code>AWSRekognitionClient.createCollection()</code>) fails.</td>
227
- </tr>
228
- <tr>
229
- <td>CollectionDeletionError</td>
230
- <td>FaceCollectionDeleteFailed</td>
231
- <td>
232
- <ul>
233
- <li>name: Error Name.</li>
234
- <li>collectionId: Collection ID.</li>
235
- <li>httpStatusCode: HTTP status code.</li>
236
- </ul>
237
- </td>
238
- <td>Thrown when deleting a face collection (<code>AWSRekognitionClient.deleteCollection()</code>) fails.</td>
239
- </tr>
240
- <tr>
241
- <td>FaceIndexError</td>
242
- <td>FaceIndexFailed</td>
243
- <td>
244
- <ul>
245
- <li>name: Error Name.</li>
246
- <li>collectionId: Collection ID.</li>
247
- </ul>
248
- </td>
249
- <td>Thrown when face indexing (<code>AWSRekognitionClient.indexFace()</code>) fails.</td>
250
- </tr>
251
- <tr>
252
- <td>MissingFaceInImageError</td>
253
- <td>FaceMissingInPhoto</td>
254
- <td>
255
- <ul>
256
- <li>name: Error Name.</li>
257
- </ul>
258
- </td>
259
- <td>Thrown if the face to index (<code>AWSRekognitionClient.indexFace()</code>) is not in the photo.</td>
260
- </tr>
261
- <tr>
262
- <td>MultipleFacesInImageError</td>
263
- <td>FacesMultipleInPhoto</td>
264
- <td>
265
- <ul>
266
- <li>name: Error Name.</li>
267
- </ul>
268
- </td>
269
- <td>Thrown when there are multiple faces to index (<code>AWSRekognitionClient.indexFace()</code>) in a photo.</td>
270
- </tr>
271
- </tbody>
272
- </table>
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>
273
341
 
274
342
  ## [1.0.38] - 2023/7/17
275
343
 
@@ -324,14 +392,14 @@ All notable changes to this project will be documented in this file.
324
392
  ### Changed
325
393
 
326
394
  - Changed helper function names in the view (Handlebars) from SnakeCase to CamelCase.
327
- |After|Before|Description|
328
- |--|--|--|
329
- |notEmpty|not_empty|Check that it is not empty.|
330
- |formatDate|format_date|Use moment to format the date.|
331
- |cacheBusting|cache_busting|Returns the Assets path containing the file update time parameter.|
332
- |jsonStringify|json_stringify|Stringify an object using JSON.stringify.|
333
- |jsonParse|json_parse|Parses the given string using JSON.parse.|
334
- |formatBytes|format_bytes|Convert bytes to just the right units(KB, MB, GB, TB, PB, EB, ZB, YB).|
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).|
335
403
 
336
404
  ### Added
337
405
 
@@ -371,10 +439,10 @@ All notable changes to this project will be documented in this file.
371
439
 
372
440
  - Update Sequelize from v5 to v6.
373
441
  - Changed the framework debug log to output only when the environment variable EXPRESS_DEBUG is defined.
374
- .env:
375
- ```
376
- EXPRESS_DEBUG=true
377
- ```
442
+ .env:
443
+ ```
444
+ EXPRESS_DEBUG=true
445
+ ```
378
446
 
379
447
  ## [1.0.25] - 2022/11/24
380
448
 
@@ -423,11 +491,11 @@ All notable changes to this project will be documented in this file.
423
491
  ### Added
424
492
 
425
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.
426
- config/authentication.js:
427
- ```json
428
- session_store: 'redis',
429
- redis_host: 'redis://localhost:6379'
430
- ```
494
+ config/authentication.js:
495
+ ```json
496
+ session_store: 'redis',
497
+ redis_host: 'redis://localhost:6379'
498
+ ```
431
499
 
432
500
  ## [1.0.17] - 2022/5/17
433
501
 
@@ -458,40 +526,40 @@ All notable changes to this project will be documented in this file.
458
526
  ### Added
459
527
 
460
528
  - The model's begin method now accepts the transaction option.
461
- ```js
462
- let transaction;
463
- try {
464
- transaction = await BookModel.begin({
465
- isolationLevel: BookModel.Transaction.ISOLATION_LEVELS.REPEATABLE_READ,
466
- type: BookModel.Transaction.TYPES.DEFERRED,
467
- });
468
- const book = await BookModel.findOne({where: {id: 1}}, {transaction});
469
- book.title = 'When Im Gone';
470
- await book.save({transaction});
471
- await transaction.commit();
472
-
473
- // Load updated data.
474
- await book.reload();
475
- } catch (error) {
476
- if (transaction)
477
- await transaction.rollback();
478
- }
479
- ```
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
+ ```
480
548
 
481
549
  ## [1.0.12] - 2021/11/16
482
550
 
483
551
  ### Added
484
552
 
485
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.
486
- ```js
487
- // By default the function will return two arguments - a results array, and an object containing metadata (such as amount of affected rows, etc).
488
- // Note that since this is a raw query, the metadata are dialect specific.
489
- const [results, metadata] = await BookModel.query("UPDATE book SET title = 'When Im Gone' WHERE id = 1");
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");
490
558
 
491
- // 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:
492
- // We didn't need to destructure the result here - the results were returned directly
493
- const users = await BookModel.query("SELECT * FROM book", {type: BookModel.QueryTypes.SELECT});
494
- ```
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
+ ```
495
563
 
496
564
  ## [1.0.11] - 2021/11/10
497
565
 
@@ -548,10 +616,10 @@ All notable changes to this project will be documented in this file.
548
616
  ### Changed
549
617
 
550
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.
551
- ```js
552
- // For example, when the current URL is "https://example.com/docs/api?q=value", "/docs/api" is set for "app.locals.currentPath".
553
- console.log(app.locals.currentPath);
554
- ```
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
+ ```
555
623
 
556
624
  ## [1.0.2] - 2021//6/10
557
625
 
@@ -623,4 +691,7 @@ All notable changes to this project will be documented in this file.
623
691
  [2.0.4]: https://github.com/takuya-motoshima/express-sweet/compare/v2.0.3...v2.0.4
624
692
  [2.0.5]: https://github.com/takuya-motoshima/express-sweet/compare/v2.0.4...v2.0.5
625
693
  [2.0.6]: https://github.com/takuya-motoshima/express-sweet/compare/v2.0.5...v2.0.6
626
- [2.0.7]: https://github.com/takuya-motoshima/express-sweet/compare/v2.0.6...v2.0.7
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