express-sweet 1.0.34 → 1.0.36
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 +83 -1
- package/dist/build.common.js +12 -12
- package/dist/build.esm.js +12 -12
- package/docs/index.html +63 -39
- package/package.json +1 -1
- package/types/database/index.d.ts +3 -3
- package/types/exceptions/index.d.ts +5 -5
- package/types/handlebars_helpers/index.d.ts +6 -6
- package/types/index.d.ts +7 -7
- package/types/interfaces/{AuthenticationOptions.d.ts → AuthenticationConfig.d.ts} +13 -16
- package/types/interfaces/BasicConfig.d.ts +74 -0
- package/types/interfaces/FaceMatch.d.ts +1 -1
- package/types/interfaces/index.d.ts +9 -9
- package/types/middlewares/CORS.d.ts +0 -1
- package/types/middlewares/Environment.d.ts +0 -1
- package/types/middlewares/{ErrorHandling.d.ts → ErrorHandler.d.ts} +0 -1
- package/types/middlewares/Http.d.ts +0 -1
- package/types/middlewares/Local.d.ts +0 -1
- package/types/middlewares/View.d.ts +0 -1
- package/types/middlewares/index.d.ts +8 -8
- package/types/routing/Router.d.ts +0 -1
- package/types/routing/index.d.ts +1 -1
- package/types/services/Authentication.d.ts +2 -2
- package/types/services/index.d.ts +3 -3
- package/types/utils/index.d.ts +8 -3
- package/types/utils/isAsyncFunction.d.ts +10 -10
- package/types/utils/isFunction.d.ts +13 -0
- package/types/utils/loadAuthenticationConfig.d.ts +8 -0
- package/types/utils/loadBasicConfig.d.ts +8 -0
- package/types/utils/loadDatabaseConfig.d.ts +8 -0
- package/types/utils/loadViewConfig.d.ts +8 -0
- package/types/interfaces/Config.d.ts +0 -66
- /package/types/interfaces/{DatabaseOptions.d.ts → DatabaseConfig.d.ts} +0 -0
- /package/types/interfaces/{ViewOptions.d.ts → ViewConfig.d.ts} +0 -0
package/docs/index.html
CHANGED
|
@@ -81,7 +81,7 @@
|
|
|
81
81
|
<!--begin::Title-->
|
|
82
82
|
<h1 class="page-heading d-flex text-dark fw-bold fs-3 justify-content-center align-items-baseline my-0">
|
|
83
83
|
<!-- <h1 class="page-heading d-flex text-dark fw-bold fs-3 flex-column justify-content-center my-0"> -->
|
|
84
|
-
DevDocs<a href="#changelog" class="badge fw-semibold fs-7 px-2 ms-2 bg-body text-dark text-hover-primary shadow-sm">v1.0.
|
|
84
|
+
DevDocs<a href="#changelog" class="badge fw-semibold fs-7 px-2 ms-2 bg-body text-dark text-hover-primary shadow-sm">v1.0.36</a>
|
|
85
85
|
</h1>
|
|
86
86
|
<!--end::Title-->
|
|
87
87
|
</div>
|
|
@@ -1290,7 +1290,7 @@ npm start</code></pre>
|
|
|
1290
1290
|
<!--begin::Body-->
|
|
1291
1291
|
<tbody>
|
|
1292
1292
|
<tr>
|
|
1293
|
-
<td class="w-250px"><code>env_path</code></td>
|
|
1293
|
+
<td class="w-250px"><code>env_path: string</code></td>
|
|
1294
1294
|
<td>
|
|
1295
1295
|
The path to the environment configuration file (<code>.env</code>).<br>
|
|
1296
1296
|
When you start the Express Sweet application, the contents of the environment configuration file are automatically read and saved in <code>process.env</code>.<br>
|
|
@@ -1298,11 +1298,11 @@ npm start</code></pre>
|
|
|
1298
1298
|
</td>
|
|
1299
1299
|
</tr>
|
|
1300
1300
|
<tr>
|
|
1301
|
-
<td class="w-250px"><code>cors_enabled</code></td>
|
|
1301
|
+
<td class="w-250px"><code>cors_enabled: boolean</code></td>
|
|
1302
1302
|
<td>Set to true to allow requests from another domain to the application.<br>The default is <code>false</code>.</td>
|
|
1303
1303
|
</tr>
|
|
1304
1304
|
<tr>
|
|
1305
|
-
<td class="w-250px"><code>max_body_size</code></td>
|
|
1305
|
+
<td class="w-250px"><code>max_body_size: string|number</code></td>
|
|
1306
1306
|
<td>
|
|
1307
1307
|
Controls the maximum request body size.<br>
|
|
1308
1308
|
If this is a number, then the value specifies the number of bytes.<br>
|
|
@@ -1311,11 +1311,11 @@ npm start</code></pre>
|
|
|
1311
1311
|
</td>
|
|
1312
1312
|
</tr>
|
|
1313
1313
|
<tr>
|
|
1314
|
-
<td class="w-250px"><code>router_dir</code></td>
|
|
1314
|
+
<td class="w-250px"><code>router_dir: string</code></td>
|
|
1315
1315
|
<td>The directory path where the routes module is located.<br>The default is the <code>routes</code> directory directly under the application root.</td>
|
|
1316
1316
|
</tr>
|
|
1317
1317
|
<tr>
|
|
1318
|
-
<td class="w-250px"><code>default_router</code></td>
|
|
1318
|
+
<td class="w-250px"><code>default_router: string</code></td>
|
|
1319
1319
|
<td>
|
|
1320
1320
|
Express Sweet can be told to load a default router when a URI is not present, as will be the case when root URL (<code>/</code>) is requested.<br>
|
|
1321
1321
|
For example, to specify a default route, set <code>default_router</code> as follows.<br>
|
|
@@ -1366,7 +1366,7 @@ module.exports = router;</code></pre>
|
|
|
1366
1366
|
</td>
|
|
1367
1367
|
</tr>
|
|
1368
1368
|
<tr>
|
|
1369
|
-
<td class="w-250px"><code>rewrite_base_url</code></td>
|
|
1369
|
+
<td class="w-250px"><code>rewrite_base_url: (baseUrl: string) => string</code></td>
|
|
1370
1370
|
<td>
|
|
1371
1371
|
This is a hook that rewrites the base URL.<br>
|
|
1372
1372
|
If you want to rewrite the app.locals.baseUrl property and the view's baseUrl variable, use this hook to return a new base URL.<br>
|
|
@@ -1389,18 +1389,21 @@ module.exports = router;</code></pre>
|
|
|
1389
1389
|
</td>
|
|
1390
1390
|
</tr>
|
|
1391
1391
|
<tr>
|
|
1392
|
-
<td class="w-250px"><code>
|
|
1392
|
+
<td class="w-250px"><code>is_ajax: (req: express.Request) => boolean</code></td>
|
|
1393
1393
|
<td>
|
|
1394
|
-
|
|
1395
|
-
|
|
1394
|
+
How to determine if it is an ajax request.<br>
|
|
1395
|
+
The default is that if there is an XMLHttpRequest in the request header (<code>req.xhr</code>) returns <code>true</code>.<br><br>
|
|
1396
|
+
For example, if there is no XMLHttpRequest in req(<code>express.Request</code>) and the Ajax endpoint starts with <code>/api</code>, a custom Ajax decision can be made like "<code>return /^\/api\//.test(req.path)</code>".<br>
|
|
1396
1397
|
<!--begin::Code-->
|
|
1397
1398
|
<div class="py-5">
|
|
1398
1399
|
<!--begin::Highlight-->
|
|
1399
1400
|
<div class="highlight">
|
|
1400
1401
|
<button class="highlight-copy btn" data-bs-toggle="tooltip" title="Copy code">copy</button>
|
|
1401
1402
|
<div class="highlight-code">
|
|
1402
|
-
<pre class="language-javascript"><code class="language-javascript">
|
|
1403
|
-
|
|
1403
|
+
<pre class="language-javascript"><code class="language-javascript">is_ajax: req => {
|
|
1404
|
+
// If the request URL begins with /api, it is assumed to be Ajax.
|
|
1405
|
+
return /^\/api/.test(req.path);
|
|
1406
|
+
// return !!req.xhr;
|
|
1404
1407
|
}</code></pre>
|
|
1405
1408
|
</div>
|
|
1406
1409
|
</div>
|
|
@@ -1409,6 +1412,32 @@ module.exports = router;</code></pre>
|
|
|
1409
1412
|
<!--end::Code-->
|
|
1410
1413
|
</td>
|
|
1411
1414
|
</tr>
|
|
1415
|
+
<tr>
|
|
1416
|
+
<td class="w-250px"><code>hook_handle_error: (err: any, req: express.Request, res: express.Response, next: express.NextFunction) => void</code></td>
|
|
1417
|
+
<td>
|
|
1418
|
+
Hooks the default behavior on request errors.<br>
|
|
1419
|
+
If unset, simply returns an error HTTP status. (<code>res.status(err.status||500).end();</code>)
|
|
1420
|
+
<!--begin::Code-->
|
|
1421
|
+
<div class="py-5">
|
|
1422
|
+
<!--begin::Highlight-->
|
|
1423
|
+
<div class="highlight">
|
|
1424
|
+
<button class="highlight-copy btn" data-bs-toggle="tooltip" title="Copy code">copy</button>
|
|
1425
|
+
<div class="highlight-code">
|
|
1426
|
+
<pre class="language-javascript"><code class="language-javascript">hook_handle_error: (err, req, res, next) => {
|
|
1427
|
+
if (err.status === 404)
|
|
1428
|
+
// If the URL cannot be found, a 404 error screen (views/error-404.hbs) is displayed.
|
|
1429
|
+
res.render('error-404');
|
|
1430
|
+
else
|
|
1431
|
+
// For other errors, unknown error screen (views/error-unknown.hbs) is displayed.
|
|
1432
|
+
res.render('error-unknown');
|
|
1433
|
+
},</code></pre>
|
|
1434
|
+
</div>
|
|
1435
|
+
</div>
|
|
1436
|
+
<!--end::Highlight-->
|
|
1437
|
+
</div>
|
|
1438
|
+
<!--end::Code-->
|
|
1439
|
+
</td>
|
|
1440
|
+
</tr>
|
|
1412
1441
|
</tbody>
|
|
1413
1442
|
<!--end::Body-->
|
|
1414
1443
|
</table>
|
|
@@ -5753,11 +5782,30 @@ await BookModel.query("SELECT * FROM book", {type: BookModel.QueryType
|
|
|
5753
5782
|
</td>
|
|
5754
5783
|
</tr>
|
|
5755
5784
|
<tr>
|
|
5756
|
-
<td class="w-250px"><code>failure_redirect: string</code></td>
|
|
5785
|
+
<td class="w-250px"><code>failure_redirect: string|((req: express.Request, res: express.Response) => string)</code></td>
|
|
5757
5786
|
<td>
|
|
5758
5787
|
Specify the URL to redirect after logging out, or the URL to redirect when the logoff user requests a URL that only the logged-in user can access.<br>
|
|
5759
5788
|
This usually specifies the URL of the login page.<br>
|
|
5760
5789
|
The default is <code>/login</code>.
|
|
5790
|
+
<!--begin::Code-->
|
|
5791
|
+
<div class="py-5">
|
|
5792
|
+
<!--begin::Highlight-->
|
|
5793
|
+
<div class="highlight">
|
|
5794
|
+
<button class="highlight-copy btn" data-bs-toggle="tooltip" title="Copy code">copy</button>
|
|
5795
|
+
<div class="highlight-code">
|
|
5796
|
+
<pre class="language-javascript"><code class="language-javascript">// Set the URL to redirect to in case of login failure as a string.
|
|
5797
|
+
failure_redirect: '/login',
|
|
5798
|
+
|
|
5799
|
+
// Dynamically set the url to redirect to on login failure.
|
|
5800
|
+
failure_redirect: (req, res) => {
|
|
5801
|
+
// If the role stored in the cookie is admin, redirect to the admin login screen.
|
|
5802
|
+
return req.cookies.role === 'admin' ? '/adminlogin' : 'login';
|
|
5803
|
+
},</code></pre>
|
|
5804
|
+
</div>
|
|
5805
|
+
</div>
|
|
5806
|
+
<!--end::Highlight-->
|
|
5807
|
+
</div>
|
|
5808
|
+
<!--end::Code-->
|
|
5761
5809
|
</td>
|
|
5762
5810
|
</tr>
|
|
5763
5811
|
<tr>
|
|
@@ -5881,30 +5929,6 @@ await BookModel.query("SELECT * FROM book", {type: BookModel.QueryType
|
|
|
5881
5929
|
The default is 24 hours (<code>86400000</code> milliseconds).
|
|
5882
5930
|
</td>
|
|
5883
5931
|
</tr>
|
|
5884
|
-
<tr>
|
|
5885
|
-
<td class="w-250px"><code>is_ajax: (req: express.Request) => boolean</code></td>
|
|
5886
|
-
<td>
|
|
5887
|
-
How to determine if it is an ajax request.<br>
|
|
5888
|
-
The default is that if there is an XMLHttpRequest in the request header (<code>req.xhr</code>) returns <code>true</code>.<br><br>
|
|
5889
|
-
For example, if there is no XMLHttpRequest in req(<code>express.Request</code>) and the Ajax endpoint starts with <code>/api</code>, a custom Ajax decision can be made like "<code>return /^\/api\//.test(req.path)</code>".<br>
|
|
5890
|
-
<!--begin::Code-->
|
|
5891
|
-
<div class="py-5">
|
|
5892
|
-
<!--begin::Highlight-->
|
|
5893
|
-
<div class="highlight">
|
|
5894
|
-
<button class="highlight-copy btn" data-bs-toggle="tooltip" title="Copy code">copy</button>
|
|
5895
|
-
<div class="highlight-code">
|
|
5896
|
-
<pre class="language-javascript"><code class="language-javascript">is_ajax: req => {
|
|
5897
|
-
// If the request URL begins with /api, it is assumed to be Ajax.
|
|
5898
|
-
return /^\/api/.test(req.path);
|
|
5899
|
-
// return !!req.xhr;
|
|
5900
|
-
}</code></pre>
|
|
5901
|
-
</div>
|
|
5902
|
-
</div>
|
|
5903
|
-
<!--end::Highlight-->
|
|
5904
|
-
</div>
|
|
5905
|
-
<!--end::Code-->
|
|
5906
|
-
</td>
|
|
5907
|
-
</tr>
|
|
5908
5932
|
</tbody>
|
|
5909
5933
|
<!--end::Body-->
|
|
5910
5934
|
</table>
|
|
@@ -6007,7 +6031,7 @@ router.post('/login', async (req, res, next) => {
|
|
|
6007
6031
|
if (isAuth)
|
|
6008
6032
|
Authentication.successRedirect(res);
|
|
6009
6033
|
else
|
|
6010
|
-
Authentication.failureRedirect(res);
|
|
6034
|
+
Authentication.failureRedirect(req, res);
|
|
6011
6035
|
});
|
|
6012
6036
|
export default router;</code></pre>
|
|
6013
6037
|
</div>
|
|
@@ -6023,7 +6047,7 @@ router.post('/login', async (req, res, next) => {
|
|
|
6023
6047
|
if (isAuth)
|
|
6024
6048
|
Authentication.successRedirect(res);
|
|
6025
6049
|
else
|
|
6026
|
-
Authentication.failureRedirect(res);
|
|
6050
|
+
Authentication.failureRedirect(req, res);
|
|
6027
6051
|
});
|
|
6028
6052
|
module.exports = router;</code></pre>
|
|
6029
6053
|
</div>
|
package/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import Database from '
|
|
2
|
-
import Model from '
|
|
3
|
-
import loadModels from '
|
|
1
|
+
import Database from '~/database/Database';
|
|
2
|
+
import Model from '~/database/Model';
|
|
3
|
+
import loadModels from '~/database/loadModels';
|
|
4
4
|
export { Database, Model, loadModels };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import CollectionCreationError from '
|
|
2
|
-
import CollectionDeletionError from '
|
|
3
|
-
import FaceIndexError from '
|
|
4
|
-
import MissingFaceInImageError from '
|
|
5
|
-
import MultipleFacesInImageError from '
|
|
1
|
+
import CollectionCreationError from '~/exceptions/CollectionCreationError';
|
|
2
|
+
import CollectionDeletionError from '~/exceptions/CollectionDeletionError';
|
|
3
|
+
import FaceIndexError from '~/exceptions/FaceIndexError';
|
|
4
|
+
import MissingFaceInImageError from '~/exceptions/MissingFaceInImageError';
|
|
5
|
+
import MultipleFacesInImageError from '~/exceptions/MultipleFacesInImageError';
|
|
6
6
|
export { CollectionCreationError, CollectionDeletionError, FaceIndexError, MissingFaceInImageError, MultipleFacesInImageError, };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import * as html from '
|
|
2
|
-
import * as object from '
|
|
3
|
-
import * as string from '
|
|
4
|
-
import * as comparison from '
|
|
5
|
-
import * as date from '
|
|
6
|
-
import * as number from '
|
|
1
|
+
import * as html from '~/handlebars_helpers/html';
|
|
2
|
+
import * as object from '~/handlebars_helpers/object';
|
|
3
|
+
import * as string from '~/handlebars_helpers/string';
|
|
4
|
+
import * as comparison from '~/handlebars_helpers/comparison';
|
|
5
|
+
import * as date from '~/handlebars_helpers/date';
|
|
6
|
+
import * as number from '~/handlebars_helpers/number';
|
|
7
7
|
export { html, object, string, comparison, date, number, };
|
package/types/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import mount from '
|
|
2
|
-
import * as database from '
|
|
3
|
-
import * as services from '
|
|
4
|
-
import * as utils from '
|
|
5
|
-
import * as middlewares from '
|
|
6
|
-
import * as exceptions from '
|
|
7
|
-
import * as interfaces from '
|
|
1
|
+
import mount from '~/mount';
|
|
2
|
+
import * as database from '~/database';
|
|
3
|
+
import * as services from '~/services';
|
|
4
|
+
import * as utils from '~/utils';
|
|
5
|
+
import * as middlewares from '~/middlewares';
|
|
6
|
+
import * as exceptions from '~/exceptions';
|
|
7
|
+
import * as interfaces from '~/interfaces';
|
|
8
8
|
export { mount, database, services, utils, middlewares, exceptions, interfaces };
|
|
@@ -38,9 +38,20 @@ export default interface {
|
|
|
38
38
|
success_redirect: string;
|
|
39
39
|
/**
|
|
40
40
|
* URL to redirect after log off, defaults to `/login`.
|
|
41
|
-
*
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* // Set the URL to redirect to in case of login failure as a string.
|
|
44
|
+
* failure_redirect: '/login',
|
|
45
|
+
*
|
|
46
|
+
* // Dynamically set the url to redirect to on login failure.
|
|
47
|
+
* failure_redirect: (req, res) => {
|
|
48
|
+
* // If the role stored in the cookie is admin, redirect to the admin login screen.
|
|
49
|
+
* return req.cookies.role === 'admin' ? '/adminlogin' : 'login';
|
|
50
|
+
* },
|
|
51
|
+
*
|
|
52
|
+
* @type {string|((req: express.Request, res: express.Response) => string)}
|
|
42
53
|
*/
|
|
43
|
-
failure_redirect: string;
|
|
54
|
+
failure_redirect: string | ((req: express.Request, res: express.Response) => string);
|
|
44
55
|
/**
|
|
45
56
|
* This hook is called when authenticating a user.
|
|
46
57
|
* Please find the user information that owns the credentials based on the user name and password you received and return it.
|
|
@@ -94,18 +105,4 @@ export default interface {
|
|
|
94
105
|
* @type {number}
|
|
95
106
|
*/
|
|
96
107
|
expiration: number;
|
|
97
|
-
/**
|
|
98
|
-
* How to determine if it is an ajax request.
|
|
99
|
-
* The default is that if there is an XMLHttpRequest in the request header (req.xhr) returns true.
|
|
100
|
-
* For example, if there is no XMLHttpRequest in req(express.Request) and the Ajax endpoint starts with /api, a custom Ajax decision can be made like "return /^\/api\//.test(req.path)".
|
|
101
|
-
*
|
|
102
|
-
* @type {(req: express.Request) => boolean}
|
|
103
|
-
* @example
|
|
104
|
-
* is_ajax: req => {
|
|
105
|
-
* // If the request URL begins with /api, it is assumed to be Ajax.
|
|
106
|
-
* return /^\/api/.test(req.path);
|
|
107
|
-
* // return !!req.xhr;
|
|
108
|
-
* }
|
|
109
|
-
*/
|
|
110
|
-
is_ajax: (req: express.Request) => boolean;
|
|
111
108
|
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import express from 'express';
|
|
2
|
+
/**
|
|
3
|
+
* Express Sweet basic configuration interface.
|
|
4
|
+
*/
|
|
5
|
+
export default interface {
|
|
6
|
+
/**
|
|
7
|
+
* Environment variable file (.env) path, defaults to none (undefined).
|
|
8
|
+
* @type {string}
|
|
9
|
+
*/
|
|
10
|
+
env_path?: string;
|
|
11
|
+
/**
|
|
12
|
+
* CORS permission, defaults to invalid (false).
|
|
13
|
+
* @type {{enabled: boolean}}
|
|
14
|
+
*/
|
|
15
|
+
cors_enabled?: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Maximum body size you can request, defaults to `100kb`.
|
|
18
|
+
* @type {string|number}
|
|
19
|
+
*/
|
|
20
|
+
max_body_size?: string | number;
|
|
21
|
+
/**
|
|
22
|
+
* Absolute path to the router directory, defaults to `<application root directory>/routes`.
|
|
23
|
+
* @type {string}
|
|
24
|
+
*/
|
|
25
|
+
router_dir?: string;
|
|
26
|
+
/**
|
|
27
|
+
* The endpoint to run when the root URL is requested, defaults to none (undefined).
|
|
28
|
+
* @type {string}
|
|
29
|
+
*/
|
|
30
|
+
default_router?: string;
|
|
31
|
+
/**
|
|
32
|
+
* This is a hook that rewrites the base URL.
|
|
33
|
+
* If you want to rewrite the app.locals.baseUrl property and the view's baseUrl variable, use this hook to return a new base URL.
|
|
34
|
+
* The default value is the referrer's origin (eg https://example.com).
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* rewrite_base_url: baseUrl => {
|
|
38
|
+
* return `${baseUrl}/admin`;
|
|
39
|
+
* }
|
|
40
|
+
*
|
|
41
|
+
* @type {(baseUrl: string): string}
|
|
42
|
+
*/
|
|
43
|
+
rewrite_base_url?: (baseUrl: string) => string;
|
|
44
|
+
/**
|
|
45
|
+
* How to determine if it is an ajax request.
|
|
46
|
+
* The default is that if there is an XMLHttpRequest in the request header (req.xhr) returns true.
|
|
47
|
+
* For example, if there is no XMLHttpRequest in req(express.Request) and the Ajax endpoint starts with /api, a custom Ajax decision can be made like "return /^\/api\//.test(req.path)".
|
|
48
|
+
*
|
|
49
|
+
* @type {(req: express.Request) => boolean}
|
|
50
|
+
* @example
|
|
51
|
+
* is_ajax: req => {
|
|
52
|
+
* // If the request URL begins with /api, it is assumed to be Ajax.
|
|
53
|
+
* return /^\/api/.test(req.path);
|
|
54
|
+
* // return !!req.xhr;
|
|
55
|
+
* }
|
|
56
|
+
*/
|
|
57
|
+
is_ajax: (req: express.Request) => boolean;
|
|
58
|
+
/**
|
|
59
|
+
* Hooks the default behavior on request errors.
|
|
60
|
+
* If unset, simply returns an error HTTP status. (<code>res.status(err.status||500).end();</code>)
|
|
61
|
+
*
|
|
62
|
+
* @type {(err: any, req: express.Request, res: express.Response, next: express.NextFunction) => void}
|
|
63
|
+
* @example
|
|
64
|
+
* hook_handle_error: (err, req, res, next) => {
|
|
65
|
+
* if (err.status === 404)
|
|
66
|
+
* // If the URL cannot be found, a 404 error screen (views/error-404.hbs) is displayed.
|
|
67
|
+
* res.render('error-404');
|
|
68
|
+
* else
|
|
69
|
+
* // For other errors, unknown error screen (views/error-unknown.hbs) is displayed.
|
|
70
|
+
* res.render('error-unknown');
|
|
71
|
+
* },
|
|
72
|
+
*/
|
|
73
|
+
hook_handle_error?: (err: any, req: express.Request, res: express.Response, next: express.NextFunction) => void;
|
|
74
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import BoundingBox from '
|
|
1
|
+
import BoundingBox from '~/interfaces/BoundingBox';
|
|
2
2
|
/**
|
|
3
3
|
* This is the metadata structure of the bounding box coordinates, reliability (the bounding box contains a face), face ID, etc. returned by the searchFaces(), listFaces() methods, etc.
|
|
4
4
|
*/
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import FaceMatch from '
|
|
5
|
-
import BoundingBox from '
|
|
6
|
-
import RekognitionOptions from '
|
|
7
|
-
import SesOptions from '
|
|
8
|
-
import
|
|
9
|
-
export {
|
|
1
|
+
import AuthenticationConfig from '~/interfaces/AuthenticationConfig';
|
|
2
|
+
import BasicConfig from '~/interfaces/BasicConfig';
|
|
3
|
+
import DatabaseConfig from '~/interfaces/DatabaseConfig';
|
|
4
|
+
import FaceMatch from '~/interfaces/FaceMatch';
|
|
5
|
+
import BoundingBox from '~/interfaces/BoundingBox';
|
|
6
|
+
import RekognitionOptions from '~/interfaces/RekognitionOptions';
|
|
7
|
+
import SesOptions from '~/interfaces/SesOptions';
|
|
8
|
+
import ViewConfig from '~/interfaces/ViewConfig';
|
|
9
|
+
export { AuthenticationConfig, BasicConfig, DatabaseConfig, FaceMatch, BoundingBox, RekognitionOptions, SesOptions, ViewConfig };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import CORS from '
|
|
2
|
-
import Environment from '
|
|
3
|
-
import Global from '
|
|
4
|
-
import Http from '
|
|
5
|
-
import Local from '
|
|
6
|
-
import View from '
|
|
7
|
-
import
|
|
8
|
-
export { CORS, Environment, Global, Http, Local, View,
|
|
1
|
+
import CORS from '~/middlewares/CORS';
|
|
2
|
+
import Environment from '~/middlewares/Environment';
|
|
3
|
+
import Global from '~/middlewares/Global';
|
|
4
|
+
import Http from '~/middlewares/Http';
|
|
5
|
+
import Local from '~/middlewares/Local';
|
|
6
|
+
import View from '~/middlewares/View';
|
|
7
|
+
import ErrorHandler from '~/middlewares/ErrorHandler';
|
|
8
|
+
export { CORS, Environment, Global, Http, Local, View, ErrorHandler, };
|
package/types/routing/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import Router from '
|
|
1
|
+
import Router from '~/routing/Router';
|
|
2
2
|
export { Router };
|
|
@@ -3,7 +3,6 @@ import express from 'express';
|
|
|
3
3
|
* User authentication service.
|
|
4
4
|
*/
|
|
5
5
|
export default class {
|
|
6
|
-
#private;
|
|
7
6
|
/**
|
|
8
7
|
* Authenticate the user.
|
|
9
8
|
*
|
|
@@ -28,7 +27,8 @@ export default class {
|
|
|
28
27
|
/**
|
|
29
28
|
* Redirects to the page that responds immediately after authentication failure set in "failure_redirect" of "config/authentication.js".
|
|
30
29
|
*
|
|
30
|
+
* @param {express.Request} req The req object represents the HTTP request and has properties for the request query string, parameters, body, HTTP headers, and so on.
|
|
31
31
|
* @param {express.Response} res The res object represents the HTTP response that an Express app sends when it gets an HTTP request.
|
|
32
32
|
*/
|
|
33
|
-
static failureRedirect(res: express.Response): void;
|
|
33
|
+
static failureRedirect(req: express.Request, res: express.Response): void;
|
|
34
34
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import AWSRekognitionClient from '
|
|
2
|
-
import Authentication from '
|
|
3
|
-
import AWSSesClient from '
|
|
1
|
+
import AWSRekognitionClient from '~/services/AWSRekognitionClient';
|
|
2
|
+
import Authentication from '~/services/Authentication';
|
|
3
|
+
import AWSSesClient from '~/services/AWSSesClient';
|
|
4
4
|
export { AWSRekognitionClient, Authentication, AWSSesClient, };
|
package/types/utils/index.d.ts
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
declare const _default: {
|
|
2
|
-
isAsyncFunction: (value: Function) => boolean;
|
|
3
|
-
isString: (value: any) => boolean;
|
|
4
|
-
isObject: (value: any) => boolean;
|
|
5
2
|
isArray: (value: any) => boolean;
|
|
3
|
+
isAsyncFunction: (value: any) => boolean;
|
|
4
|
+
isFunction: (value: any) => boolean;
|
|
5
|
+
isObject: (value: any) => boolean;
|
|
6
|
+
isString: (value: any) => boolean;
|
|
7
|
+
loadAuthenticationConfig: () => import("../interfaces").AuthenticationConfig;
|
|
8
|
+
loadBasicConfig: () => import("../interfaces").BasicConfig;
|
|
9
|
+
loadDatabaseConfig: () => import("sequelize").Options;
|
|
10
|
+
loadViewConfig: () => import("../interfaces").ViewConfig;
|
|
6
11
|
};
|
|
7
12
|
export default _default;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
declare const _default: (value:
|
|
2
|
+
* Returns true for asynchronous functions, false otherwise.
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* utils.isAsyncFunction(async () => {});// true
|
|
6
|
+
* utils.isAsyncFunction(() => {});// false
|
|
7
|
+
*
|
|
8
|
+
* @param {any} value
|
|
9
|
+
* @return {boolean}
|
|
10
|
+
*/
|
|
11
|
+
declare const _default: (value: any) => boolean;
|
|
12
12
|
export default _default;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns true for functions, false otherwise.
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* utils.isFunction(() => {});// true
|
|
6
|
+
* utils.isFunction(async () => {});// true
|
|
7
|
+
* utils.isFunction('');// false
|
|
8
|
+
*
|
|
9
|
+
* @param {any} value
|
|
10
|
+
* @return {boolean}
|
|
11
|
+
*/
|
|
12
|
+
declare const _default: (value: any) => boolean;
|
|
13
|
+
export default _default;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import AuthenticationConfig from '~/interfaces/AuthenticationConfig';
|
|
2
|
+
/**
|
|
3
|
+
* Get Authentication configuration (config/authentication).
|
|
4
|
+
*
|
|
5
|
+
* @return {AuthenticationConfig} Loaded configuration.
|
|
6
|
+
*/
|
|
7
|
+
declare const _default: () => AuthenticationConfig;
|
|
8
|
+
export default _default;
|