express-sweet 2.0.0 → 2.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 +21 -451
- package/README.md +11 -33
- package/dist/build.cjs +151 -0
- package/dist/build.mjs +151 -0
- package/package.json +25 -26
- package/types/database/Database.d.ts +48 -48
- package/types/database/loadModels.d.ts +2 -1
- package/types/handlebars_helpers/comparison.d.ts +18 -18
- package/types/handlebars_helpers/date.d.ts +1 -1
- package/types/handlebars_helpers/html.d.ts +1 -1
- package/types/handlebars_helpers/math.d.ts +7 -7
- package/types/handlebars_helpers/number.d.ts +1 -1
- package/types/handlebars_helpers/object.d.ts +2 -2
- package/types/handlebars_helpers/string.d.ts +3 -3
- package/types/index.d.ts +0 -1
- package/types/interfaces/AuthenticationConfig.d.ts +0 -1
- package/types/interfaces/BasicConfig.d.ts +0 -1
- package/types/interfaces/ViewConfig.d.ts +0 -1
- package/types/mount.d.ts +2 -1
- package/types/services/Authentication.d.ts +0 -1
- package/types/types/global.d.ts +17 -0
- package/dist/build.common.js +0 -387
- package/dist/build.esm.js +0 -387
- package/types/exceptions/FaceCollectionCreateFailed.d.ts +0 -25
- package/types/exceptions/FaceCollectionDeleteFailed.d.ts +0 -25
- package/types/exceptions/FaceIndexFailed.d.ts +0 -20
- package/types/exceptions/FaceMissingInPhoto.d.ts +0 -11
- package/types/exceptions/FacesMultipleInPhoto.d.ts +0 -11
- package/types/exceptions/index.d.ts +0 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,17 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
All notable changes to this project will be documented in this file.
|
|
3
3
|
|
|
4
|
+
## [2.0.2] - 2024/9/1
|
|
5
|
+
### Changed
|
|
6
|
+
- Update express from 4.18.3 to 4.19.2.
|
|
7
|
+
- Update rollup from 2.79.1 to 4.21.2.
|
|
8
|
+
- Rename build files (build.common.js => build.cjs, build.esm.js => build.mjs).
|
|
9
|
+
- The express package was excluded from the build file. Instead, users should install express on their own.
|
|
10
|
+
|
|
11
|
+
## [2.0.1] - 2024/4/5
|
|
12
|
+
### Changed
|
|
13
|
+
- Removed [nodejs-shared](https://www.npmjs.com/package/nodejs-shared) package dependency.
|
|
14
|
+
|
|
4
15
|
## [2.0.0] - 2024/3/24
|
|
5
16
|
### Changed
|
|
6
17
|
- Express Sweet version 2 no longer depends on the AWS SDK.
|
|
@@ -22,46 +33,15 @@ All notable changes to this project will be documented in this file.
|
|
|
22
33
|
- [sequelize](https://www.npmjs.com/package/sequelize) from v6.32.0 to v6.37.1
|
|
23
34
|
- [mariadb](https://www.npmjs.com/package/mariadb) from v2.4.0 to v3.2.3
|
|
24
35
|
- [moment](https://www.npmjs.com/package/moment) from v2.29.4 to v2.30.1
|
|
25
|
-
- Update [metronic-extension](https://www.npmjs.com/package/metronic-extension) of the demo from v1.0.1 to v3.0.9.
|
|
26
|
-
|
|
27
|
-
### Added
|
|
28
|
-
- Demo (./demo) Docker environment added. See [here](demo/README.md) for details.
|
|
29
36
|
|
|
30
37
|
## [1.0.44] - 2023/12/30
|
|
31
38
|
### Changed
|
|
32
39
|
- The `Secure` and `HttpOnly` attributes of the session cookie can now be set from the authentication configuration file (`config/authentication.js`).
|
|
33
40
|
|
|
34
|
-
config/authentication.js:
|
|
35
|
-
```js
|
|
36
|
-
/**
|
|
37
|
-
* Specifies the boolean value for the Secure Set-Cookie attribute.
|
|
38
|
-
* The default is true, which sets the Secure attribute on the cookie.
|
|
39
|
-
* @type {boolean|undefined}
|
|
40
|
-
*/
|
|
41
|
-
cookie_secure: true,
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Specifies the boolean value for the HttpOnly Set-Cookie attribute.
|
|
45
|
-
* Defaults to true, which sets the HttpOnly attribute on the cookie.
|
|
46
|
-
* @type {boolean|undefined}
|
|
47
|
-
*/
|
|
48
|
-
cookie_httpOnly: true,
|
|
49
|
-
```
|
|
50
|
-
|
|
51
41
|
## [1.0.43] - 2023/12/30
|
|
52
42
|
### Changed
|
|
53
43
|
- The cookie name for storing session IDs can now be set in the `cookie_name` field of the authentication configuration file (`config/authentication.js`).
|
|
54
44
|
|
|
55
|
-
config/authentication.js:
|
|
56
|
-
```js
|
|
57
|
-
/**
|
|
58
|
-
* The name of the session ID cookie to set in the response (and read from in the request).
|
|
59
|
-
* The default value is 'connect.sid'.
|
|
60
|
-
* @type {string|undefined}
|
|
61
|
-
*/
|
|
62
|
-
cookie_name: 'connect.sid'
|
|
63
|
-
```
|
|
64
|
-
|
|
65
45
|
## [1.0.42] - 2023/8/31
|
|
66
46
|
### Changed
|
|
67
47
|
- Update TypeScript version from 4.8.4 to 5.2.2.
|
|
@@ -75,56 +55,6 @@ All notable changes to this project will be documented in this file.
|
|
|
75
55
|
## [1.0.41] - 2023/8/4
|
|
76
56
|
### Changed
|
|
77
57
|
- 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.
|
|
78
|
-
<table>
|
|
79
|
-
<thead>
|
|
80
|
-
<tr>
|
|
81
|
-
<th>Option</th>
|
|
82
|
-
<th>Type</th>
|
|
83
|
-
<th>Description</th>
|
|
84
|
-
</tr>
|
|
85
|
-
</thead>
|
|
86
|
-
<tbody>
|
|
87
|
-
<tr>
|
|
88
|
-
<td>throwNotFoundFaceException</td>
|
|
89
|
-
<td>boolean</td>
|
|
90
|
-
<td>If true, throws a <code>FaceMissingInPhoto</code> exception when a face is not found in the image; if false, returns null. Default is false.</td>
|
|
91
|
-
</tr>
|
|
92
|
-
<tr>
|
|
93
|
-
<td>throwTooManyFaceException</td>
|
|
94
|
-
<td>boolean</td>
|
|
95
|
-
<td>If true, throws a <code>FacesMultipleInPhoto</code> exception when more than one face is found in the image. Default is false.</td>
|
|
96
|
-
</tr>
|
|
97
|
-
</tbody>
|
|
98
|
-
</table>
|
|
99
|
-
|
|
100
|
-
Example:
|
|
101
|
-
```js
|
|
102
|
-
const {services: {AWSRekognitionClient}, exceptions: {FaceMissingInPhoto, FacesMultipleInPhoto}} = require('express-sweet');
|
|
103
|
-
|
|
104
|
-
// Rekognition Client.
|
|
105
|
-
const client = new AWSRekognitionClient({
|
|
106
|
-
accessKeyId: 'your AWS access key ID',
|
|
107
|
-
secretAccessKey: 'your AWS secret access key',
|
|
108
|
-
region: 'the region to send service requests to',
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
// Find a face in the collection.
|
|
112
|
-
const collectionId = 'MyCollection';
|
|
113
|
-
|
|
114
|
-
try {
|
|
115
|
-
await client.searchFaces(collectionId, 'face.jpg', {
|
|
116
|
-
throwNotFoundFaceException: true,
|
|
117
|
-
throwTooManyFaceException: true,
|
|
118
|
-
});
|
|
119
|
-
} catch (err) {
|
|
120
|
-
if (err instanceof FaceMissingInPhoto)
|
|
121
|
-
console.log('No face was found');
|
|
122
|
-
else if (err instanceof FacesMultipleInPhoto)
|
|
123
|
-
console.log('Multiple faces were found');
|
|
124
|
-
else
|
|
125
|
-
console.log('Other errors');
|
|
126
|
-
}
|
|
127
|
-
```
|
|
128
58
|
|
|
129
59
|
## [1.0.40] - 2023/8/4
|
|
130
60
|
### Changed
|
|
@@ -211,76 +141,16 @@ All notable changes to this project will be documented in this file.
|
|
|
211
141
|
|
|
212
142
|
### Added
|
|
213
143
|
- New Math-related view helpers have been added.
|
|
214
|
-
|Helper|Description|
|
|
215
|
-
|--|--|
|
|
216
|
-
|add|Calculates the sum of two numbers.|
|
|
217
|
-
|sub|Calculates the difference of the given values.|
|
|
218
|
-
|multiply|Calculate the multiplication of the given values.|
|
|
219
|
-
|divide|Compute the division of the given values.|
|
|
220
|
-
|ceil|Round up the value.|
|
|
221
|
-
|floor|Rounds down a number.|
|
|
222
|
-
|abs|Returns an absolute value.|
|
|
223
144
|
|
|
224
145
|
## [1.0.36] - 2023/7/12
|
|
225
146
|
### Changed
|
|
226
147
|
- Moved the Ajax determination option (is_ajax) in the authentication configuration (config/authentication.js) to the basic configuration (config/config.js).
|
|
227
|
-
|
|
228
|
-
config/config.js:
|
|
229
|
-
```js
|
|
230
|
-
is_ajax: req => {
|
|
231
|
-
// If the request URL begins with /api, it is assumed to be Ajax.
|
|
232
|
-
return /^\/api/.test(req.path);
|
|
233
|
-
// return !!req.xhr;
|
|
234
|
-
}
|
|
235
|
-
```
|
|
236
|
-
- 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.
|
|
237
|
-
|
|
238
|
-
config/config.js:
|
|
239
|
-
```js
|
|
240
|
-
hook_handle_error: (err, req, res, next) => {
|
|
241
|
-
if (err.status === 404)
|
|
242
|
-
// If the URL cannot be found, a 404 error screen (views/error-404.hbs) is displayed.
|
|
243
|
-
res.render('error-404');
|
|
244
|
-
else
|
|
245
|
-
// For other errors, unknown error screen (views/error-unknown.hbs) is displayed.
|
|
246
|
-
res.render('error-unknown');
|
|
247
|
-
}
|
|
248
|
-
```
|
|
148
|
+
- 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.
|
|
249
149
|
|
|
250
150
|
## [1.0.35] - 2023/7/11
|
|
251
151
|
### Changed
|
|
252
152
|
- 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.
|
|
253
|
-
|
|
254
|
-
config/authentication.js:
|
|
255
|
-
```js
|
|
256
|
-
// Set the URL to redirect to in case of login failure as a string.
|
|
257
|
-
failure_redirect: '/login',
|
|
258
|
-
|
|
259
|
-
// Dynamically set the url to redirect to on login failure.
|
|
260
|
-
failure_redirect: (req, res) => {
|
|
261
|
-
// If the role stored in the cookie is admin, redirect to the admin login screen.
|
|
262
|
-
return req.cookies.role === 'admin' ? '/adminlogin' : 'login';
|
|
263
|
-
},
|
|
264
|
-
```
|
|
265
|
-
- The arguments of the failureRedirect method of the authentication service class (services/Authentication) have changed.
|
|
266
|
-
The argument to the Authentication.failureRedirect method used to be just express.Response, but now it requires express.Request and express.Response.
|
|
267
|
-
|
|
268
|
-
Example of login routes:
|
|
269
|
-
```js
|
|
270
|
-
import {Router} from 'express';
|
|
271
|
-
import * as sweet from 'express-sweet';
|
|
272
|
-
const router = Router();
|
|
273
|
-
const Authentication = sweet.services.Authentication;
|
|
274
|
-
|
|
275
|
-
router.post('/login', async (req, res, next) => {
|
|
276
|
-
const isAuth = await Authentication.authenticate(req, res, next);
|
|
277
|
-
if (isAuth)
|
|
278
|
-
Authentication.successRedirect(res);
|
|
279
|
-
else
|
|
280
|
-
Authentication.failureRedirect(req, res);
|
|
281
|
-
});
|
|
282
|
-
export default router;
|
|
283
|
-
```
|
|
153
|
+
- 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.
|
|
284
154
|
|
|
285
155
|
## [1.0.34] - 2023/7/1
|
|
286
156
|
### Changed
|
|
@@ -289,27 +159,6 @@ All notable changes to this project will be documented in this file.
|
|
|
289
159
|
## [1.0.33] - 2023/7/1
|
|
290
160
|
### Added
|
|
291
161
|
- Added regular expression comparison view helper.
|
|
292
|
-
```html
|
|
293
|
-
{{!-- results in: true --}}
|
|
294
|
-
{{regexMatch 'foobar' 'foo'}}
|
|
295
|
-
|
|
296
|
-
{{!-- results in: false --}}
|
|
297
|
-
{{regexMatch 'bar' 'foo'}}
|
|
298
|
-
|
|
299
|
-
{{!-- results in: false --}}
|
|
300
|
-
{{regexMatch 'foobar' '^foo$'}}
|
|
301
|
-
|
|
302
|
-
{{!-- results in: true --}}
|
|
303
|
-
{{regexMatch 'Visit Here' 'here' 'i'}}
|
|
304
|
-
|
|
305
|
-
{{!-- results in: false --}}
|
|
306
|
-
{{regexMatch 'Visit Here' 'here'}}
|
|
307
|
-
|
|
308
|
-
{{!-- results in: Match --}}
|
|
309
|
-
{{#if (regexMatch 'foobar' 'foo')}}
|
|
310
|
-
Match
|
|
311
|
-
{{/if}}
|
|
312
|
-
```
|
|
313
162
|
|
|
314
163
|
## [1.0.32] - 2023/7/1
|
|
315
164
|
### Fixed
|
|
@@ -329,14 +178,6 @@ All notable changes to this project will be documented in this file.
|
|
|
329
178
|
|
|
330
179
|
### Added
|
|
331
180
|
- Added view helper to convert numeric values to strings with language-sensitive representations.
|
|
332
|
-
```html
|
|
333
|
-
{{!-- results in: 123,456.789 --}}
|
|
334
|
-
{{number2locale 123456.789}}
|
|
335
|
-
|
|
336
|
-
{{!-- German uses comma as decimal separator and period for thousands. --}}
|
|
337
|
-
{{!-- results in: 123.456,789 --}}
|
|
338
|
-
{{number2locale 123456.789 'de-DE'}}
|
|
339
|
-
```
|
|
340
181
|
|
|
341
182
|
## [1.0.30] - 2023/6/26
|
|
342
183
|
### Changed
|
|
@@ -348,81 +189,15 @@ All notable changes to this project will be documented in this file.
|
|
|
348
189
|
|
|
349
190
|
### Added
|
|
350
191
|
- Added AWS SES email sending client class.
|
|
351
|
-
```js
|
|
352
|
-
const sweet = require('express-sweet');
|
|
353
|
-
|
|
354
|
-
// SES Client.
|
|
355
|
-
const client = new sweet.services.AWSSesClient({
|
|
356
|
-
apiVersion: 'API Version ("YYYYY-MM-DD" or "latest")',
|
|
357
|
-
region: 'the region to send service requests to',
|
|
358
|
-
accessKeyId: 'your AWS access key ID',
|
|
359
|
-
secretAccessKey: 'your AWS secret access key',
|
|
360
|
-
});
|
|
361
|
-
|
|
362
|
-
// Send an email from "test<from@example.com>" to "to@example.com".
|
|
363
|
-
await client
|
|
364
|
-
.from('from@example.com', 'Sender Name')
|
|
365
|
-
.to('to@example.com')
|
|
366
|
-
.subject('Test email')
|
|
367
|
-
.body('Hi, this is a test email')
|
|
368
|
-
.send();
|
|
369
|
-
|
|
370
|
-
// Use variables in the body of the e-mail.
|
|
371
|
-
// The body can use the handlebars and handlebars-extd syntax.
|
|
372
|
-
await client
|
|
373
|
-
.from('from@example.com', 'Sender Name')
|
|
374
|
-
.to('to@example.com')
|
|
375
|
-
.subject('Test email')
|
|
376
|
-
.body('Hello {{name}}', {name: 'Mason'})
|
|
377
|
-
.send();
|
|
378
|
-
```
|
|
379
192
|
|
|
380
193
|
## [1.0.28] - 2023/6/16
|
|
381
194
|
### Changed
|
|
382
195
|
- Updated AWS SDK version from 2 to 3.
|
|
383
|
-
Unit test results:
|
|
384
|
-
```sh
|
|
385
|
-
npm run test
|
|
386
|
-
|
|
387
|
-
> express-sweet@1.0.25 test
|
|
388
|
-
> jest
|
|
389
|
-
|
|
390
|
-
PASS __tests__/AWSRekognitionClient.test.js (8.773 s)
|
|
391
|
-
? Should detect one person from the image (448 ms)
|
|
392
|
-
? Should be able to get facial details (532 ms)
|
|
393
|
-
? Should detect three persons from the image (589 ms)
|
|
394
|
-
? The two faces should be the same person (131 ms)
|
|
395
|
-
? The two faces should be different people (213 ms)
|
|
396
|
-
? Should be able to create collections (98 ms)
|
|
397
|
-
? Should index faces in the collection (242 ms)
|
|
398
|
-
? Should return the details of the indexed face (346 ms)
|
|
399
|
-
? Should be able to find faces from the collection (153 ms)
|
|
400
|
-
? Should be able to find faces from the collection (132 ms)
|
|
401
|
-
? Should list indexed faces (27 ms)
|
|
402
|
-
? Should delete the face from the collection (53 ms)
|
|
403
|
-
? Collection should be deleted (62 ms)
|
|
404
|
-
|
|
405
|
-
Test Suites: 1 passed, 1 total
|
|
406
|
-
Tests: 13 passed, 13 total
|
|
407
|
-
Snapshots: 0 total
|
|
408
|
-
Time: 9.323 s
|
|
409
|
-
Ran all test suites.
|
|
410
|
-
```
|
|
411
196
|
|
|
412
197
|
## [1.0.27] - 2023/6/12
|
|
413
198
|
### Changed
|
|
414
199
|
- Request object has been added to the arguments of the beforeRender function in the view configuration (config/view.js).
|
|
415
200
|
|
|
416
|
-
express-sweet v1.0.27 or later (current):
|
|
417
|
-
```js
|
|
418
|
-
beforeRender: (req, res) => {}
|
|
419
|
-
```
|
|
420
|
-
|
|
421
|
-
express-sweet v1.0.26 or earlier:
|
|
422
|
-
```js
|
|
423
|
-
beforeRender: res => {}
|
|
424
|
-
```
|
|
425
|
-
|
|
426
201
|
## [1.0.26] - 2023/6/11
|
|
427
202
|
### Changed
|
|
428
203
|
- Update Sequelize from v5 to v6.
|
|
@@ -431,189 +206,41 @@ All notable changes to this project will be documented in this file.
|
|
|
431
206
|
```
|
|
432
207
|
EXPRESS_DEBUG=true
|
|
433
208
|
```
|
|
434
|
-
- A demo application was added [here](./demo).
|
|
435
209
|
|
|
436
210
|
## [1.0.25] - 2022/11/24
|
|
437
211
|
### Added
|
|
438
212
|
- Added formatBytes view helper to convert bytes to appropriate units.
|
|
439
|
-
```html
|
|
440
|
-
{{!-- results in: 1 KB --}}
|
|
441
|
-
{{formatBytes 1024}}
|
|
442
|
-
|
|
443
|
-
{{!-- results in: 1.21 KB --}}
|
|
444
|
-
{{formatBytes 1234 2}}
|
|
445
|
-
|
|
446
|
-
{{!-- results in: 1.205 KB --}}
|
|
447
|
-
{{formatBytes 1234 3}}
|
|
448
|
-
|
|
449
|
-
{{!-- results in: 0 Bytes --}}
|
|
450
|
-
{{formatBytes 0}}
|
|
451
|
-
```
|
|
452
213
|
|
|
453
214
|
## [1.0.24] - 2022/10/24
|
|
454
215
|
### Added
|
|
455
|
-
- Added is_ajax option to user authentication.
|
|
456
|
-
|
|
457
|
-
config/authentication.js:
|
|
458
|
-
```js
|
|
459
|
-
is_ajax: req => {
|
|
460
|
-
// If the request URL begins with /api, it is assumed to be Ajax.
|
|
461
|
-
return /^\/api/.test(req.path);
|
|
462
|
-
// return !!req.xhr;
|
|
463
|
-
}
|
|
464
|
-
```
|
|
216
|
+
- Added is_ajax option to user authentication (config/authentication.js).
|
|
465
217
|
|
|
466
218
|
## [1.0.23] - 2022/10/20
|
|
467
219
|
### Added
|
|
468
220
|
- A request body object has been added to the parameters of the callback function for user authentication.
|
|
469
221
|
|
|
470
|
-
config/authentication.js:
|
|
471
|
-
```js
|
|
472
|
-
authenticate_user: async (username, password, req) => {
|
|
473
|
-
const UserModel = require('../models/UserModel');
|
|
474
|
-
return UserModel.findOne({
|
|
475
|
-
where: {
|
|
476
|
-
email: username,
|
|
477
|
-
password
|
|
478
|
-
},
|
|
479
|
-
raw: true
|
|
480
|
-
});
|
|
481
|
-
}
|
|
482
|
-
```
|
|
483
|
-
|
|
484
222
|
## [1.0.22] - 2022/7/27
|
|
485
223
|
### Added
|
|
486
|
-
- You can now set hook functions that are called before the view is rendered.
|
|
487
|
-
Hook functions can be used, for example, to set local variables that can be used in the view.
|
|
488
|
-
|
|
489
|
-
To use, add the beforeRender hook function to "config/view.js" as follows.
|
|
490
|
-
```js
|
|
491
|
-
beforeRender: res => {
|
|
492
|
-
res.locals.extra = 'Extra';
|
|
493
|
-
}
|
|
494
|
-
```
|
|
224
|
+
- 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.
|
|
495
225
|
|
|
496
226
|
## [1.0.21] - 2022/526
|
|
497
227
|
### Added
|
|
498
228
|
- Added an option to the face indexing method to retrieve details (gender, emotion, age group) of indexed faces.
|
|
499
|
-
```js
|
|
500
|
-
const sweet = require('express-sweet');
|
|
501
|
-
|
|
502
|
-
// Rekognition Client.
|
|
503
|
-
const client = new sweet.services.AWSRekognitionClient({
|
|
504
|
-
accessKeyId: 'your AWS access key ID',
|
|
505
|
-
secretAccessKey: 'your AWS secret access key',
|
|
506
|
-
region: 'the region to send service requests to'
|
|
507
|
-
});
|
|
508
|
-
|
|
509
|
-
// Collection ID for testing.
|
|
510
|
-
const collectionId = 'MyCollection';
|
|
511
|
-
|
|
512
|
-
// Create a face and get the ID of the created face.
|
|
513
|
-
// results in: e65d66cb-e7bc-4bbf-966c-b1b49ddf29f8
|
|
514
|
-
const faceId = await client.indexFace(collectionId, 'face4.jpg');
|
|
515
|
-
console.log(faceId);
|
|
516
|
-
|
|
517
|
-
// Create a face and get the details of the created face.
|
|
518
|
-
// results in: {
|
|
519
|
-
// faceId: '7f2dd321-f047-44ff-8856-864637e1d286',
|
|
520
|
-
// ageRange: { high: 29, low: 21 },
|
|
521
|
-
// gender: 'female',
|
|
522
|
-
// emotions: {
|
|
523
|
-
// angry: 77.1907958984375,
|
|
524
|
-
// surprised: 9.944050788879395,
|
|
525
|
-
// fear: 7.514361381530762,
|
|
526
|
-
// confused: 4.780297756195068,
|
|
527
|
-
// sad: 2.91914963722229,
|
|
528
|
-
// happy: 2.5718722343444824,
|
|
529
|
-
// disgusted: 1.933768391609192,
|
|
530
|
-
// calm: 1.5354809761047363
|
|
531
|
-
// }
|
|
532
|
-
// }
|
|
533
|
-
const faceDetails = await client.indexFace(collectionId, 'face5.jpg', {returnDetails: true});
|
|
534
|
-
console.log(faceDetails);
|
|
535
|
-
```
|
|
536
229
|
|
|
537
230
|
## [1.0.20] - 2022/5/25
|
|
538
231
|
### Added
|
|
539
232
|
- Added an option to get details (emotion, gender, age group) to the face detection method.
|
|
540
|
-
```js
|
|
541
|
-
const sweet = require('express-sweet');
|
|
542
|
-
|
|
543
|
-
// Rekognition Client.
|
|
544
|
-
const client = new sweet.services.AWSRekognitionClient({
|
|
545
|
-
accessKeyId: 'your AWS access key ID',
|
|
546
|
-
secretAccessKey: 'your AWS secret access key',
|
|
547
|
-
region: 'the region to send service requests to'
|
|
548
|
-
});
|
|
549
|
-
|
|
550
|
-
(async () => {
|
|
551
|
-
// Detects bounding boxes on faces.
|
|
552
|
-
// results in: [
|
|
553
|
-
// {
|
|
554
|
-
// width: 0.3099822998046875,
|
|
555
|
-
// height: 0.661512017250061,
|
|
556
|
-
// left: 0.5449195504188538,
|
|
557
|
-
// top: 0.11531734466552734
|
|
558
|
-
// }
|
|
559
|
-
// ]
|
|
560
|
-
let res = await client.detectFaces('face.jpg');
|
|
561
|
-
console.log(res);
|
|
562
|
-
|
|
563
|
-
// Detect facial details.
|
|
564
|
-
// results in: [
|
|
565
|
-
// {
|
|
566
|
-
// boundingBox: {
|
|
567
|
-
// width: 0.3099822998046875,
|
|
568
|
-
// height: 0.661512017250061,
|
|
569
|
-
// left: 0.5449195504188538,
|
|
570
|
-
// top: 0.11531734466552734
|
|
571
|
-
// },
|
|
572
|
-
// ageRange: { high: 14, low: 6 },
|
|
573
|
-
// gender: 'female',
|
|
574
|
-
// emotions: {
|
|
575
|
-
// happy: 99.78905487060547,
|
|
576
|
-
// surprised: 6.306276321411133,
|
|
577
|
-
// fear: 5.880091190338135,
|
|
578
|
-
// sad: 2.152125835418701,
|
|
579
|
-
// confused: 0.023256277665495872,
|
|
580
|
-
// angry: 0.018351631239056587,
|
|
581
|
-
// calm: 0.015775982290506363,
|
|
582
|
-
// disgusted: 0.013914424926042557
|
|
583
|
-
// }
|
|
584
|
-
// }
|
|
585
|
-
// ]
|
|
586
|
-
const minConfidence = 90;
|
|
587
|
-
const withDetails = true;
|
|
588
|
-
res = await client.detectFaces('face.jpg', minConfidence, withDetails);
|
|
589
|
-
console.log(res);
|
|
590
|
-
})();
|
|
591
|
-
```
|
|
592
233
|
|
|
593
234
|
## [1.0.19] - 2022/5/20
|
|
594
235
|
### Added
|
|
595
236
|
- Add date format helper to view.
|
|
596
|
-
```html
|
|
597
|
-
{{!-- results in: 2021/10/24 --}}
|
|
598
|
-
{{formatDate 'YYYY/MM/DD' "2021-10-24T02:13:06.610Z"}}
|
|
599
|
-
|
|
600
|
-
{{!-- results in: 2021/10/24 --}}
|
|
601
|
-
{{formatDate 'YYYY/MM/DD' "2021-10-24T02:13:06.610Z" 'jp'}}
|
|
602
|
-
|
|
603
|
-
{{!-- results in: 2021/10/24 --}}
|
|
604
|
-
{{formatDate 'YYYY/MM/DD' "2021-10-24T02:13:06.610Z" 'es'}}
|
|
605
|
-
```
|
|
606
237
|
|
|
607
238
|
## [1.0.18] - 2022/5/18
|
|
608
239
|
### Added
|
|
609
|
-
- User authentication sessions can now be stored in redis.
|
|
610
|
-
To use redis for session storage, simply add the following option to config/authentication.js.
|
|
611
|
-
Please give it a try.
|
|
612
|
-
|
|
240
|
+
- 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.
|
|
613
241
|
config/authentication.js:
|
|
614
242
|
```json
|
|
615
|
-
session_store: '
|
|
616
|
-
// session_store: 'redis',
|
|
243
|
+
session_store: 'redis',
|
|
617
244
|
redis_host: 'redis://localhost:6379'
|
|
618
245
|
```
|
|
619
246
|
|
|
@@ -632,42 +259,6 @@ All notable changes to this project will be documented in this file.
|
|
|
632
259
|
## [1.0.14] - 2022/1/17
|
|
633
260
|
### Changed
|
|
634
261
|
- empty view helper can now check any type. Previously I could only check arrays.
|
|
635
|
-
```html
|
|
636
|
-
{{!-- results in: false --}}
|
|
637
|
-
{{empty [5, 6]}}
|
|
638
|
-
|
|
639
|
-
{{#if (empty 'foo')}}
|
|
640
|
-
Hello
|
|
641
|
-
{{/if}}
|
|
642
|
-
|
|
643
|
-
{{!-- results in: false --}}
|
|
644
|
-
{{empty 'Hello'}}
|
|
645
|
-
|
|
646
|
-
{{!-- results in: true --}}
|
|
647
|
-
{{empty ''}}
|
|
648
|
-
|
|
649
|
-
{{!-- results in: true --}}
|
|
650
|
-
{{empty value}}
|
|
651
|
-
```
|
|
652
|
-
|
|
653
|
-
- Added notEmpty view helper.
|
|
654
|
-
```html
|
|
655
|
-
{{!-- results in: true --}}
|
|
656
|
-
{{notEmpty [5, 6]}}
|
|
657
|
-
|
|
658
|
-
{{#if (notEmpty 'foo')}}
|
|
659
|
-
Hello
|
|
660
|
-
{{/if}}
|
|
661
|
-
|
|
662
|
-
{{!-- results in: true --}}
|
|
663
|
-
{{notEmpty 'Hello'}}
|
|
664
|
-
|
|
665
|
-
{{!-- results in: false --}}
|
|
666
|
-
{{notEmpty ''}}
|
|
667
|
-
|
|
668
|
-
{{!-- results in: false --}}
|
|
669
|
-
{{notEmpty ' '}}
|
|
670
|
-
```
|
|
671
262
|
|
|
672
263
|
## [1.0.13] - 2021/12/13
|
|
673
264
|
### Added
|
|
@@ -696,9 +287,7 @@ All notable changes to this project will be documented in this file.
|
|
|
696
287
|
|
|
697
288
|
## [1.0.12] - 2021/11/16
|
|
698
289
|
### Added
|
|
699
|
-
- Added a method to the model that can execute raw SQL.
|
|
700
|
-
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.
|
|
701
|
-
|
|
290
|
+
- 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.
|
|
702
291
|
```js
|
|
703
292
|
// By default the function will return two arguments - a results array, and an object containing metadata (such as amount of affected rows, etc).
|
|
704
293
|
// Note that since this is a raw query, the metadata are dialect specific.
|
|
@@ -717,27 +306,6 @@ All notable changes to this project will be documented in this file.
|
|
|
717
306
|
### Changed
|
|
718
307
|
- Added face similarity found to face search results in collection.
|
|
719
308
|
|
|
720
|
-
```js
|
|
721
|
-
import * as sweet from 'express-sweet';
|
|
722
|
-
|
|
723
|
-
// Find a face from the collection.
|
|
724
|
-
// results in: Face search results: [
|
|
725
|
-
// {
|
|
726
|
-
// faceId: '385e1b00-4ede-4219-a7b0-0b9cbe4953e5',
|
|
727
|
-
// boundingBox: {
|
|
728
|
-
// width: 0.3204210102558136,
|
|
729
|
-
// height: 1.0046900510787964,
|
|
730
|
-
// left: 0.39145898818969727,
|
|
731
|
-
// top: 0.07936319708824158
|
|
732
|
-
// },
|
|
733
|
-
// similarity: 99.98941802978516
|
|
734
|
-
// }
|
|
735
|
-
// ]
|
|
736
|
-
const collectionId = 'MyCollection';
|
|
737
|
-
const res = await client.searchFaces(collectionId, 'face.jpg');
|
|
738
|
-
console.log('Face search results:', res);
|
|
739
|
-
```
|
|
740
|
-
|
|
741
309
|
## [1.0.9] - 2021/10/13
|
|
742
310
|
### Changed
|
|
743
311
|
- Updated dependent package'sharp'from 0.25.4 to 0.29.1.
|
|
@@ -831,4 +399,6 @@ All notable changes to this project will be documented in this file.
|
|
|
831
399
|
[1.0.45]: https://github.com/takuya-motoshima/express-sweet/compare/v1.0.44...v1.0.45
|
|
832
400
|
[1.1.0]: https://github.com/takuya-motoshima/express-sweet/compare/v1.0.45...v1.1.0
|
|
833
401
|
[1.1.1]: https://github.com/takuya-motoshima/express-sweet/compare/v1.1.0...v1.1.1
|
|
834
|
-
[2.0.0]: https://github.com/takuya-motoshima/express-sweet/compare/v1.1.1...v2.0.0
|
|
402
|
+
[2.0.0]: https://github.com/takuya-motoshima/express-sweet/compare/v1.1.1...v2.0.0
|
|
403
|
+
[2.0.1]: https://github.com/takuya-motoshima/express-sweet/compare/v2.0.0...v2.0.1
|
|
404
|
+
[2.0.2]: https://github.com/takuya-motoshima/express-sweet/compare/v2.0.1...v2.0.2
|
package/README.md
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
#
|
|
1
|
+
# express-sweet
|
|
2
2
|
This is an extension of Express.
|
|
3
3
|
|
|
4
4
|
## Documentation
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
The API reference for previous versions can be found [here](https://takuya-motoshima.github.io/express-sweet/v1/).
|
|
5
|
+
- express-sweet V2 Documentation: [https://takuya-motoshima.github.io/express-sweet/v2/](https://takuya-motoshima.github.io/express-sweet/v2/)
|
|
6
|
+
- express-sweet V1 documentation: [https://takuya-motoshima.github.io/express-sweet/v1/](https://takuya-motoshima.github.io/express-sweet/v1/)
|
|
8
7
|
|
|
9
8
|
## Quick Start
|
|
10
9
|
See [here](QUICK_START.md).
|
|
@@ -15,37 +14,16 @@ See [here](demo/README.md).
|
|
|
15
14
|
## Release Notes
|
|
16
15
|
All changes can be found [here](CHANGELOG.md).
|
|
17
16
|
|
|
18
|
-
- ### [2.0.
|
|
17
|
+
- ### [2.0.2] - 2024/9/1
|
|
19
18
|
#### Changed
|
|
20
|
-
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
-
|
|
19
|
+
- Update express from 4.18.3 to 4.19.2.
|
|
20
|
+
- Update rollup from 2.79.1 to 4.21.2.
|
|
21
|
+
- Rename build files (build.common.js => build.cjs, build.esm.js => build.mjs).
|
|
22
|
+
- The express package was excluded from the build file. Instead, users should install express on their own.
|
|
23
|
+
- ### [2.0.1] - 2024/4/5
|
|
24
24
|
#### Changed
|
|
25
|
-
-
|
|
26
|
-
|
|
27
|
-
Warning: Cookie security must be disabled for user authentication to work over the HTTP protocol (config/authentication.js#cookie_secure)
|
|
28
|
-
```
|
|
29
|
-
- ### [1.1.0] - 2024/3/6
|
|
30
|
-
#### Changed
|
|
31
|
-
- Updated Express Sweet's dependency packages.
|
|
32
|
-
- [express](https://www.npmjs.com/package/express) from v4.18.2 to v4.18.3
|
|
33
|
-
- [multer](https://www.npmjs.com/package/multer) from v1.4.4 to v1.4.5-lts.1
|
|
34
|
-
- [express-session](https://www.npmjs.com/package/express-session) from v1.17.3 to v1.18.0
|
|
35
|
-
- [sequelize](https://www.npmjs.com/package/sequelize) from v6.32.0 to v6.37.1
|
|
36
|
-
- [mariadb](https://www.npmjs.com/package/mariadb) from v2.4.0 to v3.2.3
|
|
37
|
-
- [moment](https://www.npmjs.com/package/moment) from v2.29.4 to v2.30.1
|
|
38
|
-
- Update [metronic-extension](https://www.npmjs.com/package/metronic-extension) of the demo from v1.0.1 to v3.0.9.
|
|
39
|
-
|
|
40
|
-
#### Added
|
|
41
|
-
- Demo (./demo) Docker environment added. See [here](demo/README.md) for details.
|
|
42
|
-
|
|
43
|
-
<!-- ## Testing
|
|
44
|
-
With [npm](http://npmjs.org) do:
|
|
45
|
-
|
|
46
|
-
```sh
|
|
47
|
-
npm test
|
|
48
|
-
``` -->
|
|
25
|
+
- Removed [nodejs-shared](https://www.npmjs.com/package/nodejs-shared) package dependency.
|
|
26
|
+
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.
|
|
49
27
|
|
|
50
28
|
## Author
|
|
51
29
|
**Takuya Motoshima**
|