express-sweet 3.0.2 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +112 -118
- package/README.md +206 -57
- package/configuration_sample/cjs/config.js +5 -4
- package/configuration_sample/cjs/upload.js +91 -0
- package/configuration_sample/esm/config.js +5 -4
- package/configuration_sample/esm/upload.js +91 -0
- package/dist/build.cjs +41 -35
- package/dist/build.mjs +41 -35
- package/package.json +6 -4
- package/types/database/Model.d.ts +2 -2
- package/types/handlebars_helpers/object.d.ts +2 -2
- package/types/index.d.ts +1 -43
- package/types/interfaces/{BasicConfig.d.ts → AppConfig.d.ts} +8 -7
- package/types/interfaces/DatabaseConfig.d.ts +1 -0
- package/types/interfaces/UploadConfig.d.ts +73 -0
- package/types/interfaces/index.d.ts +6 -2
- package/types/middlewares/corsPolicy.d.ts +28 -0
- package/types/middlewares/{Environment.d.ts → envLoader.d.ts} +13 -15
- package/types/middlewares/errorHandler.d.ts +32 -0
- package/types/middlewares/globalVars.d.ts +25 -0
- package/types/middlewares/index.d.ts +19 -11
- package/types/middlewares/localVars.d.ts +44 -0
- package/types/middlewares/passportAuth.d.ts +15 -0
- package/types/middlewares/requestParser.d.ts +27 -0
- package/types/{routing/Router.d.ts → middlewares/routeMapper.d.ts} +14 -16
- package/types/middlewares/viewEngine.d.ts +49 -0
- package/types/mount.d.ts +33 -1
- package/types/utils/Types.d.ts +17 -11
- package/types/utils/index.d.ts +7 -3
- package/types/utils/loadAppConfig.d.ts +17 -0
- package/types/utils/loadUploadConfig.d.ts +20 -0
- package/types/middlewares/Authentication.d.ts +0 -52
- package/types/middlewares/CORS.d.ts +0 -30
- package/types/middlewares/ErrorHandler.d.ts +0 -34
- package/types/middlewares/Global.d.ts +0 -27
- package/types/middlewares/Http.d.ts +0 -29
- package/types/middlewares/Local.d.ts +0 -42
- package/types/middlewares/View.d.ts +0 -49
- package/types/routing/index.d.ts +0 -37
- package/types/utils/loadBasicConfig.d.ts +0 -17
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,79 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
|
|
5
|
+
## [Unreleased]
|
|
6
|
+
|
|
7
|
+
### Breaking Changes
|
|
8
|
+
|
|
9
|
+
**Middleware Architecture Refactoring**
|
|
10
|
+
- All middleware components have been refactored from class-based to function-based architecture
|
|
11
|
+
- Middleware naming updated to follow Express.js conventions (2-word composition pattern)
|
|
12
|
+
|
|
13
|
+
**Middleware Name Changes:**
|
|
14
|
+
| Previous (Class-based) | Current (Function-based) |
|
|
15
|
+
|------------------------|--------------------------|
|
|
16
|
+
| `CORS` | `corsPolicy` |
|
|
17
|
+
| `Environment` | `envLoader` |
|
|
18
|
+
| `ErrorHandler` | `errorHandler` |
|
|
19
|
+
| `Http` | `requestParser` |
|
|
20
|
+
| `Local` | `localVars` |
|
|
21
|
+
| `Router` | `routeMapper` |
|
|
22
|
+
| `View` | `viewEngine` |
|
|
23
|
+
| `Authentication` | `passportAuth` |
|
|
24
|
+
| `Global` | `globalVars` |
|
|
25
|
+
|
|
26
|
+
**Migration Notes:**
|
|
27
|
+
- These are internal changes and do not affect the public API
|
|
28
|
+
- The `mount()` function handles all middleware automatically
|
|
29
|
+
- No changes required in application code for standard usage
|
|
30
|
+
|
|
31
|
+
**Express 5 Migration**
|
|
32
|
+
- **Requires Node.js 18.x or higher**
|
|
33
|
+
- Upgraded from Express 4.21.2 to Express 5.2.1
|
|
34
|
+
- Note: `express-handlebars` remains at v7.1.3 to maintain Node.js 18+ compatibility (v8 requires Node.js 20+)
|
|
35
|
+
- Route patterns with regex parameters no longer support `/:param(\\d+)` syntax
|
|
36
|
+
- Use RegExp with named capture groups instead: `/^\/(?<userId>\d+)$/`
|
|
37
|
+
- See migration example in Changed section below
|
|
38
|
+
- For more details on Express 5 changes, see:
|
|
39
|
+
- [Express 5 Migration Guide](https://expressjs.com/en/guide/migrating-5.html)
|
|
40
|
+
- [Express.js Release Notes](https://expressjs.com/en/changelog/)
|
|
41
|
+
|
|
42
|
+
### Added
|
|
43
|
+
|
|
44
|
+
**File Upload Support (Multer)**
|
|
45
|
+
- Added dynamic file upload middleware using Multer
|
|
46
|
+
- New `config/upload.js` configuration file for flexible upload handling
|
|
47
|
+
- Support for single file, multiple files (array), and multiple field uploads
|
|
48
|
+
- Both memory storage and disk storage options
|
|
49
|
+
- Request-based middleware resolution for route-specific upload configurations
|
|
50
|
+
- Sample configurations added:
|
|
51
|
+
- [ESM Configuration](configuration_sample/esm/upload.js)
|
|
52
|
+
- [CJS Configuration](configuration_sample/cjs/upload.js)
|
|
53
|
+
|
|
54
|
+
### Changed
|
|
55
|
+
|
|
56
|
+
**Express 5 Compatibility Updates**
|
|
57
|
+
- Added `query parser: 'extended'` setting in HTTP middleware to maintain Express 4 behavior for nested query objects
|
|
58
|
+
- Added `multer().none()` middleware to parse `multipart/form-data` requests without files
|
|
59
|
+
|
|
60
|
+
**Route Pattern Migration Example**
|
|
61
|
+
```js
|
|
62
|
+
// Before (Express 4)
|
|
63
|
+
router.get('/:userId(\\d+)', (req, res) => {
|
|
64
|
+
const userId = req.params.userId; // Works
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
// After (Express 5)
|
|
68
|
+
router.get(/^\/(?<userId>\d+)$/, (req, res) => {
|
|
69
|
+
const userId = req.params.userId; // Works with named capture group
|
|
70
|
+
});
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### Fixed
|
|
74
|
+
|
|
75
|
+
- Fixed `ERR_INVALID_URL` error when invalid Host header values are provided
|
|
76
|
+
- `baseUrl` is now set to `undefined` when URL construction fails, allowing graceful error handling via `rewrite_base_url` hook or template checks
|
|
77
|
+
|
|
5
78
|
## [3.0.2] - 2025-11-28
|
|
6
79
|
|
|
7
80
|
### Changed
|
|
@@ -14,12 +87,7 @@ All notable changes to this project will be documented in this file.
|
|
|
14
87
|
- Added explicit handling for OPTIONS preflight requests
|
|
15
88
|
|
|
16
89
|
**Demo Improvements**
|
|
17
|
-
- Reorganized demo structure into separate `web-app` and `rest-api` directories
|
|
18
90
|
- 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
91
|
|
|
24
92
|
## [3.0.1] - 2025-09-02
|
|
25
93
|
|
|
@@ -118,7 +186,7 @@ const db = await expx.database.DatabaseManager.getInstance();
|
|
|
118
186
|
|
|
119
187
|
### Fixed
|
|
120
188
|
|
|
121
|
-
- Fixed a bug that caused redirection to fail when
|
|
189
|
+
- Fixed a bug that caused logout redirection to fail when the redirect URL contained query parameters.
|
|
122
190
|
|
|
123
191
|
## [2.0.5] - 2025-02-04
|
|
124
192
|
|
|
@@ -168,31 +236,16 @@ const db = await expx.database.DatabaseManager.getInstance();
|
|
|
168
236
|
|
|
169
237
|
## [2.0.3] - 2024-09-03
|
|
170
238
|
|
|
171
|
-
|
|
239
|
+
> **Note:** This version used class-based middleware with names like `CORS`, `Environment`, `ErrorHandler`, `Http`, `Local`, `Router`, `View`, and `Authentication`. In v3.x and later, these were refactored to function-based middleware with new names (`corsPolicy`, `envLoader`, `errorHandler`, `requestParser`, `localVars`, `routeMapper`, `viewEngine`, `passportAuth`). The items listed below reflect the naming and structure used in v2.0.3.
|
|
172
240
|
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
241
|
+
### Breaking Changes
|
|
242
|
+
|
|
243
|
+
**Template Engine Migration**
|
|
244
|
+
- Template engine changed from `express-hbs` to `express-handlebars`.
|
|
245
|
+
However, the `block` and `contentFor` helpers are still available for backward compatibility.
|
|
246
|
+
|
|
247
|
+
**Database Layer Changes**
|
|
177
248
|
- `database/Database` has been changed from a `sequelize.Sequelize` instance to a `sequelize.Sequelize` class. If you use it in the future, you need to instantiate it.
|
|
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
249
|
- DB connection check method has been changed.
|
|
197
250
|
- After:
|
|
198
251
|
```js
|
|
@@ -212,6 +265,14 @@ const db = await expx.database.DatabaseManager.getInstance();
|
|
|
212
265
|
// Check database connection.
|
|
213
266
|
await expx.database.Database.isConnect();
|
|
214
267
|
```
|
|
268
|
+
|
|
269
|
+
**Async Function Signature Changes**
|
|
270
|
+
- All middleware mount methods, configuration loaders, authentication services, and database initialization functions now return `Promise` types instead of synchronous return types. This change enables asynchronous configuration loading and proper async/await usage throughout the framework.
|
|
271
|
+
|
|
272
|
+
### Changed
|
|
273
|
+
|
|
274
|
+
- Added `"type": "module"` to the `package.json` of the ESM app generated by `express-sweet-generator`. It is now fully ESM compliant.
|
|
275
|
+
- `require` was changed to dynamic import.
|
|
215
276
|
- Updated passport from 0.4.1 to 0.7.0
|
|
216
277
|
|
|
217
278
|
## [2.0.2] - 2024-09-01
|
|
@@ -231,19 +292,17 @@ const db = await expx.database.DatabaseManager.getInstance();
|
|
|
231
292
|
|
|
232
293
|
## [2.0.0] - 2024-03-24
|
|
233
294
|
|
|
234
|
-
###
|
|
295
|
+
### Breaking Changes
|
|
235
296
|
|
|
236
|
-
|
|
297
|
+
**AWS SDK Removal**
|
|
298
|
+
- EXPRESS SWEET version 2 no longer depends on the AWS SDK.
|
|
237
299
|
The `services.AWSRekognitionClient` and `services.AWSSesClient` have been migrated to the [AWS SDK Extension](https://www.npmjs.com/package/aws-sdk-extension) NPM package, so please install from there if needed.
|
|
238
300
|
|
|
239
301
|
## [1.1.1] - 2024-03-23
|
|
240
302
|
|
|
241
303
|
### Changed
|
|
242
304
|
|
|
243
|
-
- When cookie security is enabled
|
|
244
|
-
```bash
|
|
245
|
-
Warning: Cookie security must be disabled for user authentication to work over the HTTP protocol (config/authentication.js#cookie_secure)
|
|
246
|
-
```
|
|
305
|
+
- When cookie security is enabled and the application runs over HTTP, a warning message is now displayed during user authentication to prevent authentication issues caused by secure cookie settings incompatible with the HTTP protocol.
|
|
247
306
|
|
|
248
307
|
## [1.1.0] - 2024-03-06
|
|
249
308
|
|
|
@@ -261,13 +320,13 @@ const db = await expx.database.DatabaseManager.getInstance();
|
|
|
261
320
|
|
|
262
321
|
### Changed
|
|
263
322
|
|
|
264
|
-
- The `Secure` and `HttpOnly` attributes of
|
|
323
|
+
- The `Secure` and `HttpOnly` attributes of session cookies can now be configured through the authentication configuration file.
|
|
265
324
|
|
|
266
325
|
## [1.0.43] - 2023-12-30
|
|
267
326
|
|
|
268
327
|
### Changed
|
|
269
328
|
|
|
270
|
-
-
|
|
329
|
+
- Session cookie name is now configurable through the authentication configuration file.
|
|
271
330
|
|
|
272
331
|
## [1.0.42] - 2023-08-31
|
|
273
332
|
|
|
@@ -297,86 +356,19 @@ const db = await expx.database.DatabaseManager.getInstance();
|
|
|
297
356
|
|
|
298
357
|
### Changed
|
|
299
358
|
|
|
300
|
-
-
|
|
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>
|
|
359
|
+
- Renamed AWS Rekognition exception classes to more descriptive names. All face-related error classes now follow a consistent naming pattern with "Face" prefix and "Failed"/"Missing"/"Multiple" suffixes for better clarity and error handling.
|
|
368
360
|
|
|
369
361
|
## [1.0.38] - 2023-07-17
|
|
370
362
|
|
|
371
363
|
### Fixed
|
|
372
364
|
|
|
373
|
-
- Fixed a bug that login user data
|
|
365
|
+
- Fixed a bug that prevented login user data from being referenced in the view rendering hook function.
|
|
374
366
|
|
|
375
367
|
## [1.0.37] - 2023-07-17
|
|
376
368
|
|
|
377
369
|
### Changed
|
|
378
370
|
|
|
379
|
-
- The
|
|
371
|
+
- The view rendering hook function now supports asynchronous functions for async operations before rendering.
|
|
380
372
|
|
|
381
373
|
### Added
|
|
382
374
|
|
|
@@ -386,15 +378,15 @@ const db = await expx.database.DatabaseManager.getInstance();
|
|
|
386
378
|
|
|
387
379
|
### Changed
|
|
388
380
|
|
|
389
|
-
- Moved the Ajax determination option (is_ajax)
|
|
390
|
-
- The error
|
|
381
|
+
- Moved the Ajax determination option (`is_ajax`) from authentication configuration to application configuration.
|
|
382
|
+
- The error handler option has been replaced with a hookable error handling mechanism (`hook_handle_error`) for more flexible error processing.
|
|
391
383
|
|
|
392
384
|
## [1.0.35] - 2023-07-11
|
|
393
385
|
|
|
394
386
|
### Changed
|
|
395
387
|
|
|
396
|
-
- The
|
|
397
|
-
-
|
|
388
|
+
- The login failure redirect URL option can now be defined as a function for dynamic redirect behavior.
|
|
389
|
+
- Authentication service's `failureRedirect` method signature changed to accept both request and response objects instead of response only.
|
|
398
390
|
|
|
399
391
|
## [1.0.34] - 2023-07-01
|
|
400
392
|
|
|
@@ -412,7 +404,7 @@ const db = await expx.database.DatabaseManager.getInstance();
|
|
|
412
404
|
|
|
413
405
|
### Fixed
|
|
414
406
|
|
|
415
|
-
- Fixed a bug that
|
|
407
|
+
- Fixed a bug that prevented cookies from being accessed in the view rendering hook function.
|
|
416
408
|
|
|
417
409
|
## [1.0.31] - 2023-06-29
|
|
418
410
|
|
|
@@ -458,17 +450,17 @@ const db = await expx.database.DatabaseManager.getInstance();
|
|
|
458
450
|
|
|
459
451
|
### Changed
|
|
460
452
|
|
|
461
|
-
-
|
|
453
|
+
- The view rendering hook function now receives the request object as an argument for accessing request data during rendering.
|
|
462
454
|
|
|
463
455
|
## [1.0.26] - 2023-06-11
|
|
464
456
|
|
|
465
457
|
### Changed
|
|
466
458
|
|
|
467
459
|
- Updated Sequelize from v5 to v6.
|
|
468
|
-
- Changed the framework debug log to output only when the environment variable
|
|
460
|
+
- Changed the framework debug log to output only when the environment variable SWEET_DEBUG is defined.
|
|
469
461
|
.env:
|
|
470
462
|
```
|
|
471
|
-
|
|
463
|
+
SWEET_DEBUG=true
|
|
472
464
|
```
|
|
473
465
|
|
|
474
466
|
## [1.0.25] - 2022-11-24
|
|
@@ -481,7 +473,7 @@ const db = await expx.database.DatabaseManager.getInstance();
|
|
|
481
473
|
|
|
482
474
|
### Added
|
|
483
475
|
|
|
484
|
-
- Added
|
|
476
|
+
- Added Ajax request detection option to authentication configuration for custom XHR/fetch request handling.
|
|
485
477
|
|
|
486
478
|
## [1.0.23] - 2022-10-20
|
|
487
479
|
|
|
@@ -540,7 +532,7 @@ const db = await expx.database.DatabaseManager.getInstance();
|
|
|
540
532
|
|
|
541
533
|
### Changed
|
|
542
534
|
|
|
543
|
-
-
|
|
535
|
+
- The unauthenticated route pattern option now accepts both string and RegExp patterns for more flexible route matching.
|
|
544
536
|
|
|
545
537
|
## [1.0.14] - 2022-01-17
|
|
546
538
|
|
|
@@ -722,4 +714,6 @@ const db = await expx.database.DatabaseManager.getInstance();
|
|
|
722
714
|
[2.0.8]: https://github.com/takuya-motoshima/express-sweet/compare/v2.0.7...v2.0.8
|
|
723
715
|
[2.0.9]: https://github.com/takuya-motoshima/express-sweet/compare/v2.0.8...v2.0.9
|
|
724
716
|
[3.0.0]: https://github.com/takuya-motoshima/express-sweet/compare/v2.0.9...v3.0.0
|
|
725
|
-
[3.0.1]: https://github.com/takuya-motoshima/express-sweet/compare/v3.0.0...v3.0.1
|
|
717
|
+
[3.0.1]: https://github.com/takuya-motoshima/express-sweet/compare/v3.0.0...v3.0.1
|
|
718
|
+
[3.0.2]: https://github.com/takuya-motoshima/express-sweet/compare/v3.0.1...v3.0.2
|
|
719
|
+
[Unreleased]: https://github.com/takuya-motoshima/express-sweet/compare/v3.0.2...HEAD
|