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