express-sweet 1.0.35 → 1.0.37
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 +66 -1
- package/dist/build.common.js +11 -11
- package/dist/build.esm.js +12 -12
- package/docs/index.html +321 -38
- 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 +8 -7
- package/types/handlebars_helpers/math.d.ts +81 -0
- package/types/index.d.ts +7 -7
- package/types/interfaces/{AuthenticationOptions.d.ts → AuthenticationConfig.d.ts} +0 -14
- package/types/interfaces/BasicConfig.d.ts +74 -0
- package/types/interfaces/FaceMatch.d.ts +1 -1
- package/types/interfaces/{ViewOptions.d.ts → ViewConfig.d.ts} +2 -2
- 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 +0 -1
- package/types/services/index.d.ts +3 -3
- package/types/utils/index.d.ts +4 -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
|
@@ -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
|
*/
|
|
@@ -38,7 +38,7 @@ export default interface {
|
|
|
38
38
|
* res.locals.message = 'Hello World';
|
|
39
39
|
* }
|
|
40
40
|
*
|
|
41
|
-
* @type {(res: express.Response) => void}
|
|
41
|
+
* @type {(res: express.Response) => Promise<void>|void}
|
|
42
42
|
*/
|
|
43
|
-
beforeRender?: (req: express.Request, res: express.Response) => void;
|
|
43
|
+
beforeRender?: (req: express.Request, res: express.Response) => Promise<void> | void;
|
|
44
44
|
}
|
|
@@ -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 };
|
|
@@ -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
|
@@ -4,5 +4,9 @@ declare const _default: {
|
|
|
4
4
|
isFunction: (value: any) => boolean;
|
|
5
5
|
isObject: (value: any) => boolean;
|
|
6
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;
|
|
7
11
|
};
|
|
8
12
|
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;
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Express Sweet basic configuration interface.
|
|
3
|
-
*/
|
|
4
|
-
export default interface {
|
|
5
|
-
/**
|
|
6
|
-
* Environment variable file (.env) path, defaults to none (undefined).
|
|
7
|
-
* @type {string}
|
|
8
|
-
*/
|
|
9
|
-
env_path?: string;
|
|
10
|
-
/**
|
|
11
|
-
* CORS permission, defaults to invalid (false).
|
|
12
|
-
* @type {{enabled: boolean}}
|
|
13
|
-
*/
|
|
14
|
-
cors_enabled?: boolean;
|
|
15
|
-
/**
|
|
16
|
-
* Maximum body size you can request, defaults to `100kb`.
|
|
17
|
-
* @type {string|number}
|
|
18
|
-
*/
|
|
19
|
-
max_body_size?: string | number;
|
|
20
|
-
/**
|
|
21
|
-
* Absolute path to the router directory, defaults to `<application root directory>/routes`.
|
|
22
|
-
* @type {string}
|
|
23
|
-
*/
|
|
24
|
-
router_dir?: string;
|
|
25
|
-
/**
|
|
26
|
-
* The endpoint to run when the root URL is requested, defaults to none (undefined).
|
|
27
|
-
* @type {string}
|
|
28
|
-
*/
|
|
29
|
-
default_router?: string;
|
|
30
|
-
/**
|
|
31
|
-
* This is a hook that rewrites the base URL.
|
|
32
|
-
* 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.
|
|
33
|
-
* The default value is the referrer's origin (eg https://example.com).
|
|
34
|
-
*
|
|
35
|
-
* @example
|
|
36
|
-
* rewrite_base_url: baseUrl => {
|
|
37
|
-
* return `${baseUrl}/admin`;
|
|
38
|
-
* }
|
|
39
|
-
*
|
|
40
|
-
* @type {(baseUrl: string): string}
|
|
41
|
-
*/
|
|
42
|
-
rewrite_base_url?: (baseUrl: string) => string;
|
|
43
|
-
/**
|
|
44
|
-
* This is a hook for error handling.
|
|
45
|
-
* For example, you can use it when you want to send an external notification of the error received by this hook.
|
|
46
|
-
*
|
|
47
|
-
* @example
|
|
48
|
-
* error_handler: async err => {
|
|
49
|
-
* // Notify system administrator of error.
|
|
50
|
-
* return new Promise((resolve, reject) => {
|
|
51
|
-
* const sendmail = require('sendmail')();
|
|
52
|
-
* sendmail({
|
|
53
|
-
* from: 'no-reply@example.com',
|
|
54
|
-
* to: 'administrator@example.com',
|
|
55
|
-
* subject: 'Error occurred',
|
|
56
|
-
* text: err.message
|
|
57
|
-
* }, err => {
|
|
58
|
-
* err ? reject(err) : resolve();
|
|
59
|
-
* });
|
|
60
|
-
* });
|
|
61
|
-
* }
|
|
62
|
-
*
|
|
63
|
-
* @type {(err: any): void|Promise<void>}
|
|
64
|
-
*/
|
|
65
|
-
error_handler?: (err: any) => void | Promise<void>;
|
|
66
|
-
}
|
|
File without changes
|