express-sweet 1.0.17 → 1.0.20
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 +96 -2
- package/INSTALL-Redis.md +51 -0
- package/dist/build.common.js +19 -11
- package/dist/build.esm.js +19 -11
- package/docs/index.html +333 -56
- package/docs/templates/cjs/authentication.js +96 -0
- package/docs/templates/cjs/config.js +78 -0
- package/docs/templates/cjs/database.js +35 -0
- package/docs/templates/cjs/view.js +36 -0
- package/docs/templates/esm/authentication.js +96 -0
- package/docs/templates/esm/config.js +78 -0
- package/docs/templates/esm/database.js +35 -0
- package/docs/templates/esm/view.js +36 -0
- package/package.json +10 -7
- package/types/database/Model.d.ts +1 -1
- package/types/handlebars_helpers/date.d.ts +10 -17
- package/types/handlebars_helpers/index.d.ts +2 -1
- package/types/interfaces/AuthenticationOptions.d.ts +13 -0
- package/types/interfaces/BoundingBox.d.ts +1 -1
- package/types/interfaces/FaceDetailsEmotions.d.ts +40 -0
- package/types/middlewares/CORS.d.ts +1 -1
- package/types/package.d.ts +3 -0
- package/types/services/AWSRekognitionClient.d.ts +9 -241
- package/types/utils/index.d.ts +1 -0
- package/types/utils/isArray.d.ts +8 -0
- package/types/utils/isString.d.ts +1 -1
package/docs/index.html
CHANGED
|
@@ -65,6 +65,7 @@
|
|
|
65
65
|
<a class="nav-link" href="#views-html-helpers">HTML helpers</a>
|
|
66
66
|
<a class="nav-link" href="#views-object-helpers">Object helpers</a>
|
|
67
67
|
<a class="nav-link" href="#views-string-helpers">String helpers</a>
|
|
68
|
+
<a class="nav-link" href="#views-date-helpers">Date helpers</a>
|
|
68
69
|
</nav>
|
|
69
70
|
<a class="nav-link" href="#model">Model</a>
|
|
70
71
|
<nav class="nav nav-pills flex-column flex-nowrap fw-normal small">
|
|
@@ -85,6 +86,8 @@
|
|
|
85
86
|
<nav class="nav nav-pills flex-column flex-nowrap fw-normal small">
|
|
86
87
|
<a class="nav-link" href="#rekognition-class">Class Rekognition</a>
|
|
87
88
|
<a class="nav-link" href="#rekognition-match-interface">Interface FaceMatch</a>
|
|
89
|
+
<a class="nav-link" href="#rekognition-face-details-interface">Interface FaceDetails</a>
|
|
90
|
+
<a class="nav-link" href="#rekognition-face-details-emotions-interface">Interface FaceDetailsEmotions</a>
|
|
88
91
|
<a class="nav-link" href="#rekognition-bbox-interface">Interface BoundingBox</a>
|
|
89
92
|
</nav>
|
|
90
93
|
<a class="nav-link" href="#changelog">Changelog</a>
|
|
@@ -111,15 +114,23 @@
|
|
|
111
114
|
</div>
|
|
112
115
|
<hr class="mx-auto mx-lg-0 my-5">
|
|
113
116
|
<p class="text-muted">
|
|
114
|
-
Currently <a href="https://github.com/takuya-motoshima/express-sweet/releases/tag/v1.0.
|
|
115
|
-
<span class="px-1">•</span>
|
|
116
|
-
<a href="#install">Install</a>
|
|
117
|
+
Currently <a href="https://github.com/takuya-motoshima/express-sweet/releases/tag/v1.0.20" target="_blank">v1.0.20</a>
|
|
117
118
|
<span class="px-1">•</span>
|
|
118
119
|
<a href="#quick-start">Quick Start</a>
|
|
119
120
|
<span class="px-1">•</span>
|
|
120
|
-
<a href="#
|
|
121
|
+
<a href="#environment-variable">Environment variable</a>
|
|
122
|
+
<span class="px-1">•</span>
|
|
123
|
+
<a href="#base-configuration">Base configuration</a>
|
|
124
|
+
<span class="px-1">•</span>
|
|
125
|
+
<a href="#routing">Routing</a>
|
|
126
|
+
<span class="px-1">•</span>
|
|
127
|
+
<a href="#views">Views</a>
|
|
121
128
|
<span class="px-1">•</span>
|
|
122
|
-
<a href="#
|
|
129
|
+
<a href="#model">Model</a>
|
|
130
|
+
<span class="px-1">•</span>
|
|
131
|
+
<a href="#user-authentication">User authentication</a>
|
|
132
|
+
<span class="px-1">•</span>
|
|
133
|
+
<a href="#rekognition">Rekognition</a>
|
|
123
134
|
<span class="px-1">•</span>
|
|
124
135
|
<a href="https://github.com/takuya-motoshima/express-sweet" target="_blank">GitHub repo</a>
|
|
125
136
|
<span class="px-1">•</span>
|
|
@@ -337,6 +348,10 @@ INSERT INTO `book` (`userId`, `title`) VALUES
|
|
|
337
348
|
<!-- begin::Base configuration -->
|
|
338
349
|
<h1 id="base-configuration">Base configuration</h1>
|
|
339
350
|
<p>The basic configuration of Express Sweet is defined in the <code>config/config.js</code> file.</p>
|
|
351
|
+
<div class="callout callout-info">
|
|
352
|
+
Click <a href="templates/esm/config.js" download="config.js">here</a> to download a sample <span class="fw-bolder">ESM</span> configuration and<br>
|
|
353
|
+
<a href="templates/cjs/config.js" download="config.js">here</a> to download a sample <span class="fw-bolder">CJS</span> configuration.
|
|
354
|
+
</div>
|
|
340
355
|
<ul class="list-group list-group-flush">
|
|
341
356
|
<li class="list-group-item">
|
|
342
357
|
<div class="fw-bold"><code class="h5">env_path</code></div>
|
|
@@ -665,6 +680,10 @@ module.exports = router;</code></pre>
|
|
|
665
680
|
</p>
|
|
666
681
|
<h2 id="views-configuration">Configuration</h2>
|
|
667
682
|
<p>The view (template engine) configuration is defined in the <code>"config/view.js"</code> file.</p>
|
|
683
|
+
<div class="callout callout-info">
|
|
684
|
+
Click <a href="templates/esm/view.js" download="view.js">here</a> to download a sample <span class="fw-bolder">ESM</span> configuration and<br>
|
|
685
|
+
<a href="templates/cjs/view.js" download="view.js">here</a> to download a sample <span class="fw-bolder">CJS</span> configuration.
|
|
686
|
+
</div>
|
|
668
687
|
<ul class="list-group list-group-flush">
|
|
669
688
|
<li class="list-group-item">
|
|
670
689
|
<div class="fw-bold"><code class="h5">views_dir</code></div>
|
|
@@ -1287,6 +1306,37 @@ let val = '2'
|
|
|
1287
1306
|
</tr>
|
|
1288
1307
|
</tbody>
|
|
1289
1308
|
</table>
|
|
1309
|
+
<h2 id="views-date-helpers">Date helpers</h2>
|
|
1310
|
+
<table class="table">
|
|
1311
|
+
<thead class="table-light">
|
|
1312
|
+
<tr class="text-nowrap">
|
|
1313
|
+
<th>Helper</th>
|
|
1314
|
+
<th>Description</th>
|
|
1315
|
+
</tr>
|
|
1316
|
+
</thead>
|
|
1317
|
+
<tbody>
|
|
1318
|
+
<tr>
|
|
1319
|
+
<td class="text-nowrap"><code class="h5">format_date</code></td>
|
|
1320
|
+
<td class="w-100">
|
|
1321
|
+
<p>Use moment to format the date.</p>
|
|
1322
|
+
<h6>Parameters</h6>
|
|
1323
|
+
<ul>
|
|
1324
|
+
<li><code>string</code> format A format string based on moment.</li>
|
|
1325
|
+
<li><code>string</code> date Date string to format.</li>
|
|
1326
|
+
<li><code>string|string[]</code> locale Language or language-country locale string (or array of strings) available in <a href="https://github.com/moment/moment/tree/develop/locale" target="_blank">https://github.com/moment/moment/tree/develop/locale</a>.</li>
|
|
1327
|
+
</ul>
|
|
1328
|
+
<h6>Return value</h6>
|
|
1329
|
+
<p><code>string</code> Returns formatted date.</p>
|
|
1330
|
+
<h6>Usage:</h6>
|
|
1331
|
+
<div class="highlight">
|
|
1332
|
+
<pre><code class="html">{{format_date 'YYYY/MM/DD' "2021-10-24T02:13:06.610Z"}} => 2021/10/24
|
|
1333
|
+
{{format_date 'YYYY/MM/DD' "2021-10-24T02:13:06.610Z" 'jp'}} => 2021/10/24
|
|
1334
|
+
{{format_date 'YYYY/MM/DD' "2021-10-24T02:13:06.610Z" 'es'}} => 2021/10/24</code></pre>
|
|
1335
|
+
</div>
|
|
1336
|
+
</td>
|
|
1337
|
+
</tr>
|
|
1338
|
+
</tbody>
|
|
1339
|
+
</table>
|
|
1290
1340
|
<!-- end::Views -->
|
|
1291
1341
|
|
|
1292
1342
|
<!-- begin::Model -->
|
|
@@ -1304,6 +1354,10 @@ let val = '2'
|
|
|
1304
1354
|
<p>This class provides a solid base from which to build your own models, allowing you to rapidly build out your application’s model layer.</p>
|
|
1305
1355
|
<h2 id="model-configuration">Database configuration</h2>
|
|
1306
1356
|
<p>The database configuration is defined in the <code>"config/database.js"</code> file.</p>
|
|
1357
|
+
<div class="callout callout-info">
|
|
1358
|
+
Click <a href="templates/esm/database.js" download="database.js">here</a> to download a sample <span class="fw-bolder">ESM</span> configuration and<br>
|
|
1359
|
+
<a href="templates/cjs/database.js" download="database.js">here</a> to download a sample <span class="fw-bolder">CJS</span> configuration.
|
|
1360
|
+
</div>
|
|
1307
1361
|
<ul class="list-group list-group-flush">
|
|
1308
1362
|
<li class="list-group-item">
|
|
1309
1363
|
<div class="fw-bold"><code class="h5">username</code></div>
|
|
@@ -3218,6 +3272,10 @@ await BookModel.query("SELECT * FROM book", {type: BookModel.QueryType
|
|
|
3218
3272
|
</p>
|
|
3219
3273
|
<h2 id="user-authentication-configuration">Configuration</h2>
|
|
3220
3274
|
<p>The user authentication configuration is defined in the <code>"config/authentication.js"</code> file.</p>
|
|
3275
|
+
<div class="callout callout-info">
|
|
3276
|
+
Click <a href="templates/esm/authentication.js" download="authentication.js">here</a> to download a sample <span class="fw-bolder">ESM</span> configuration and<br>
|
|
3277
|
+
<a href="templates/cjs/authentication.js" download="authentication.js">here</a> to download a sample <span class="fw-bolder">CJS</span> configuration.
|
|
3278
|
+
</div>
|
|
3221
3279
|
<ul class="list-group list-group-flush">
|
|
3222
3280
|
<li class="list-group-item">
|
|
3223
3281
|
<div class="fw-bold h5"><code>boolean</code>enabled</div>
|
|
@@ -3226,6 +3284,19 @@ await BookModel.query("SELECT * FROM book", {type: BookModel.QueryType
|
|
|
3226
3284
|
User authentication is enabled (<code>true</code>) by default.
|
|
3227
3285
|
</div>
|
|
3228
3286
|
</li>
|
|
3287
|
+
<li class="list-group-item">
|
|
3288
|
+
<div class="fw-bold h5"><code>'memory'|'redis'</code>session_store</div>
|
|
3289
|
+
<div class="ms-3">The session store instance, defaults to a new MemoryStore(<code>memory</code>) instance.</div>
|
|
3290
|
+
</li>
|
|
3291
|
+
<li class="list-group-item">
|
|
3292
|
+
<div class="fw-bold h5"><code>string|undefined</code>redis_host?</div>
|
|
3293
|
+
<div class="ms-3">
|
|
3294
|
+
If the session is stored in <code>"redis"</code>, this field is required and should be set to the hostname of the Redis server.
|
|
3295
|
+
For example, to connect to redis on localhost on port <code>6379</code>, set <code>"redis://localhost:6379"</code>.
|
|
3296
|
+
To connect to a different host or port, use a connection string in the format <code>"redis[s]://[[username][:password]@][host][:port][/db-number]"</code>.
|
|
3297
|
+
For example, <code>"redis://alice:foobared@awesome.redis.server:6380"</code>.
|
|
3298
|
+
</div>
|
|
3299
|
+
</li>
|
|
3229
3300
|
<li class="list-group-item">
|
|
3230
3301
|
<div class="fw-bold h5"><code>string</code>username</div>
|
|
3231
3302
|
<div class="ms-3">
|
|
@@ -3586,6 +3657,10 @@ module.exports = router;</code></pre>
|
|
|
3586
3657
|
<div class="highlight">
|
|
3587
3658
|
<pre><code class="js">import * as sweet from 'express-sweet';
|
|
3588
3659
|
|
|
3660
|
+
// Load environment variables.
|
|
3661
|
+
sweet.middlewares.Environment.mount();
|
|
3662
|
+
|
|
3663
|
+
// Rekognition Client.
|
|
3589
3664
|
const client = new sweet.services.AWSRekognitionClient({
|
|
3590
3665
|
accessKeyId: process.env.AWS_REKOGNITION_ACCESS_KEY_ID,
|
|
3591
3666
|
secretAccessKey: process.env.AWS_REKOGNITION_SECRET_ACCESS_KEY,
|
|
@@ -3595,9 +3670,13 @@ const client = new sweet.services.AWSRekognitionClient({
|
|
|
3595
3670
|
</div>
|
|
3596
3671
|
<div class="tab-pane fade" id="rekognition-constructor-cjs">
|
|
3597
3672
|
<div class="highlight">
|
|
3598
|
-
<pre><code class="js">const
|
|
3599
|
-
|
|
3600
|
-
|
|
3673
|
+
<pre><code class="js">const sweet = require('express-sweet');
|
|
3674
|
+
|
|
3675
|
+
// Load environment variables.
|
|
3676
|
+
sweet.middlewares.Environment.mount();
|
|
3677
|
+
|
|
3678
|
+
// Rekognition Client.
|
|
3679
|
+
const client = new sweet.services.AWSRekognitionClient({
|
|
3601
3680
|
accessKeyId: process.env.AWS_REKOGNITION_ACCESS_KEY_ID,
|
|
3602
3681
|
secretAccessKey: process.env.AWS_REKOGNITION_SECRET_ACCESS_KEY,
|
|
3603
3682
|
region: process.env.AWS_REKOGNITION_REGION
|
|
@@ -3608,7 +3687,11 @@ const client = new AWSRekognitionClient({
|
|
|
3608
3687
|
</div>
|
|
3609
3688
|
</li>
|
|
3610
3689
|
<li class="list-group-item">
|
|
3611
|
-
<div class="fw-bold"
|
|
3690
|
+
<div class="fw-bold">
|
|
3691
|
+
<code class="h5">
|
|
3692
|
+
public async detectFaces(img: string, minConfidence: number = 90, withDetails: boolean = false): Promise<<a href="#rekognition-bbox-interface">BoundingBox</a>[]|<a href="#rekognition-face-details-interface">FaceDetails</a>[]>
|
|
3693
|
+
</code>
|
|
3694
|
+
</div>
|
|
3612
3695
|
<div class="ms-3">
|
|
3613
3696
|
<p>
|
|
3614
3697
|
Detects faces within an image that is provided as input.<br>
|
|
@@ -3627,9 +3710,19 @@ const client = new AWSRekognitionClient({
|
|
|
3627
3710
|
Faces with a confidence lower than this value will not be returned as a result.
|
|
3628
3711
|
</div>
|
|
3629
3712
|
</li>
|
|
3713
|
+
<li class="list-group-item pt-0 border-0">
|
|
3714
|
+
<div class="fw-bold"><code>boolean</code>withDetails</div>
|
|
3715
|
+
<div class="ms-3">
|
|
3716
|
+
If false, returns only the face bounding box.<br>
|
|
3717
|
+
When true, returns the age group, gender, and emotion in addition to the face bounding box.
|
|
3718
|
+
</div>
|
|
3719
|
+
</li>
|
|
3630
3720
|
</ul>
|
|
3631
3721
|
<h6>Return value</h6>
|
|
3632
|
-
<p
|
|
3722
|
+
<p>
|
|
3723
|
+
<code>Promise<<a href="#rekognition-bbox-interface">BoundingBox</a>[]|<a href="#rekognition-face-details-interface">FaceDetails</a>[]></code>
|
|
3724
|
+
Returns the bounding box of the detected face.
|
|
3725
|
+
</p>
|
|
3633
3726
|
<h6>Example</h6>
|
|
3634
3727
|
<ul class="nav nav-tabs">
|
|
3635
3728
|
<li class="nav-item">
|
|
@@ -3645,22 +3738,55 @@ const client = new AWSRekognitionClient({
|
|
|
3645
3738
|
<pre><code class="js">import * as sweet from 'express-sweet';
|
|
3646
3739
|
import fs from 'fs';
|
|
3647
3740
|
|
|
3741
|
+
// Load environment variables.
|
|
3742
|
+
sweet.middlewares.Environment.mount();
|
|
3743
|
+
|
|
3744
|
+
// Rekognition Client.
|
|
3648
3745
|
const client = new sweet.services.AWSRekognitionClient({
|
|
3649
3746
|
accessKeyId: process.env.AWS_REKOGNITION_ACCESS_KEY_ID,
|
|
3650
3747
|
secretAccessKey: process.env.AWS_REKOGNITION_SECRET_ACCESS_KEY,
|
|
3651
3748
|
region: process.env.AWS_REKOGNITION_REGION
|
|
3652
3749
|
});
|
|
3653
3750
|
|
|
3654
|
-
//
|
|
3655
|
-
// Output:
|
|
3656
|
-
//
|
|
3657
|
-
//
|
|
3658
|
-
//
|
|
3659
|
-
//
|
|
3660
|
-
//
|
|
3661
|
-
//
|
|
3662
|
-
//
|
|
3663
|
-
await client.detectFaces('img.jpg');
|
|
3751
|
+
// Detects bounding boxes on faces.
|
|
3752
|
+
// Output: [
|
|
3753
|
+
// {
|
|
3754
|
+
// width: 0.3099822998046875,
|
|
3755
|
+
// height: 0.661512017250061,
|
|
3756
|
+
// left: 0.5449195504188538,
|
|
3757
|
+
// top: 0.11531734466552734
|
|
3758
|
+
// }
|
|
3759
|
+
// ]
|
|
3760
|
+
let res = await client.detectFaces('img/face2.jpg');
|
|
3761
|
+
console.log(res);
|
|
3762
|
+
|
|
3763
|
+
// Detect facial details.
|
|
3764
|
+
// Output: [
|
|
3765
|
+
// {
|
|
3766
|
+
// boundingBox: {
|
|
3767
|
+
// width: 0.3099822998046875,
|
|
3768
|
+
// height: 0.661512017250061,
|
|
3769
|
+
// left: 0.5449195504188538,
|
|
3770
|
+
// top: 0.11531734466552734
|
|
3771
|
+
// },
|
|
3772
|
+
// ageRange: { high: 14, low: 6 },
|
|
3773
|
+
// gender: 'female',
|
|
3774
|
+
// emotions: {
|
|
3775
|
+
// happy: 99.78905487060547,
|
|
3776
|
+
// surprised: 6.306276321411133,
|
|
3777
|
+
// fear: 5.880091190338135,
|
|
3778
|
+
// sad: 2.152125835418701,
|
|
3779
|
+
// confused: 0.023256277665495872,
|
|
3780
|
+
// angry: 0.018351631239056587,
|
|
3781
|
+
// calm: 0.015775982290506363,
|
|
3782
|
+
// disgusted: 0.013914424926042557
|
|
3783
|
+
// }
|
|
3784
|
+
// }
|
|
3785
|
+
// ]
|
|
3786
|
+
const minConfidence = 90;
|
|
3787
|
+
const withDetails = true;
|
|
3788
|
+
res = await client.detectFaces('img/face2.jpg', minConfidence, withDetails);
|
|
3789
|
+
console.log(res);
|
|
3664
3790
|
|
|
3665
3791
|
// Detect faces from data URL.
|
|
3666
3792
|
await client.detectFaces('data:image/png;base64,/9j/4...');
|
|
@@ -3671,25 +3797,58 @@ await client.detectFaces(fs.readFileSync('img.jpg'));</code></pre>
|
|
|
3671
3797
|
</div>
|
|
3672
3798
|
<div class="tab-pane fade" id="rekognition-method-detect-faces-cjs">
|
|
3673
3799
|
<div class="highlight">
|
|
3674
|
-
<pre><code class="js">const
|
|
3800
|
+
<pre><code class="js">const sweet = require('express-sweet');
|
|
3675
3801
|
const fs = require('fs');
|
|
3676
3802
|
|
|
3677
|
-
|
|
3803
|
+
// Load environment variables.
|
|
3804
|
+
sweet.middlewares.Environment.mount();
|
|
3805
|
+
|
|
3806
|
+
// Rekognition Client.
|
|
3807
|
+
const client = new sweet.services.AWSRekognitionClient({
|
|
3678
3808
|
accessKeyId: process.env.AWS_REKOGNITION_ACCESS_KEY_ID,
|
|
3679
3809
|
secretAccessKey: process.env.AWS_REKOGNITION_SECRET_ACCESS_KEY,
|
|
3680
3810
|
region: process.env.AWS_REKOGNITION_REGION
|
|
3681
3811
|
});
|
|
3682
3812
|
|
|
3683
|
-
//
|
|
3684
|
-
// Output:
|
|
3685
|
-
//
|
|
3686
|
-
//
|
|
3687
|
-
//
|
|
3688
|
-
//
|
|
3689
|
-
//
|
|
3690
|
-
//
|
|
3691
|
-
//
|
|
3692
|
-
await client.detectFaces('img.jpg');
|
|
3813
|
+
// Detects bounding boxes on faces.
|
|
3814
|
+
// Output: [
|
|
3815
|
+
// {
|
|
3816
|
+
// width: 0.3099822998046875,
|
|
3817
|
+
// height: 0.661512017250061,
|
|
3818
|
+
// left: 0.5449195504188538,
|
|
3819
|
+
// top: 0.11531734466552734
|
|
3820
|
+
// }
|
|
3821
|
+
// ]
|
|
3822
|
+
let res = await client.detectFaces('img/face2.jpg');
|
|
3823
|
+
console.log(res);
|
|
3824
|
+
|
|
3825
|
+
// Detect facial details.
|
|
3826
|
+
// Output: [
|
|
3827
|
+
// {
|
|
3828
|
+
// boundingBox: {
|
|
3829
|
+
// width: 0.3099822998046875,
|
|
3830
|
+
// height: 0.661512017250061,
|
|
3831
|
+
// left: 0.5449195504188538,
|
|
3832
|
+
// top: 0.11531734466552734
|
|
3833
|
+
// },
|
|
3834
|
+
// ageRange: { high: 14, low: 6 },
|
|
3835
|
+
// gender: 'female',
|
|
3836
|
+
// emotions: {
|
|
3837
|
+
// happy: 99.78905487060547,
|
|
3838
|
+
// surprised: 6.306276321411133,
|
|
3839
|
+
// fear: 5.880091190338135,
|
|
3840
|
+
// sad: 2.152125835418701,
|
|
3841
|
+
// confused: 0.023256277665495872,
|
|
3842
|
+
// angry: 0.018351631239056587,
|
|
3843
|
+
// calm: 0.015775982290506363,
|
|
3844
|
+
// disgusted: 0.013914424926042557
|
|
3845
|
+
// }
|
|
3846
|
+
// }
|
|
3847
|
+
// ]
|
|
3848
|
+
const minConfidence = 90;
|
|
3849
|
+
const withDetails = true;
|
|
3850
|
+
res = await client.detectFaces('img/face2.jpg', minConfidence, withDetails);
|
|
3851
|
+
console.log(res);
|
|
3693
3852
|
|
|
3694
3853
|
// Detect faces from data URL.
|
|
3695
3854
|
await client.detectFaces('data:image/png;base64,/9j/4...');
|
|
@@ -3733,6 +3892,10 @@ await client.detectFaces(fs.readFileSync('img.jpg'));</code></pre>
|
|
|
3733
3892
|
<pre><code class="js">import * as sweet from 'express-sweet';
|
|
3734
3893
|
import fs from 'fs';
|
|
3735
3894
|
|
|
3895
|
+
// Load environment variables.
|
|
3896
|
+
sweet.middlewares.Environment.mount();
|
|
3897
|
+
|
|
3898
|
+
// Rekognition Client.
|
|
3736
3899
|
const client = new sweet.services.AWSRekognitionClient({
|
|
3737
3900
|
accessKeyId: process.env.AWS_REKOGNITION_ACCESS_KEY_ID,
|
|
3738
3901
|
secretAccessKey: process.env.AWS_REKOGNITION_SECRET_ACCESS_KEY,
|
|
@@ -3751,10 +3914,14 @@ await client.compareFaces(fs.readFileSync('img1.jpg'), fs.readFileSync
|
|
|
3751
3914
|
</div>
|
|
3752
3915
|
<div class="tab-pane fade" id="rekognition-method-compare-faces-cjs">
|
|
3753
3916
|
<div class="highlight">
|
|
3754
|
-
<pre><code class="js">const
|
|
3917
|
+
<pre><code class="js">const sweet = require('express-sweet');
|
|
3755
3918
|
const fs = require('fs');
|
|
3756
3919
|
|
|
3757
|
-
|
|
3920
|
+
// Load environment variables.
|
|
3921
|
+
sweet.middlewares.Environment.mount();
|
|
3922
|
+
|
|
3923
|
+
// Rekognition Client.
|
|
3924
|
+
const client = new sweet.services.AWSRekognitionClient({
|
|
3758
3925
|
accessKeyId: process.env.AWS_REKOGNITION_ACCESS_KEY_ID,
|
|
3759
3926
|
secretAccessKey: process.env.AWS_REKOGNITION_SECRET_ACCESS_KEY,
|
|
3760
3927
|
region: process.env.AWS_REKOGNITION_REGION
|
|
@@ -3807,6 +3974,10 @@ await client.compareFaces(fs.readFileSync('img1.jpg'), fs.readFileSync
|
|
|
3807
3974
|
<div class="highlight">
|
|
3808
3975
|
<pre><code class="js">import * as sweet from 'express-sweet';
|
|
3809
3976
|
|
|
3977
|
+
// Load environment variables.
|
|
3978
|
+
sweet.middlewares.Environment.mount();
|
|
3979
|
+
|
|
3980
|
+
// Rekognition Client.
|
|
3810
3981
|
const client = new sweet.services.AWSRekognitionClient({
|
|
3811
3982
|
accessKeyId: process.env.AWS_REKOGNITION_ACCESS_KEY_ID,
|
|
3812
3983
|
secretAccessKey: process.env.AWS_REKOGNITION_SECRET_ACCESS_KEY,
|
|
@@ -3819,9 +3990,13 @@ await client.createCollection('MyCollection');</code></pre>
|
|
|
3819
3990
|
</div>
|
|
3820
3991
|
<div class="tab-pane fade" id="rekognition-method-create-collection-cjs">
|
|
3821
3992
|
<div class="highlight">
|
|
3822
|
-
<pre><code class="js">const
|
|
3993
|
+
<pre><code class="js">const sweet = require('express-sweet');
|
|
3823
3994
|
|
|
3824
|
-
|
|
3995
|
+
// Load environment variables.
|
|
3996
|
+
sweet.middlewares.Environment.mount();
|
|
3997
|
+
|
|
3998
|
+
// Rekognition Client.
|
|
3999
|
+
const client = new sweet.services.AWSRekognitionClient({
|
|
3825
4000
|
accessKeyId: process.env.AWS_REKOGNITION_ACCESS_KEY_ID,
|
|
3826
4001
|
secretAccessKey: process.env.AWS_REKOGNITION_SECRET_ACCESS_KEY,
|
|
3827
4002
|
region: process.env.AWS_REKOGNITION_REGION
|
|
@@ -3856,6 +4031,10 @@ await client.createCollection('MyCollection');</code></pre>
|
|
|
3856
4031
|
<div class="highlight">
|
|
3857
4032
|
<pre><code class="js">import * as sweet from 'express-sweet';
|
|
3858
4033
|
|
|
4034
|
+
// Load environment variables.
|
|
4035
|
+
sweet.middlewares.Environment.mount();
|
|
4036
|
+
|
|
4037
|
+
// Rekognition Client.
|
|
3859
4038
|
const client = new sweet.services.AWSRekognitionClient({
|
|
3860
4039
|
accessKeyId: process.env.AWS_REKOGNITION_ACCESS_KEY_ID,
|
|
3861
4040
|
secretAccessKey: process.env.AWS_REKOGNITION_SECRET_ACCESS_KEY,
|
|
@@ -3872,9 +4051,13 @@ await client.listCollections();</code></pre>
|
|
|
3872
4051
|
</div>
|
|
3873
4052
|
<div class="tab-pane fade" id="rekognition-method-list-collections-cjs">
|
|
3874
4053
|
<div class="highlight">
|
|
3875
|
-
<pre><code class="js">const
|
|
3876
|
-
|
|
3877
|
-
|
|
4054
|
+
<pre><code class="js">const sweet = require('express-sweet');
|
|
4055
|
+
|
|
4056
|
+
// Load environment variables.
|
|
4057
|
+
sweet.middlewares.Environment.mount();
|
|
4058
|
+
|
|
4059
|
+
// Rekognition Client.
|
|
4060
|
+
const client = new sweet.services.AWSRekognitionClient({
|
|
3878
4061
|
accessKeyId: process.env.AWS_REKOGNITION_ACCESS_KEY_ID,
|
|
3879
4062
|
secretAccessKey: process.env.AWS_REKOGNITION_SECRET_ACCESS_KEY,
|
|
3880
4063
|
region: process.env.AWS_REKOGNITION_REGION
|
|
@@ -3918,7 +4101,11 @@ await client.listCollections();</code></pre>
|
|
|
3918
4101
|
<div class="tab-pane fade show active" id="rekognition-method-delete-collection-esm">
|
|
3919
4102
|
<div class="highlight">
|
|
3920
4103
|
<pre><code class="js">import * as sweet from 'express-sweet';
|
|
3921
|
-
|
|
4104
|
+
|
|
4105
|
+
// Load environment variables.
|
|
4106
|
+
sweet.middlewares.Environment.mount();
|
|
4107
|
+
|
|
4108
|
+
// Rekognition Client.
|
|
3922
4109
|
const client = new sweet.services.AWSRekognitionClient({
|
|
3923
4110
|
accessKeyId: process.env.AWS_REKOGNITION_ACCESS_KEY_ID,
|
|
3924
4111
|
secretAccessKey: process.env.AWS_REKOGNITION_SECRET_ACCESS_KEY,
|
|
@@ -3931,9 +4118,13 @@ await client.deleteCollection('MyCollection');</code></pre>
|
|
|
3931
4118
|
</div>
|
|
3932
4119
|
<div class="tab-pane fade" id="rekognition-method-delete-collection-cjs">
|
|
3933
4120
|
<div class="highlight">
|
|
3934
|
-
<pre><code class="js">const
|
|
3935
|
-
|
|
3936
|
-
|
|
4121
|
+
<pre><code class="js">const sweet = require('express-sweet');
|
|
4122
|
+
|
|
4123
|
+
// Load environment variables.
|
|
4124
|
+
sweet.middlewares.Environment.mount();
|
|
4125
|
+
|
|
4126
|
+
// Rekognition Client.
|
|
4127
|
+
const client = new sweet.services.AWSRekognitionClient({
|
|
3937
4128
|
accessKeyId: process.env.AWS_REKOGNITION_ACCESS_KEY_ID,
|
|
3938
4129
|
secretAccessKey: process.env.AWS_REKOGNITION_SECRET_ACCESS_KEY,
|
|
3939
4130
|
region: process.env.AWS_REKOGNITION_REGION
|
|
@@ -3997,6 +4188,10 @@ await client.deleteCollection('MyCollection');</code></pre>
|
|
|
3997
4188
|
<pre><code class="js">import * as sweet from 'express-sweet';
|
|
3998
4189
|
import fs from 'fs';
|
|
3999
4190
|
|
|
4191
|
+
// Load environment variables.
|
|
4192
|
+
sweet.middlewares.Environment.mount();
|
|
4193
|
+
|
|
4194
|
+
// Rekognition Client.
|
|
4000
4195
|
const client = new sweet.services.AWSRekognitionClient({
|
|
4001
4196
|
accessKeyId: process.env.AWS_REKOGNITION_ACCESS_KEY_ID,
|
|
4002
4197
|
secretAccessKey: process.env.AWS_REKOGNITION_SECRET_ACCESS_KEY,
|
|
@@ -4027,10 +4222,14 @@ await client.indexFace('MyCollection', 'img.jpg');</code></p
|
|
|
4027
4222
|
</div>
|
|
4028
4223
|
<div class="tab-pane fade" id="rekognition-method-index-face-cjs">
|
|
4029
4224
|
<div class="highlight">
|
|
4030
|
-
<pre><code class="js">const
|
|
4225
|
+
<pre><code class="js">const sweet = require('express-sweet');
|
|
4031
4226
|
const fs = require('fs');
|
|
4032
4227
|
|
|
4033
|
-
|
|
4228
|
+
// Load environment variables.
|
|
4229
|
+
sweet.middlewares.Environment.mount();
|
|
4230
|
+
|
|
4231
|
+
// Rekognition Client.
|
|
4232
|
+
const client = new sweet.services.AWSRekognitionClient({
|
|
4034
4233
|
accessKeyId: process.env.AWS_REKOGNITION_ACCESS_KEY_ID,
|
|
4035
4234
|
secretAccessKey: process.env.AWS_REKOGNITION_SECRET_ACCESS_KEY,
|
|
4036
4235
|
region: process.env.AWS_REKOGNITION_REGION
|
|
@@ -4117,6 +4316,10 @@ await client.indexFace('MyCollection', 'img.jpg');</code></p
|
|
|
4117
4316
|
<pre><code class="js">import * as sweet from 'express-sweet';
|
|
4118
4317
|
import fs from 'fs';
|
|
4119
4318
|
|
|
4319
|
+
// Load environment variables.
|
|
4320
|
+
sweet.middlewares.Environment.mount();
|
|
4321
|
+
|
|
4322
|
+
// Rekognition Client.
|
|
4120
4323
|
const client = new sweet.services.AWSRekognitionClient({
|
|
4121
4324
|
accessKeyId: process.env.AWS_REKOGNITION_ACCESS_KEY_ID,
|
|
4122
4325
|
secretAccessKey: process.env.AWS_REKOGNITION_SECRET_ACCESS_KEY,
|
|
@@ -4164,10 +4367,14 @@ await client.searchFaces('MyCollection', fs.readFileSync('img.jpg
|
|
|
4164
4367
|
</div>
|
|
4165
4368
|
<div class="tab-pane fade" id="rekognition-method-search-faces-cjs">
|
|
4166
4369
|
<div class="highlight">
|
|
4167
|
-
<pre><code class="js">const
|
|
4370
|
+
<pre><code class="js">const sweet = require('express-sweet');
|
|
4168
4371
|
const fs = require('fs');
|
|
4169
4372
|
|
|
4170
|
-
|
|
4373
|
+
// Load environment variables.
|
|
4374
|
+
sweet.middlewares.Environment.mount();
|
|
4375
|
+
|
|
4376
|
+
// Rekognition Client.
|
|
4377
|
+
const client = new sweet.services.AWSRekognitionClient({
|
|
4171
4378
|
accessKeyId: process.env.AWS_REKOGNITION_ACCESS_KEY_ID,
|
|
4172
4379
|
secretAccessKey: process.env.AWS_REKOGNITION_SECRET_ACCESS_KEY,
|
|
4173
4380
|
region: process.env.AWS_REKOGNITION_REGION
|
|
@@ -4248,7 +4455,11 @@ await client.searchFaces('MyCollection', fs.readFileSync('img.jpg
|
|
|
4248
4455
|
<div class="tab-pane fade show active" id="rekognition-method-list-faces-esm">
|
|
4249
4456
|
<div class="highlight">
|
|
4250
4457
|
<pre><code class="js">import * as sweet from 'express-sweet';
|
|
4251
|
-
|
|
4458
|
+
|
|
4459
|
+
// Load environment variables.
|
|
4460
|
+
sweet.middlewares.Environment.mount();
|
|
4461
|
+
|
|
4462
|
+
// Rekognition Client.
|
|
4252
4463
|
const client = new sweet.services.AWSRekognitionClient({
|
|
4253
4464
|
accessKeyId: process.env.AWS_REKOGNITION_ACCESS_KEY_ID,
|
|
4254
4465
|
secretAccessKey: process.env.AWS_REKOGNITION_SECRET_ACCESS_KEY,
|
|
@@ -4274,9 +4485,13 @@ console.log(result);</code></pre>
|
|
|
4274
4485
|
</div>
|
|
4275
4486
|
<div class="tab-pane fade" id="rekognition-method-list-faces-cjs">
|
|
4276
4487
|
<div class="highlight">
|
|
4277
|
-
<pre><code class="js">const
|
|
4278
|
-
|
|
4279
|
-
|
|
4488
|
+
<pre><code class="js">const sweet = require('express-sweet');
|
|
4489
|
+
|
|
4490
|
+
// Load environment variables.
|
|
4491
|
+
sweet.middlewares.Environment.mount();
|
|
4492
|
+
|
|
4493
|
+
// Rekognition Client.
|
|
4494
|
+
const client = new sweet.services.AWSRekognitionClient({
|
|
4280
4495
|
accessKeyId: process.env.AWS_REKOGNITION_ACCESS_KEY_ID,
|
|
4281
4496
|
secretAccessKey: process.env.AWS_REKOGNITION_SECRET_ACCESS_KEY,
|
|
4282
4497
|
region: process.env.AWS_REKOGNITION_REGION
|
|
@@ -4333,7 +4548,11 @@ console.log(result);</code></pre>
|
|
|
4333
4548
|
<div class="tab-pane fade show active" id="rekognition-method-delete-faces-esm">
|
|
4334
4549
|
<div class="highlight">
|
|
4335
4550
|
<pre><code class="js">import * as sweet from 'express-sweet';
|
|
4336
|
-
|
|
4551
|
+
|
|
4552
|
+
// Load environment variables.
|
|
4553
|
+
sweet.middlewares.Environment.mount();
|
|
4554
|
+
|
|
4555
|
+
// Rekognition Client.
|
|
4337
4556
|
const client = new sweet.services.AWSRekognitionClient({
|
|
4338
4557
|
accessKeyId: process.env.AWS_REKOGNITION_ACCESS_KEY_ID,
|
|
4339
4558
|
secretAccessKey: process.env.AWS_REKOGNITION_SECRET_ACCESS_KEY,
|
|
@@ -4346,9 +4565,13 @@ await client.deleteFaces('MyCollection', ['f7befa24-3b83-43cc-b21
|
|
|
4346
4565
|
</div>
|
|
4347
4566
|
<div class="tab-pane fade" id="rekognition-method-delete-faces-cjs">
|
|
4348
4567
|
<div class="highlight">
|
|
4349
|
-
<pre><code class="js">const
|
|
4350
|
-
|
|
4351
|
-
|
|
4568
|
+
<pre><code class="js">const sweet = require('express-sweet');
|
|
4569
|
+
|
|
4570
|
+
// Load environment variables.
|
|
4571
|
+
sweet.middlewares.Environment.mount();
|
|
4572
|
+
|
|
4573
|
+
// Rekognition Client.
|
|
4574
|
+
const client = new sweet.services.AWSRekognitionClient({
|
|
4352
4575
|
accessKeyId: process.env.AWS_REKOGNITION_ACCESS_KEY_ID,
|
|
4353
4576
|
secretAccessKey: process.env.AWS_REKOGNITION_SECRET_ACCESS_KEY,
|
|
4354
4577
|
region: process.env.AWS_REKOGNITION_REGION
|
|
@@ -4391,8 +4614,62 @@ await client.deleteFaces('MyCollection', ['f7befa24-3b83-43cc-b21
|
|
|
4391
4614
|
<div class="ms-3">Confidence in the match of this face with the input face.<br>Valid Range: Minimum value of 0. Maximum value of 100.</div>
|
|
4392
4615
|
</li>
|
|
4393
4616
|
</ul>
|
|
4617
|
+
<h2 id="rekognition-face-details-interface">Interface FaceDetails<span class="fs-5 ms-2">(express-sweet.interfaces.FaceDetails)</span></h2>
|
|
4618
|
+
<p>Details of each face found in the image. </p>
|
|
4619
|
+
<h3>Properties</h3>
|
|
4620
|
+
<ul class="list-group list-group-flush">
|
|
4621
|
+
<li class="list-group-item">
|
|
4622
|
+
<div class="fw-bold"><code class="h5">boundingBox: <a href="#rekognition-bbox-interface">BoundingBox</a></code></div>
|
|
4623
|
+
<div class="ms-3">Bounding box of the face.</div>
|
|
4624
|
+
</li>
|
|
4625
|
+
<li class="list-group-item">
|
|
4626
|
+
<div class="fw-bold"><code class="h5">ageRange?: {high: UInteger, low: UInteger}</code></div>
|
|
4627
|
+
<div class="ms-3">The estimated age range, in years, for the face. Low represents the lowest estimated age and High represents the highest estimated age.</div>
|
|
4628
|
+
</li>
|
|
4629
|
+
<li class="list-group-item">
|
|
4630
|
+
<div class="fw-bold"><code class="h5">gender?: 'male'|'female'</code></div>
|
|
4631
|
+
<div class="ms-3">The predicted gender of a detected face. </div>
|
|
4632
|
+
</li>
|
|
4633
|
+
<li class="list-group-item">
|
|
4634
|
+
<div class="fw-bold"><code class="h5">emotions?: <a href="#rekognition-face-details-emotions-interface">FaceDetailsEmotions</a></code></div>
|
|
4635
|
+
<div class="ms-3">The predicted gender of a detected face. </div>
|
|
4636
|
+
</li>
|
|
4637
|
+
</ul>
|
|
4638
|
+
<h2 id="rekognition-face-details-emotions-interface">Interface FaceDetailsEmotions<span class="fs-5 ms-2">(express-sweet.interfaces.FaceDetailsEmotions)</span></h2>
|
|
4639
|
+
<p>The emotions that appear to be expressed on the face, and the confidence level in the determination. </p>
|
|
4640
|
+
<h3>Properties</h3>
|
|
4641
|
+
<ul class="list-group list-group-flush">
|
|
4642
|
+
<li class="list-group-item">
|
|
4643
|
+
<div class="fw-bold"><code class="h5">disgusted: number</code></div>
|
|
4644
|
+
<div class="ms-3">Confidence level of "disgusted" predicted from the face.</div>
|
|
4645
|
+
</li>
|
|
4646
|
+
<li class="list-group-item">
|
|
4647
|
+
<div class="fw-bold"><code class="h5">happy: number</code></div>
|
|
4648
|
+
<div class="ms-3">Confidence level of "happy" predicted from the face.</div>
|
|
4649
|
+
</li>
|
|
4650
|
+
<li class="list-group-item">
|
|
4651
|
+
<div class="fw-bold"><code class="h5">surprised: number</code></div>
|
|
4652
|
+
<div class="ms-3">Confidence level of "surprised" predicted from the face.</div>
|
|
4653
|
+
</li>
|
|
4654
|
+
<li class="list-group-item">
|
|
4655
|
+
<div class="fw-bold"><code class="h5">angry: number</code></div>
|
|
4656
|
+
<div class="ms-3">Confidence level of "angry" predicted from the face.</div>
|
|
4657
|
+
</li>
|
|
4658
|
+
<li class="list-group-item">
|
|
4659
|
+
<div class="fw-bold"><code class="h5">confused: number</code></div>
|
|
4660
|
+
<div class="ms-3">Confidence level of "confused" predicted from the face.</div>
|
|
4661
|
+
</li>
|
|
4662
|
+
<li class="list-group-item">
|
|
4663
|
+
<div class="fw-bold"><code class="h5">calm: number</code></div>
|
|
4664
|
+
<div class="ms-3">Confidence level of "calm" predicted from the face.</div>
|
|
4665
|
+
</li>
|
|
4666
|
+
<li class="list-group-item">
|
|
4667
|
+
<div class="fw-bold"><code class="h5">sad: number</code></div>
|
|
4668
|
+
<div class="ms-3">Confidence level of "sad" predicted from the face.</div>
|
|
4669
|
+
</li>
|
|
4670
|
+
</ul>
|
|
4394
4671
|
<h2 id="rekognition-bbox-interface">Interface BoundingBox<span class="fs-5 ms-2">(express-sweet.interfaces.BoundingBox)</span></h2>
|
|
4395
|
-
<p>Bounding box
|
|
4672
|
+
<p>Bounding box of the face.</p>
|
|
4396
4673
|
<h3>Properties</h3>
|
|
4397
4674
|
<ul class="list-group list-group-flush">
|
|
4398
4675
|
<li class="list-group-item">
|