express-sweet 1.0.27 → 1.0.29

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "express-sweet",
3
- "version": "1.0.27",
3
+ "version": "1.0.29",
4
4
  "description": "Express framework extension.",
5
5
  "main": "dist/build.common.js",
6
6
  "module": "dist/build.esm.js",
@@ -65,7 +65,10 @@
65
65
  },
66
66
  "homepage": "https://github.com/takuya-motoshima/express-sweet#readme",
67
67
  "dependencies": {
68
- "aws-sdk": "^2.1142.0",
68
+ "@aws-sdk/client-rekognition": "^3.352.0",
69
+ "@aws-sdk/client-ses": "^3.354.0",
70
+ "@aws-sdk/node-http-handler": "^3.350.0",
71
+ "@types/libmime": "^5.0.0",
69
72
  "body-parser": "^1.19.0",
70
73
  "class-transformer": "^0.2.3",
71
74
  "class-validator": "^0.12.2",
@@ -80,9 +83,11 @@
80
83
  "express-session": "^1.17.1",
81
84
  "fs-extra": "^9.0.1",
82
85
  "glob": "^7.1.6",
86
+ "handlebars-extd": "^1.0.7",
83
87
  "hbs": "~4.0.4",
84
88
  "http-errors": "~1.6.3",
85
89
  "ioredis": "^4.27.6",
90
+ "libmime": "^5.2.1",
86
91
  "mariadb": "^2.4.0",
87
92
  "mime-types": "^2.1.27",
88
93
  "module-alias": "^2.2.2",
@@ -97,7 +102,8 @@
97
102
  "uniqid": "^5.2.0"
98
103
  },
99
104
  "devDependencies": {
100
- "@types/aws-sdk": "^2.7.0",
105
+ "@aws-sdk/types": "^3.347.0",
106
+ "@rollup/plugin-alias": "^5.0.0",
101
107
  "@types/connect-redis": "^0.0.18",
102
108
  "@types/cookie-parser": "^1.4.2",
103
109
  "@types/debug": "^4.1.5",
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Collection creation error.
3
+ */
4
+ export default class extends Error {
5
+ /**
6
+ * @type {string}
7
+ */
8
+ name: string;
9
+ /**
10
+ * @param {string} message Error message.
11
+ */
12
+ constructor(message: string);
13
+ }
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Collection deletion error.
3
+ */
4
+ export default class extends Error {
5
+ /**
6
+ * @type {string}
7
+ */
8
+ name: string;
9
+ /**
10
+ * @param {string} message Error message.
11
+ */
12
+ constructor(message: string);
13
+ }
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Face index error.
3
+ */
4
+ export default class extends Error {
5
+ /**
6
+ * @type {string}
7
+ */
8
+ name: string;
9
+ /**
10
+ * @param {string} message Error message.
11
+ */
12
+ constructor(message: string);
13
+ }
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Missing face in image error.
3
+ */
4
+ export default class extends Error {
5
+ /**
6
+ * @type {string}
7
+ */
8
+ name: string;
9
+ /**
10
+ * @param {string} message Error message.
11
+ */
12
+ constructor(message?: string);
13
+ }
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Multiple faces in an image error.
3
+ */
4
+ export default class extends Error {
5
+ /**
6
+ * @type {string}
7
+ */
8
+ name: string;
9
+ /**
10
+ * @param {string} message Error message.
11
+ */
12
+ constructor(message?: string);
13
+ }
@@ -1,2 +1,6 @@
1
- import ApiError from './ApiError';
2
- export { ApiError };
1
+ import CollectionCreationError from './CollectionCreationError';
2
+ import CollectionDeletionError from './CollectionDeletionError';
3
+ import FaceIndexError from './FaceIndexError';
4
+ import MissingFaceInImageError from './MissingFaceInImageError';
5
+ import MultipleFacesInImageError from './MultipleFacesInImageError';
6
+ export { CollectionCreationError, CollectionDeletionError, FaceIndexError, MissingFaceInImageError, MultipleFacesInImageError, };
@@ -0,0 +1,27 @@
1
+ /**
2
+ * AWS SES Client Optional Interface.
3
+ */
4
+ export default interface {
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
+ }
@@ -4,5 +4,6 @@ import DatabaseOptions from './DatabaseOptions';
4
4
  import FaceMatch from './FaceMatch';
5
5
  import BoundingBox from './BoundingBox';
6
6
  import RekognitionOptions from './RekognitionOptions';
7
+ import SesOptions from './SesOptions';
7
8
  import ViewOptions from './ViewOptions';
8
- export { AuthenticationOptions, Config, DatabaseOptions, FaceMatch, BoundingBox, RekognitionOptions, ViewOptions };
9
+ export { AuthenticationOptions, Config, DatabaseOptions, FaceMatch, BoundingBox, RekognitionOptions, SesOptions, ViewOptions };
@@ -5,22 +5,9 @@ import express from 'express';
5
5
  * If that access is asynchronous, a 403 error is returned.
6
6
  */
7
7
  export default class {
8
+ #private;
8
9
  /**
9
10
  * Mount on application.
10
11
  */
11
12
  static mount(app: express.Express): void;
12
- /**
13
- * Returns the option.
14
- *
15
- * @return {AuthenticationOptions} option.
16
- */
17
- private static loadOptions;
18
- /**
19
- * Check if the request URL does not require authentication.
20
- *
21
- * @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.
22
- * @param {(string|RegExp)[]} allowUrls A list of URLs that do not require authentication.
23
- * @returns {boolean} Return true if the request URL does not require authentication.
24
- */
25
- private static isNotRequireAuthentication;
26
13
  }
@@ -3,14 +3,9 @@ import express from 'express';
3
3
  * Enables the CORS.
4
4
  */
5
5
  export default class {
6
+ #private;
6
7
  /**
7
8
  * Mount on application.
8
9
  */
9
10
  static mount(app: express.Express): void;
10
- /**
11
- * Returns the option.
12
- *
13
- * @return {Config} option.
14
- */
15
- private static loadOptions;
16
11
  }
@@ -4,14 +4,9 @@
4
4
  * Read the environment variable file in options.path and set it in "process.env".
5
5
  */
6
6
  export default class {
7
+ #private;
7
8
  /**
8
9
  * Mount on application.
9
10
  */
10
11
  static mount(): void;
11
- /**
12
- * Returns the option.
13
- *
14
- * @return {Config} option.
15
- */
16
- private static loadOptions;
17
12
  }
@@ -3,14 +3,9 @@ import express from 'express';
3
3
  * Error handling.
4
4
  */
5
5
  export default class {
6
+ #private;
6
7
  /**
7
8
  * Mount on application.
8
9
  */
9
10
  static mount(app: express.Express): void;
10
- /**
11
- * Returns the option.
12
- *
13
- * @return {Config} option.
14
- */
15
- private static loadOptions;
16
11
  }
@@ -3,14 +3,9 @@ import express from 'express';
3
3
  * Defines all the requisites in HTTP.
4
4
  */
5
5
  export default class {
6
+ #private;
6
7
  /**
7
8
  * Mount on application.
8
9
  */
9
10
  static mount(app: express.Express): void;
10
- /**
11
- * Returns the option.
12
- *
13
- * @return {Config} option.
14
- */
15
- private static loadOptions;
16
11
  }
@@ -7,14 +7,9 @@ import express from 'express';
7
7
  * baseUrl: The base URL for this application.
8
8
  */
9
9
  export default class {
10
+ #private;
10
11
  /**
11
12
  * Mount on application.
12
13
  */
13
14
  static mount(app: express.Express): void;
14
- /**
15
- * Returns the option.
16
- *
17
- * @return {Config} option.
18
- */
19
- private static loadOptions;
20
15
  }
@@ -3,14 +3,9 @@ import express from 'express';
3
3
  * Enable Handlebars template engine.
4
4
  */
5
5
  export default class {
6
+ #private;
6
7
  /**
7
8
  * Mount on application.
8
9
  */
9
10
  static mount(app: express.Express): void;
10
- /**
11
- * Returns the option.
12
- *
13
- * @return {ViewOptions} option.
14
- */
15
- private static loadOptions;
16
11
  }
@@ -6,14 +6,9 @@ import express from 'express';
6
6
  * For example, if you have "routes/api/users.js", you can request the method in "user.js (ts)" with the base URL as "https:////api/users".
7
7
  */
8
8
  export default class {
9
+ #private;
9
10
  /**
10
11
  * Mount on application.
11
12
  */
12
13
  static mount(app: express.Express): void;
13
- /**
14
- * Returns the option.
15
- *
16
- * @return {Config} option.
17
- */
18
- private static loadOptions;
19
14
  }
@@ -7,11 +7,7 @@ import IndexFaceDetails from '~/interfaces/IndexFaceDetails';
7
7
  * AWS Rekognition Client.
8
8
  */
9
9
  export default class {
10
- /**
11
- * Rekognition Client.
12
- * @type {AWS.Rekognition}
13
- */
14
- private client;
10
+ #private;
15
11
  /**
16
12
  * Constructs a rekognition client object.
17
13
  */
@@ -21,11 +17,8 @@ export default class {
21
17
  * For each face detected, the operation returns a bounding box of the face.
22
18
  *
23
19
  * @param {string} img Image path or Data Url or image buffer.
24
- * @param {number} minConfidence The minimum confidence of the detected face.
25
- * Faces with a confidence lower than this value will not be returned as a result.
26
- * @param {boolean} withDetails If false, returns only the face bounding box.
27
- * When true, returns the age group, gender, and emotion in addition to the face bounding box.
28
- *
20
+ * @param {number} minConfidence The minimum confidence of the detected face. Faces with a confidence lower than this value will not be returned as a result.
21
+ * @param {boolean} withDetails If false, returns only the face bounding box.When true, returns the age group, gender, and emotion in addition to the face bounding box.
29
22
  * @return {Promise<BoundingBox[]|FaceDetails[]>}
30
23
  */
31
24
  detectFaces(img: string, minConfidence?: number, withDetails?: boolean): Promise<BoundingBox[] | FaceDetails[]>;
@@ -111,20 +104,15 @@ export default class {
111
104
  *
112
105
  * @param {string} collectionId Collection from which to remove the specific faces.
113
106
  * @param {string[]} faceIds An array of face IDs to delete.
107
+ * @return {Promise<boolean>} True on success.
114
108
  */
115
- deleteFaces(collectionId: string, faceIds: string[]): Promise<void>;
109
+ deleteFaces(collectionId: string, faceIds: string[]): Promise<boolean>;
116
110
  /**
117
111
  * Deletes the specified collection.
118
112
  * Note that this operation removes all faces in the collection.
119
113
  *
120
114
  * @param {string} collectionId ID of the collection to delete.
115
+ * @return {Promise<boolean>} True on success.
121
116
  */
122
- deleteCollection(collectionId: string): Promise<void>;
123
- /**
124
- * Returns a buffer of images.
125
- *
126
- * @param {string|Buffer} img Image path or Data Url or image buffer.
127
- * @return {Buffer} Image buffer.
128
- */
129
- private getImageBuffer;
117
+ deleteCollection(collectionId: string): Promise<boolean>;
130
118
  }
@@ -0,0 +1,57 @@
1
+ import SesOptions from '~/interfaces/SesOptions';
2
+ /**
3
+ * AWS SES email sending client.
4
+ */
5
+ export default class AWSSesClient {
6
+ #private;
7
+ /**
8
+ * Constructs a SES client object.
9
+ */
10
+ constructor(options: SesOptions);
11
+ /**
12
+ * Set the sender's email address.
13
+ *
14
+ * @param {string} from Sender's email address.
15
+ * @param {string} name? Sender Name.
16
+ * @return {AWSSesClient}
17
+ */
18
+ from(from: string, name?: string): AWSSesClient;
19
+ /**
20
+ * Set the destination email address.
21
+ *
22
+ * @param {(string|string[])} to Email address to be sent to.
23
+ * @return {AWSSesClient}
24
+ */
25
+ to(to: string | string[]): AWSSesClient;
26
+ /**
27
+ * Set CC email address.
28
+ *
29
+ * @param {(string|string[])} cc CC email address.
30
+ * @return {AWSSesClient}
31
+ */
32
+ cc(cc: string | string[]): AWSSesClient;
33
+ /**
34
+ * Set the email subject.
35
+ *
36
+ * @param {string} subject Email Subject.
37
+ * @return {AWSSesClient}
38
+ */
39
+ subject(subject: string): AWSSesClient;
40
+ /**
41
+ * Set the body of the email.
42
+ *
43
+ * @param {string} body Email Body. The body can use the <a href="https://handlebarsjs.com/">handlebars</a> and <a href="https://www.npmjs.com/package/handlebars-extd">handlebars-extd</a> syntax.
44
+ * @param {{[key: string]: any}} vars The value of a variable in the body of the e-mail.
45
+ * @return {AWSSesClient}
46
+ */
47
+ body(body: string, vars?: {
48
+ [key: string]: any;
49
+ }): AWSSesClient;
50
+ /**
51
+ * Send email.
52
+ *
53
+ * @param {'text'|'html'} type E-Mail type ('html': HTML mail, 'text': text mail). Default is 'text'.
54
+ * @return {Promise<string>} Unique ID assigned by Amazon SES for a successfully sent email.
55
+ */
56
+ send(type?: 'text' | 'html'): Promise<string>;
57
+ }
@@ -3,6 +3,7 @@ import express from 'express';
3
3
  * User authentication service.
4
4
  */
5
5
  export default class {
6
+ #private;
6
7
  /**
7
8
  * Authenticate the user.
8
9
  *
@@ -30,10 +31,4 @@ export default class {
30
31
  * @param {express.Response} res The res object represents the HTTP response that an Express app sends when it gets an HTTP request.
31
32
  */
32
33
  static failureRedirect(res: express.Response): void;
33
- /**
34
- * Returns the option.
35
- *
36
- * @return {AuthenticationOptions} option.
37
- */
38
- private static loadOptions;
39
34
  }
@@ -1,3 +1,4 @@
1
1
  import AWSRekognitionClient from './AWSRekognitionClient';
2
2
  import Authentication from './Authentication';
3
- export { AWSRekognitionClient, Authentication, };
3
+ import AWSSesClient from './AWSSesClient';
4
+ export { AWSRekognitionClient, Authentication, AWSSesClient, };
@@ -1,29 +0,0 @@
1
- /**
2
- * API error.
3
- */
4
- export default class extends Error {
5
- /**
6
- * Error name.
7
- * @type {string}
8
- */
9
- name: string;
10
- /**
11
- * HTTP status code.
12
- * @type {number}
13
- */
14
- statusCode: number;
15
- /**
16
- * Constructs a API error.
17
- *
18
- * @example
19
- * const ApiError = require('express-sweet').exceptions.ApiError;
20
- *
21
- * // Throw an API error.
22
- * throw new ApiError('UserNotFount', 400, 'user not found');
23
- *
24
- * @param {string} name Error name.
25
- * @param {number} statusCode HTTP status code.
26
- * @param {string} message Error message.
27
- */
28
- constructor(name: string, statusCode: number, message?: string);
29
- }