express-sweet 2.0.7 → 2.0.9
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 +191 -173
- package/README.md +48 -26
- package/dist/build.cjs +9 -9
- package/dist/build.mjs +9 -9
- package/package.json +3 -3
- package/types/database/Database.d.ts +7 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,17 +1,33 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
All notable changes to this project will be documented in this file.
|
|
3
3
|
|
|
4
|
+
## [2.0.9] - 2025/8/12
|
|
5
|
+
|
|
6
|
+
### Added
|
|
7
|
+
|
|
8
|
+
- Added `getConfig()` method to Database class to retrieve the current database configuration object containing all sequelize options.
|
|
9
|
+
|
|
10
|
+
### Changed
|
|
11
|
+
|
|
12
|
+
- Updated `multer` dependency from v1.4.5-lts.1 to v2.0.2 for improved file upload handling and security enhancements.
|
|
13
|
+
|
|
14
|
+
## [2.0.8] - 2025/7/29
|
|
15
|
+
|
|
16
|
+
### Changed
|
|
17
|
+
|
|
18
|
+
- Updated the usage example of the `isConnect` method in the `Database` class in the README reference.
|
|
19
|
+
|
|
4
20
|
## [2.0.7] - 2025/7/22
|
|
5
21
|
|
|
6
22
|
### Changed
|
|
7
23
|
|
|
8
24
|
- Updated dependencies to address vulnerabilities
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
25
|
+
- `express`: 4.19.2 => 4.21.2
|
|
26
|
+
- `express-session`: 1.18.0 => 1.18.2
|
|
27
|
+
- `body-parser`: 1.19.0 => 2.2.0
|
|
28
|
+
- `cookie-parser`: 1.4.4 => 1.4.7
|
|
29
|
+
- `morgan`: 1.10.0 => 1.10.1
|
|
30
|
+
- `rollup`: 4.21.2 => 4.45.1
|
|
15
31
|
|
|
16
32
|
## [2.0.6] - 2025/2/9
|
|
17
33
|
|
|
@@ -25,18 +41,18 @@ All notable changes to this project will be documented in this file.
|
|
|
25
41
|
|
|
26
42
|
- Added a Handlebars helper, available for use in views, to replace HTML tags in a string.
|
|
27
43
|
|
|
28
|
-
|
|
44
|
+
Example:
|
|
29
45
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
46
|
+
```html
|
|
47
|
+
{{!-- results in: lorem ipsum dolor sit amet --}}
|
|
48
|
+
{{{stripTags '<a href="https://example.com">lorem ipsum <strong>dolor</strong> <em>sit</em> amet</a>'}}}
|
|
33
49
|
|
|
34
|
-
|
|
35
|
-
|
|
50
|
+
{{!-- results in: lorem ipsum <strong>dolor</strong> sit amet --}}
|
|
51
|
+
{{{stripTags '<a href="https://example.com">lorem ipsum <strong>dolor</strong> <em>sit</em> amet</a>' '<strong>' ''}}}
|
|
36
52
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
53
|
+
{{!-- results in: 🍩lorem ipsum 🍩dolor🍩 🍩sit🍩 amet🍩 --}}
|
|
54
|
+
{{{stripTags '<a href="https://example.com">lorem ipsum <strong>dolor</strong> <em>sit</em> amet</a>' [] '🍩'}}}
|
|
55
|
+
```
|
|
40
56
|
|
|
41
57
|
## [2.0.4] - 2025/1/14
|
|
42
58
|
|
|
@@ -51,19 +67,19 @@ All notable changes to this project will be documented in this file.
|
|
|
51
67
|
|
|
52
68
|
- **`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.
|
|
53
69
|
|
|
54
|
-
|
|
70
|
+
Example:
|
|
55
71
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
72
|
+
```html
|
|
73
|
+
{{!--
|
|
74
|
+
items is an array of objects: [{id: 123, name: 'Item A'}, {id: 456, name: 'Item B'}]
|
|
75
|
+
This code will output: "Item A"
|
|
76
|
+
--}}
|
|
77
|
+
{{#each items}}
|
|
78
|
+
{{#if (eq id 123)}}
|
|
79
|
+
{{lookup (findObjectInArray ../items 'id' id) 'name'}}
|
|
80
|
+
{{/if}}
|
|
81
|
+
{{/each}}
|
|
82
|
+
```
|
|
67
83
|
|
|
68
84
|
## [2.0.3] - 2024/9/3
|
|
69
85
|
|
|
@@ -72,7 +88,7 @@ All notable changes to this project will be documented in this file.
|
|
|
72
88
|
- Add `"type": "module"` to the `package.json` of the esm app generated by `express-sweet-generator`. It is fully esm compliant.
|
|
73
89
|
- `require` was changed to dynamic import.
|
|
74
90
|
- Template engine changed from `express-hbs` to `express-handlebars`.
|
|
75
|
-
|
|
91
|
+
However, the `block` and `contentFor` helpers are still available.
|
|
76
92
|
- `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.
|
|
77
93
|
- Return type of `mount()` changed from `void` to `Promise<void>`.
|
|
78
94
|
- Return type of `middlewares/CORS.mount()` changed from `void` to `Promise<void>`.
|
|
@@ -93,24 +109,24 @@ All notable changes to this project will be documented in this file.
|
|
|
93
109
|
- Return type of `database/Model.initialize()` changed from `typeof Model` to `Promise<typeof Model>`.
|
|
94
110
|
- Return type of `database/loadModels()` changed from `void` to `Promise<void>`.
|
|
95
111
|
- DB connection check method has been changed.
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
112
|
+
- After:
|
|
113
|
+
```js
|
|
114
|
+
const expx = require('express-sweet');
|
|
115
|
+
|
|
116
|
+
// Create Database instance.
|
|
117
|
+
const config = await expx.utils.loadDatabaseConfig();
|
|
118
|
+
const database = new expx.database.Database(config.database, config.username, config.password, config);
|
|
119
|
+
|
|
120
|
+
// Check database connection.
|
|
121
|
+
await database.isConnect();
|
|
122
|
+
```
|
|
123
|
+
- Before:
|
|
124
|
+
```js
|
|
125
|
+
const expx = require('express-sweet');
|
|
126
|
+
|
|
127
|
+
// Check database connection.
|
|
128
|
+
await expx.database.Database.isConnect();
|
|
129
|
+
```
|
|
114
130
|
- Update passport from 0.4.1 to 0.7.0
|
|
115
131
|
|
|
116
132
|
## [2.0.2] - 2024/9/1
|
|
@@ -133,7 +149,7 @@ All notable changes to this project will be documented in this file.
|
|
|
133
149
|
### Changed
|
|
134
150
|
|
|
135
151
|
- EXPRESS SWEET version 2 no longer depends on the AWS SDK.
|
|
136
|
-
|
|
152
|
+
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.
|
|
137
153
|
|
|
138
154
|
## [1.1.1] - 2024/3/23
|
|
139
155
|
|
|
@@ -149,12 +165,12 @@ All notable changes to this project will be documented in this file.
|
|
|
149
165
|
### Changed
|
|
150
166
|
|
|
151
167
|
- Updated EXPRESS SWEET's dependency packages.
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
168
|
+
- [express](https://www.npmjs.com/package/express) from v4.18.2 to v4.18.3
|
|
169
|
+
- [multer](https://www.npmjs.com/package/multer) from v1.4.4 to v1.4.5-lts.1
|
|
170
|
+
- [express-session](https://www.npmjs.com/package/express-session) from v1.17.3 to v1.18.0
|
|
171
|
+
- [sequelize](https://www.npmjs.com/package/sequelize) from v6.32.0 to v6.37.1
|
|
172
|
+
- [mariadb](https://www.npmjs.com/package/mariadb) from v2.4.0 to v3.2.3
|
|
173
|
+
- [moment](https://www.npmjs.com/package/moment) from v2.29.4 to v2.30.1
|
|
158
174
|
|
|
159
175
|
## [1.0.44] - 2023/12/30
|
|
160
176
|
|
|
@@ -174,10 +190,10 @@ All notable changes to this project will be documented in this file.
|
|
|
174
190
|
|
|
175
191
|
- Update TypeScript version from 4.8.4 to 5.2.2.
|
|
176
192
|
- Update redis dependency package used for user authentication.
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
193
|
+
- Updated redis package version from 4.3.1 to 4.6.8.
|
|
194
|
+
[Here](https://github.com/redis/node-redis/blob/master/CHANGELOG.md) are the changes.
|
|
195
|
+
- Updated connect-redis package version from 6.1.3 to 7.1.0.
|
|
196
|
+
[Here](https://github.com/tj/connect-redis/releases) are the changes.
|
|
181
197
|
|
|
182
198
|
|
|
183
199
|
## [1.0.41] - 2023/8/4
|
|
@@ -197,73 +213,73 @@ All notable changes to this project will be documented in this file.
|
|
|
197
213
|
### Changed
|
|
198
214
|
|
|
199
215
|
- Changed exception class name.
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
216
|
+
<table>
|
|
217
|
+
<thead>
|
|
218
|
+
<tr>
|
|
219
|
+
<th>Before Class Name</th>
|
|
220
|
+
<th>After class name</th>
|
|
221
|
+
<th>Instance member</th>
|
|
222
|
+
<th>Description</th>
|
|
223
|
+
</tr>
|
|
224
|
+
</thead>
|
|
225
|
+
<tbody>
|
|
226
|
+
<tr>
|
|
227
|
+
<td>CollectionCreationError</td>
|
|
228
|
+
<td>FaceCollectionCreateFailed</td>
|
|
229
|
+
<td>
|
|
230
|
+
<ul>
|
|
231
|
+
<li>name: Error Name.</li>
|
|
232
|
+
<li>collectionId: Collection ID.</li>
|
|
233
|
+
<li>httpStatusCode: HTTP status code.</li>
|
|
234
|
+
</ul>
|
|
235
|
+
</td>
|
|
236
|
+
<td>Thrown when face collection creation (<code>AWSRekognitionClient.createCollection()</code>) fails.</td>
|
|
237
|
+
</tr>
|
|
238
|
+
<tr>
|
|
239
|
+
<td>CollectionDeletionError</td>
|
|
240
|
+
<td>FaceCollectionDeleteFailed</td>
|
|
241
|
+
<td>
|
|
242
|
+
<ul>
|
|
243
|
+
<li>name: Error Name.</li>
|
|
244
|
+
<li>collectionId: Collection ID.</li>
|
|
245
|
+
<li>httpStatusCode: HTTP status code.</li>
|
|
246
|
+
</ul>
|
|
247
|
+
</td>
|
|
248
|
+
<td>Thrown when deleting a face collection (<code>AWSRekognitionClient.deleteCollection()</code>) fails.</td>
|
|
249
|
+
</tr>
|
|
250
|
+
<tr>
|
|
251
|
+
<td>FaceIndexError</td>
|
|
252
|
+
<td>FaceIndexFailed</td>
|
|
253
|
+
<td>
|
|
254
|
+
<ul>
|
|
255
|
+
<li>name: Error Name.</li>
|
|
256
|
+
<li>collectionId: Collection ID.</li>
|
|
257
|
+
</ul>
|
|
258
|
+
</td>
|
|
259
|
+
<td>Thrown when face indexing (<code>AWSRekognitionClient.indexFace()</code>) fails.</td>
|
|
260
|
+
</tr>
|
|
261
|
+
<tr>
|
|
262
|
+
<td>MissingFaceInImageError</td>
|
|
263
|
+
<td>FaceMissingInPhoto</td>
|
|
264
|
+
<td>
|
|
265
|
+
<ul>
|
|
266
|
+
<li>name: Error Name.</li>
|
|
267
|
+
</ul>
|
|
268
|
+
</td>
|
|
269
|
+
<td>Thrown if the face to index (<code>AWSRekognitionClient.indexFace()</code>) is not in the photo.</td>
|
|
270
|
+
</tr>
|
|
271
|
+
<tr>
|
|
272
|
+
<td>MultipleFacesInImageError</td>
|
|
273
|
+
<td>FacesMultipleInPhoto</td>
|
|
274
|
+
<td>
|
|
275
|
+
<ul>
|
|
276
|
+
<li>name: Error Name.</li>
|
|
277
|
+
</ul>
|
|
278
|
+
</td>
|
|
279
|
+
<td>Thrown when there are multiple faces to index (<code>AWSRekognitionClient.indexFace()</code>) in a photo.</td>
|
|
280
|
+
</tr>
|
|
281
|
+
</tbody>
|
|
282
|
+
</table>
|
|
267
283
|
|
|
268
284
|
## [1.0.38] - 2023/7/17
|
|
269
285
|
|
|
@@ -318,14 +334,14 @@ All notable changes to this project will be documented in this file.
|
|
|
318
334
|
### Changed
|
|
319
335
|
|
|
320
336
|
- Changed helper function names in the view (Handlebars) from SnakeCase to CamelCase.
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
337
|
+
|After|Before|Description|
|
|
338
|
+
|--|--|--|
|
|
339
|
+
|notEmpty|not_empty|Check that it is not empty.|
|
|
340
|
+
|formatDate|format_date|Use moment to format the date.|
|
|
341
|
+
|cacheBusting|cache_busting|Returns the Assets path containing the file update time parameter.|
|
|
342
|
+
|jsonStringify|json_stringify|Stringify an object using JSON.stringify.|
|
|
343
|
+
|jsonParse|json_parse|Parses the given string using JSON.parse.|
|
|
344
|
+
|formatBytes|format_bytes|Convert bytes to just the right units(KB, MB, GB, TB, PB, EB, ZB, YB).|
|
|
329
345
|
|
|
330
346
|
### Added
|
|
331
347
|
|
|
@@ -365,10 +381,10 @@ All notable changes to this project will be documented in this file.
|
|
|
365
381
|
|
|
366
382
|
- Update Sequelize from v5 to v6.
|
|
367
383
|
- Changed the framework debug log to output only when the environment variable EXPRESS_DEBUG is defined.
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
384
|
+
.env:
|
|
385
|
+
```
|
|
386
|
+
EXPRESS_DEBUG=true
|
|
387
|
+
```
|
|
372
388
|
|
|
373
389
|
## [1.0.25] - 2022/11/24
|
|
374
390
|
|
|
@@ -417,11 +433,11 @@ All notable changes to this project will be documented in this file.
|
|
|
417
433
|
### Added
|
|
418
434
|
|
|
419
435
|
- 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.
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
436
|
+
config/authentication.js:
|
|
437
|
+
```json
|
|
438
|
+
session_store: 'redis',
|
|
439
|
+
redis_host: 'redis://localhost:6379'
|
|
440
|
+
```
|
|
425
441
|
|
|
426
442
|
## [1.0.17] - 2022/5/17
|
|
427
443
|
|
|
@@ -452,40 +468,40 @@ All notable changes to this project will be documented in this file.
|
|
|
452
468
|
### Added
|
|
453
469
|
|
|
454
470
|
- The model's begin method now accepts the transaction option.
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
471
|
+
```js
|
|
472
|
+
let transaction;
|
|
473
|
+
try {
|
|
474
|
+
transaction = await BookModel.begin({
|
|
475
|
+
isolationLevel: BookModel.Transaction.ISOLATION_LEVELS.REPEATABLE_READ,
|
|
476
|
+
type: BookModel.Transaction.TYPES.DEFERRED,
|
|
477
|
+
});
|
|
478
|
+
const book = await BookModel.findOne({where: {id: 1}}, {transaction});
|
|
479
|
+
book.title = 'When Im Gone';
|
|
480
|
+
await book.save({transaction});
|
|
481
|
+
await transaction.commit();
|
|
482
|
+
|
|
483
|
+
// Load updated data.
|
|
484
|
+
await book.reload();
|
|
485
|
+
} catch (error) {
|
|
486
|
+
if (transaction)
|
|
487
|
+
await transaction.rollback();
|
|
488
|
+
}
|
|
489
|
+
```
|
|
474
490
|
|
|
475
491
|
## [1.0.12] - 2021/11/16
|
|
476
492
|
|
|
477
493
|
### Added
|
|
478
494
|
|
|
479
495
|
- 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.
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
496
|
+
```js
|
|
497
|
+
// By default the function will return two arguments - a results array, and an object containing metadata (such as amount of affected rows, etc).
|
|
498
|
+
// Note that since this is a raw query, the metadata are dialect specific.
|
|
499
|
+
const [results, metadata] = await BookModel.query("UPDATE book SET title = 'When Im Gone' WHERE id = 1");
|
|
484
500
|
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
501
|
+
// 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:
|
|
502
|
+
// We didn't need to destructure the result here - the results were returned directly
|
|
503
|
+
const users = await BookModel.query("SELECT * FROM book", {type: BookModel.QueryTypes.SELECT});
|
|
504
|
+
```
|
|
489
505
|
|
|
490
506
|
## [1.0.11] - 2021/11/10
|
|
491
507
|
|
|
@@ -542,10 +558,10 @@ All notable changes to this project will be documented in this file.
|
|
|
542
558
|
### Changed
|
|
543
559
|
|
|
544
560
|
- 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.
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
561
|
+
```js
|
|
562
|
+
// For example, when the current URL is "https://example.com/docs/api?q=value", "/docs/api" is set for "app.locals.currentPath".
|
|
563
|
+
console.log(app.locals.currentPath);
|
|
564
|
+
```
|
|
549
565
|
|
|
550
566
|
## [1.0.2] - 2021//6/10
|
|
551
567
|
|
|
@@ -617,4 +633,6 @@ All notable changes to this project will be documented in this file.
|
|
|
617
633
|
[2.0.4]: https://github.com/takuya-motoshima/express-sweet/compare/v2.0.3...v2.0.4
|
|
618
634
|
[2.0.5]: https://github.com/takuya-motoshima/express-sweet/compare/v2.0.4...v2.0.5
|
|
619
635
|
[2.0.6]: https://github.com/takuya-motoshima/express-sweet/compare/v2.0.5...v2.0.6
|
|
620
|
-
[2.0.7]: https://github.com/takuya-motoshima/express-sweet/compare/v2.0.6...v2.0.7
|
|
636
|
+
[2.0.7]: https://github.com/takuya-motoshima/express-sweet/compare/v2.0.6...v2.0.7
|
|
637
|
+
[2.0.8]: https://github.com/takuya-motoshima/express-sweet/compare/v2.0.7...v2.0.8
|
|
638
|
+
[2.0.9]: https://github.com/takuya-motoshima/express-sweet/compare/v2.0.8...v2.0.9
|