express-sweet 2.0.9 → 3.0.1
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 +69 -1
- package/README.md +1039 -2137
- package/configuration_sample/cjs/authentication.js +50 -15
- package/configuration_sample/cjs/config.js +38 -21
- package/configuration_sample/cjs/database.js +90 -4
- package/configuration_sample/cjs/logging.js +41 -0
- package/configuration_sample/cjs/view.js +19 -1
- package/configuration_sample/esm/authentication.js +48 -15
- package/configuration_sample/esm/config.js +39 -22
- package/configuration_sample/esm/database.js +90 -4
- package/configuration_sample/esm/logging.js +41 -0
- package/configuration_sample/esm/view.js +20 -2
- package/dist/build.cjs +8 -8
- package/dist/build.mjs +4 -4
- package/package.json +9 -4
- package/types/database/DatabaseManager.d.ts +95 -0
- package/types/database/Model.d.ts +183 -20
- package/types/database/index.d.ts +47 -3
- package/types/database/loadModels.d.ts +19 -4
- package/types/handlebars_helpers/array.d.ts +3 -1
- package/types/handlebars_helpers/comparison.d.ts +55 -19
- package/types/handlebars_helpers/date.d.ts +3 -1
- package/types/handlebars_helpers/html.d.ts +6 -2
- package/types/handlebars_helpers/index.d.ts +73 -9
- package/types/handlebars_helpers/layouts.d.ts +5 -1
- package/types/handlebars_helpers/math.d.ts +21 -7
- package/types/handlebars_helpers/number.d.ts +3 -1
- package/types/handlebars_helpers/object.d.ts +6 -2
- package/types/handlebars_helpers/string.d.ts +9 -3
- package/types/index.d.ts +92 -5
- package/types/interfaces/AuthenticationConfig.d.ts +38 -1
- package/types/interfaces/BasicConfig.d.ts +26 -1
- package/types/interfaces/DatabaseConfig.d.ts +45 -1
- package/types/interfaces/LoggingConfig.d.ts +49 -0
- package/types/interfaces/ViewConfig.d.ts +21 -2
- package/types/interfaces/index.d.ts +25 -11
- package/types/middlewares/Authentication.d.ts +43 -6
- package/types/middlewares/CORS.d.ts +23 -5
- package/types/middlewares/Environment.d.ts +30 -4
- package/types/middlewares/ErrorHandler.d.ts +27 -5
- package/types/middlewares/Global.d.ts +20 -6
- package/types/middlewares/Http.d.ts +22 -5
- package/types/middlewares/Local.d.ts +35 -8
- package/types/middlewares/View.d.ts +39 -8
- package/types/middlewares/index.d.ts +47 -7
- package/types/mount.d.ts +16 -3
- package/types/routing/Router.d.ts +49 -7
- package/types/routing/index.d.ts +37 -1
- package/types/services/Authentication.d.ts +79 -16
- package/types/services/index.d.ts +33 -1
- package/types/types/global.d.ts +29 -8
- package/types/utils/Types.d.ts +5 -3
- package/types/utils/index.d.ts +71 -9
- package/types/utils/isArray.d.ts +12 -3
- package/types/utils/isAsyncFunction.d.ts +12 -5
- package/types/utils/isFunction.d.ts +13 -6
- package/types/utils/isObject.d.ts +14 -3
- package/types/utils/isString.d.ts +15 -4
- package/types/utils/loadAuthenticationConfig.d.ts +13 -3
- package/types/utils/loadBasicConfig.d.ts +13 -3
- package/types/utils/loadDatabaseConfig.d.ts +34 -3
- package/types/utils/loadLoggingConfig.d.ts +16 -0
- package/types/utils/loadViewConfig.d.ts +28 -3
- package/types/database/Database.d.ts +0 -18
- package/types/interfaces/BoundingBox.d.ts +0 -25
- package/types/interfaces/FaceDetails.d.ts +0 -30
- package/types/interfaces/FaceDetailsEmotions.d.ts +0 -40
- package/types/interfaces/FaceMatch.d.ts +0 -31
- package/types/interfaces/IndexFaceDetails.d.ts +0 -29
- package/types/interfaces/RekognitionOptions.d.ts +0 -26
- package/types/interfaces/SesOptions.d.ts +0 -27
|
@@ -1,7 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
* Check if a value is a non-empty string.
|
|
3
|
+
* Returns true only for strings with content, false for empty strings or other types.
|
|
4
|
+
* @param {any} value The value to check
|
|
5
|
+
* @returns {boolean} Returns true if value is a non-empty string, false otherwise
|
|
6
|
+
* @example
|
|
7
|
+
* ```js
|
|
8
|
+
* import isString from '~/utils/isString';
|
|
9
|
+
*
|
|
10
|
+
* isString('hello'); // true
|
|
11
|
+
* isString(''); // false (empty string)
|
|
12
|
+
* isString(' '); // true (space is content)
|
|
13
|
+
* isString(123); // false
|
|
14
|
+
* isString(null); // false
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
6
17
|
declare const _default: (value: any) => boolean;
|
|
7
18
|
export default _default;
|
|
@@ -1,7 +1,17 @@
|
|
|
1
1
|
import AuthenticationConfig from '~/interfaces/AuthenticationConfig';
|
|
2
2
|
/**
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
* Load authentication configuration from config/authentication.js file.
|
|
4
|
+
* Returns default authentication configuration if config file doesn't exist.
|
|
5
|
+
* @returns {Promise<AuthenticationConfig>} The loaded authentication configuration with defaults
|
|
6
|
+
* @example
|
|
7
|
+
* ```js
|
|
8
|
+
* import loadAuthenticationConfig from '~/utils/loadAuthenticationConfig';
|
|
9
|
+
*
|
|
10
|
+
* const config = await loadAuthenticationConfig();
|
|
11
|
+
* console.log(config.enabled); // false (default)
|
|
12
|
+
* console.log(config.username); // 'username' (default)
|
|
13
|
+
* console.log(config.success_redirect); // '/' (default)
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
6
16
|
declare const _default: () => Promise<AuthenticationConfig>;
|
|
7
17
|
export default _default;
|
|
@@ -1,7 +1,17 @@
|
|
|
1
1
|
import BasicConfig from '~/interfaces/BasicConfig';
|
|
2
2
|
/**
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
* Load basic application configuration from config/config.js file.
|
|
4
|
+
* Returns default configuration if config file doesn't exist.
|
|
5
|
+
* @returns {Promise<BasicConfig>} The loaded basic configuration with defaults
|
|
6
|
+
* @example
|
|
7
|
+
* ```js
|
|
8
|
+
* import loadBasicConfig from '~/utils/loadBasicConfig';
|
|
9
|
+
*
|
|
10
|
+
* const config = await loadBasicConfig();
|
|
11
|
+
* console.log(config.cors_enabled); // false (default)
|
|
12
|
+
* console.log(config.max_body_size); // '100kb' (default)
|
|
13
|
+
* console.log(config.router_dir); // '/path/to/app/routes' (default)
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
6
16
|
declare const _default: () => Promise<BasicConfig>;
|
|
7
17
|
export default _default;
|
|
@@ -1,7 +1,38 @@
|
|
|
1
1
|
import sequelize from 'sequelize';
|
|
2
2
|
/**
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
* Load database configuration from config/database.js file.
|
|
4
|
+
* Returns environment-specific configuration based on NODE_ENV.
|
|
5
|
+
* @returns {Promise<sequelize.Options>} The loaded database configuration for current environment
|
|
6
|
+
* @example
|
|
7
|
+
* ```js
|
|
8
|
+
* import loadDatabaseConfig from '~/utils/loadDatabaseConfig';
|
|
9
|
+
*
|
|
10
|
+
* const config = await loadDatabaseConfig();
|
|
11
|
+
* console.log(config.database); // Database name for current environment
|
|
12
|
+
* console.log(config.host); // Database host
|
|
13
|
+
* console.log(config.dialect); // Database dialect (mariadb, mysql, etc.)
|
|
14
|
+
* ```
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```js
|
|
18
|
+
* // config/database.js structure
|
|
19
|
+
* export default {
|
|
20
|
+
* development: {
|
|
21
|
+
* username: 'root',
|
|
22
|
+
* password: 'password',
|
|
23
|
+
* database: 'myapp_dev',
|
|
24
|
+
* host: 'localhost',
|
|
25
|
+
* dialect: 'mariadb'
|
|
26
|
+
* },
|
|
27
|
+
* production: {
|
|
28
|
+
* username: 'root',
|
|
29
|
+
* password: 'password',
|
|
30
|
+
* database: 'myapp_prod',
|
|
31
|
+
* host: 'localhost',
|
|
32
|
+
* dialect: 'mariadb'
|
|
33
|
+
* }
|
|
34
|
+
* }
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
6
37
|
declare const _default: () => Promise<sequelize.Options>;
|
|
7
38
|
export default _default;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import LoggingConfig from '~/interfaces/LoggingConfig';
|
|
2
|
+
/**
|
|
3
|
+
* Load logging configuration from config/logging.js file.
|
|
4
|
+
* Returns default logging configuration if config file doesn't exist.
|
|
5
|
+
* @returns {Promise<LoggingConfig>} The loaded logging configuration with defaults
|
|
6
|
+
* @example
|
|
7
|
+
* ```js
|
|
8
|
+
* import loadLoggingConfig from '~/utils/loadLoggingConfig';
|
|
9
|
+
*
|
|
10
|
+
* const config = await loadLoggingConfig();
|
|
11
|
+
* console.log(config.format); // 'combined' (default)
|
|
12
|
+
* console.log(config.skip); // undefined (default)
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
declare const _default: () => Promise<LoggingConfig>;
|
|
16
|
+
export default _default;
|
|
@@ -1,7 +1,32 @@
|
|
|
1
1
|
import ViewConfig from '~/interfaces/ViewConfig';
|
|
2
2
|
/**
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
* Load view configuration from config/view.js file.
|
|
4
|
+
* Returns default Handlebars view configuration if config file doesn't exist.
|
|
5
|
+
* @returns {Promise<ViewConfig>} The loaded view configuration with defaults
|
|
6
|
+
* @example
|
|
7
|
+
* ```js
|
|
8
|
+
* import loadViewConfig from '~/utils/loadViewConfig';
|
|
9
|
+
*
|
|
10
|
+
* const config = await loadViewConfig();
|
|
11
|
+
* console.log(config.views_dir); // 'views' (default)
|
|
12
|
+
* console.log(config.extension); // '.hbs' (default)
|
|
13
|
+
* console.log(config.layouts_dir); // 'views/layout' (default)
|
|
14
|
+
* ```
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```js
|
|
18
|
+
* // config/view.js structure
|
|
19
|
+
* export default {
|
|
20
|
+
* views_dir: 'views',
|
|
21
|
+
* partials_dir: 'views/partials',
|
|
22
|
+
* layouts_dir: 'views/layout',
|
|
23
|
+
* default_layout: 'views/layout/default',
|
|
24
|
+
* extension: '.hbs',
|
|
25
|
+
* beforeRender: (req, res) => {
|
|
26
|
+
* res.locals.extra = 'Extra';
|
|
27
|
+
* }
|
|
28
|
+
* };
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
6
31
|
declare const _default: () => Promise<ViewConfig>;
|
|
7
32
|
export default _default;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import sequelize from 'sequelize';
|
|
2
|
-
/**
|
|
3
|
-
* Database class.
|
|
4
|
-
*/
|
|
5
|
-
export default class extends sequelize.Sequelize {
|
|
6
|
-
/**
|
|
7
|
-
* Returns true if the DB can be connected.
|
|
8
|
-
* @return {Promise<boolean>} Returns true if it can connect to the database, false if it cannot.
|
|
9
|
-
*/
|
|
10
|
-
isConnect(): Promise<boolean>;
|
|
11
|
-
/**
|
|
12
|
-
* Returns the current database configuration.
|
|
13
|
-
* @return {object} Database configuration object containing all sequelize options
|
|
14
|
-
* @see {@link https://sequelize.org/docs/v6/other-topics/dialect-specific-things/ | Sequelize Dialect Options}
|
|
15
|
-
* @see {@link https://sequelize.org/api/v6/class/src/sequelize.js~sequelize#instance-constructor-options | Sequelize Constructor Options}
|
|
16
|
-
*/
|
|
17
|
-
getConfig(): object;
|
|
18
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Bounding box of the face.
|
|
3
|
-
*/
|
|
4
|
-
export default interface BoundingBox {
|
|
5
|
-
/**
|
|
6
|
-
* The width of the bounding box.
|
|
7
|
-
* @type {number}
|
|
8
|
-
*/
|
|
9
|
-
width: number;
|
|
10
|
-
/**
|
|
11
|
-
* The height of the bounding box.
|
|
12
|
-
* @type {number}
|
|
13
|
-
*/
|
|
14
|
-
height: number;
|
|
15
|
-
/**
|
|
16
|
-
* The x coordinate of the bounding box with the origin (0,0) in the upper left corner.
|
|
17
|
-
* @type {number}
|
|
18
|
-
*/
|
|
19
|
-
left: number;
|
|
20
|
-
/**
|
|
21
|
-
* The y coordinate of the bounding box with the origin (0,0) in the upper left corner.
|
|
22
|
-
* @type {number}
|
|
23
|
-
*/
|
|
24
|
-
top: number;
|
|
25
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import BoundingBox from '~/interfaces/BoundingBox';
|
|
2
|
-
import FaceDetailsEmotions from '~/interfaces/FaceDetailsEmotions';
|
|
3
|
-
/**
|
|
4
|
-
* Details of each face found in the image.
|
|
5
|
-
*/
|
|
6
|
-
export default interface FaceDetails {
|
|
7
|
-
/**
|
|
8
|
-
* Bounding box of the face.
|
|
9
|
-
* @type {BoundingBox}
|
|
10
|
-
*/
|
|
11
|
-
boundingBox: BoundingBox;
|
|
12
|
-
/**
|
|
13
|
-
* The estimated age range, in years, for the face. Low represents the lowest estimated age and High represents the highest estimated age.
|
|
14
|
-
* @type {{high: number, low: number}}
|
|
15
|
-
*/
|
|
16
|
-
ageRange?: {
|
|
17
|
-
high: number;
|
|
18
|
-
low: number;
|
|
19
|
-
};
|
|
20
|
-
/**
|
|
21
|
-
* The predicted gender of a detected face.
|
|
22
|
-
* @type {'male'|'female'}
|
|
23
|
-
*/
|
|
24
|
-
gender?: 'male' | 'female';
|
|
25
|
-
/**
|
|
26
|
-
* The emotions that appear to be expressed on the face, and the confidence level in the determination.
|
|
27
|
-
* @type {FaceDetailsEmotions}
|
|
28
|
-
*/
|
|
29
|
-
emotions?: FaceDetailsEmotions;
|
|
30
|
-
}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The emotions that appear to be expressed on the face, and the confidence level in the determination.
|
|
3
|
-
*/
|
|
4
|
-
export default interface FaceDetailsEmotions {
|
|
5
|
-
/**
|
|
6
|
-
* Confidence level of "disgusted" predicted from the face.
|
|
7
|
-
* @type {number}
|
|
8
|
-
*/
|
|
9
|
-
disgusted: number;
|
|
10
|
-
/**
|
|
11
|
-
* Confidence level of "happy" predicted from the face.
|
|
12
|
-
* @type {number}
|
|
13
|
-
*/
|
|
14
|
-
happy: number;
|
|
15
|
-
/**
|
|
16
|
-
* Confidence level of "surprised" predicted from the face.
|
|
17
|
-
* @type {number}
|
|
18
|
-
*/
|
|
19
|
-
surprised: number;
|
|
20
|
-
/**
|
|
21
|
-
* Confidence level of "angry" predicted from the face.
|
|
22
|
-
* @type {number}
|
|
23
|
-
*/
|
|
24
|
-
angry: number;
|
|
25
|
-
/**
|
|
26
|
-
* Confidence level of "confused" predicted from the face.
|
|
27
|
-
* @type {number}
|
|
28
|
-
*/
|
|
29
|
-
confused: number;
|
|
30
|
-
/**
|
|
31
|
-
* Confidence level of "calm" predicted from the face.
|
|
32
|
-
* @type {number}
|
|
33
|
-
*/
|
|
34
|
-
calm: number;
|
|
35
|
-
/**
|
|
36
|
-
* Confidence level of "sad" predicted from the face.
|
|
37
|
-
* @type {number}
|
|
38
|
-
*/
|
|
39
|
-
sad: number;
|
|
40
|
-
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import BoundingBox from '~/interfaces/BoundingBox';
|
|
2
|
-
/**
|
|
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
|
-
*/
|
|
5
|
-
export default interface FaceMatch {
|
|
6
|
-
/**
|
|
7
|
-
* A unique identifier assigned to the face.
|
|
8
|
-
* @type {string}
|
|
9
|
-
*/
|
|
10
|
-
faceId: string;
|
|
11
|
-
/**
|
|
12
|
-
* Bounding box of the face.
|
|
13
|
-
* width : Width of the bounding box as a ratio of the overall image width.
|
|
14
|
-
* height : Height of the bounding box as a ratio of the overall image height.
|
|
15
|
-
* left : Left coordinate of the bounding box as a ratio of overall image width.
|
|
16
|
-
* top : Top coordinate of the bounding box as a ratio of overall image height.
|
|
17
|
-
* @type {BoundingBox}
|
|
18
|
-
*/
|
|
19
|
-
boundingBox: BoundingBox;
|
|
20
|
-
/**
|
|
21
|
-
* Identifier that you assign to all the faces in the input image.
|
|
22
|
-
* @type {string}
|
|
23
|
-
*/
|
|
24
|
-
externalImageId?: string;
|
|
25
|
-
/**
|
|
26
|
-
* Confidence in the match of this face with the input face.
|
|
27
|
-
* Valid Range: Minimum value of 0. Maximum value of 100.
|
|
28
|
-
* @type {number}
|
|
29
|
-
*/
|
|
30
|
-
similarity?: number;
|
|
31
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import FaceDetailsEmotions from '~/interfaces/FaceDetailsEmotions';
|
|
2
|
-
/**
|
|
3
|
-
* Detail of indexed face.
|
|
4
|
-
*/
|
|
5
|
-
export default interface IndexFaceDetails {
|
|
6
|
-
/**
|
|
7
|
-
* A unique identifier assigned to the face.
|
|
8
|
-
* @type {string}
|
|
9
|
-
*/
|
|
10
|
-
faceId: string;
|
|
11
|
-
/**
|
|
12
|
-
* The estimated age range, in years, for the face. Low represents the lowest estimated age and High represents the highest estimated age.
|
|
13
|
-
* @type {{high: number, low: number}}
|
|
14
|
-
*/
|
|
15
|
-
ageRange: {
|
|
16
|
-
high: number;
|
|
17
|
-
low: number;
|
|
18
|
-
};
|
|
19
|
-
/**
|
|
20
|
-
* The predicted gender of a detected face.
|
|
21
|
-
* @type {'male'|'female'}
|
|
22
|
-
*/
|
|
23
|
-
gender: 'male' | 'female';
|
|
24
|
-
/**
|
|
25
|
-
* The emotions that appear to be expressed on the face, and the confidence level in the determination.
|
|
26
|
-
* @type {FaceDetailsEmotions}
|
|
27
|
-
*/
|
|
28
|
-
emotions: FaceDetailsEmotions;
|
|
29
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Rekognition Client Optional Interface.
|
|
3
|
-
*/
|
|
4
|
-
export default interface RekognitionOptions {
|
|
5
|
-
/**
|
|
6
|
-
* Your AWS access key ID.
|
|
7
|
-
* @type {string}
|
|
8
|
-
*/
|
|
9
|
-
accessKeyId: string;
|
|
10
|
-
/**
|
|
11
|
-
* Your AWS secret access key.
|
|
12
|
-
* @type {string}
|
|
13
|
-
*/
|
|
14
|
-
secretAccessKey: string;
|
|
15
|
-
/**
|
|
16
|
-
* The region to send service requests to.
|
|
17
|
-
* @type {string}
|
|
18
|
-
*/
|
|
19
|
-
region: string;
|
|
20
|
-
/**
|
|
21
|
-
* Sets the socket to timeout after failing to establish a connection with the server after connectTimeout milliseconds.
|
|
22
|
-
* The default is 5000 milliseconds.
|
|
23
|
-
* @type {number}
|
|
24
|
-
*/
|
|
25
|
-
timeout?: number;
|
|
26
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* AWS SES Client Optional Interface.
|
|
3
|
-
*/
|
|
4
|
-
export default interface SesOptions {
|
|
5
|
-
/**
|
|
6
|
-
* API version in YYYYY-MM-DD format (or date).
|
|
7
|
-
* Specify 'latest' to use the latest possible version.
|
|
8
|
-
* The default is 'latest'.
|
|
9
|
-
* @type {string}
|
|
10
|
-
*/
|
|
11
|
-
apiVersion: string;
|
|
12
|
-
/**
|
|
13
|
-
* The region to send service requests to.
|
|
14
|
-
* @type {string}
|
|
15
|
-
*/
|
|
16
|
-
region: string;
|
|
17
|
-
/**
|
|
18
|
-
* Your AWS access key ID.
|
|
19
|
-
* @type {string}
|
|
20
|
-
*/
|
|
21
|
-
accessKeyId: string;
|
|
22
|
-
/**
|
|
23
|
-
* Your AWS secret access key.
|
|
24
|
-
* @type {string}
|
|
25
|
-
*/
|
|
26
|
-
secretAccessKey: string;
|
|
27
|
-
}
|