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.
Files changed (71) hide show
  1. package/CHANGELOG.md +69 -1
  2. package/README.md +1039 -2137
  3. package/configuration_sample/cjs/authentication.js +50 -15
  4. package/configuration_sample/cjs/config.js +38 -21
  5. package/configuration_sample/cjs/database.js +90 -4
  6. package/configuration_sample/cjs/logging.js +41 -0
  7. package/configuration_sample/cjs/view.js +19 -1
  8. package/configuration_sample/esm/authentication.js +48 -15
  9. package/configuration_sample/esm/config.js +39 -22
  10. package/configuration_sample/esm/database.js +90 -4
  11. package/configuration_sample/esm/logging.js +41 -0
  12. package/configuration_sample/esm/view.js +20 -2
  13. package/dist/build.cjs +8 -8
  14. package/dist/build.mjs +4 -4
  15. package/package.json +9 -4
  16. package/types/database/DatabaseManager.d.ts +95 -0
  17. package/types/database/Model.d.ts +183 -20
  18. package/types/database/index.d.ts +47 -3
  19. package/types/database/loadModels.d.ts +19 -4
  20. package/types/handlebars_helpers/array.d.ts +3 -1
  21. package/types/handlebars_helpers/comparison.d.ts +55 -19
  22. package/types/handlebars_helpers/date.d.ts +3 -1
  23. package/types/handlebars_helpers/html.d.ts +6 -2
  24. package/types/handlebars_helpers/index.d.ts +73 -9
  25. package/types/handlebars_helpers/layouts.d.ts +5 -1
  26. package/types/handlebars_helpers/math.d.ts +21 -7
  27. package/types/handlebars_helpers/number.d.ts +3 -1
  28. package/types/handlebars_helpers/object.d.ts +6 -2
  29. package/types/handlebars_helpers/string.d.ts +9 -3
  30. package/types/index.d.ts +92 -5
  31. package/types/interfaces/AuthenticationConfig.d.ts +38 -1
  32. package/types/interfaces/BasicConfig.d.ts +26 -1
  33. package/types/interfaces/DatabaseConfig.d.ts +45 -1
  34. package/types/interfaces/LoggingConfig.d.ts +49 -0
  35. package/types/interfaces/ViewConfig.d.ts +21 -2
  36. package/types/interfaces/index.d.ts +25 -11
  37. package/types/middlewares/Authentication.d.ts +43 -6
  38. package/types/middlewares/CORS.d.ts +23 -5
  39. package/types/middlewares/Environment.d.ts +30 -4
  40. package/types/middlewares/ErrorHandler.d.ts +27 -5
  41. package/types/middlewares/Global.d.ts +20 -6
  42. package/types/middlewares/Http.d.ts +22 -5
  43. package/types/middlewares/Local.d.ts +35 -8
  44. package/types/middlewares/View.d.ts +39 -8
  45. package/types/middlewares/index.d.ts +47 -7
  46. package/types/mount.d.ts +16 -3
  47. package/types/routing/Router.d.ts +49 -7
  48. package/types/routing/index.d.ts +37 -1
  49. package/types/services/Authentication.d.ts +79 -16
  50. package/types/services/index.d.ts +33 -1
  51. package/types/types/global.d.ts +29 -8
  52. package/types/utils/Types.d.ts +5 -3
  53. package/types/utils/index.d.ts +71 -9
  54. package/types/utils/isArray.d.ts +12 -3
  55. package/types/utils/isAsyncFunction.d.ts +12 -5
  56. package/types/utils/isFunction.d.ts +13 -6
  57. package/types/utils/isObject.d.ts +14 -3
  58. package/types/utils/isString.d.ts +15 -4
  59. package/types/utils/loadAuthenticationConfig.d.ts +13 -3
  60. package/types/utils/loadBasicConfig.d.ts +13 -3
  61. package/types/utils/loadDatabaseConfig.d.ts +34 -3
  62. package/types/utils/loadLoggingConfig.d.ts +16 -0
  63. package/types/utils/loadViewConfig.d.ts +28 -3
  64. package/types/database/Database.d.ts +0 -18
  65. package/types/interfaces/BoundingBox.d.ts +0 -25
  66. package/types/interfaces/FaceDetails.d.ts +0 -30
  67. package/types/interfaces/FaceDetailsEmotions.d.ts +0 -40
  68. package/types/interfaces/FaceMatch.d.ts +0 -31
  69. package/types/interfaces/IndexFaceDetails.d.ts +0 -29
  70. package/types/interfaces/RekognitionOptions.d.ts +0 -26
  71. package/types/interfaces/SesOptions.d.ts +0 -27
@@ -1,7 +1,53 @@
1
1
  /**
2
- * Database configuration.
2
+ * Sequelize Database Configuration
3
+ *
4
+ * @description Database connection settings for different environments
5
+ * Includes connection pool configuration for each environment
6
+ *
7
+ * @example
8
+ * // Connection pool configuration examples
9
+ * // The max value must be set appropriately according to the DB's max_connections
10
+ *
11
+ * // How to check max_connections in MariaDB:
12
+ * // SHOW VARIABLES LIKE 'max_connections';
13
+ * // +-----------------+-------+
14
+ * // | Variable_name | Value |
15
+ * // +-----------------+-------+
16
+ * // | max_connections | 151 |
17
+ * // +-----------------+-------+
18
+ *
19
+ * // Configuration example when max_connections=151:
20
+ * pool: {
21
+ * // Maximum 100 connections (66.2% usage of max_connections=151)
22
+ * // Keep total connections from all instances within 70-80% of max_connections
23
+ * max: 100,
24
+ * // Maintain 10 connections constantly (ensures stability during load increases)
25
+ * min: 10,
26
+ * // 10 second timeout for connection acquisition
27
+ * acquire: 10000,
28
+ * // Mark for deletion after 3 seconds of inactivity
29
+ * idle: 3000,
30
+ * // Check for idle connections every 10 seconds
31
+ * evict: 10000
32
+ * }
33
+ *
34
+ * // Configuration example when max_connections=5297:
35
+ * pool: {
36
+ * // Maximum 300 connections per instance (6 instances peak = 1800 connections = 34.0% usage)
37
+ * // Distribute connections across multiple instances while staying within safe limits
38
+ * max: 300,
39
+ * // Maintain 30 connections constantly (ensures stability during high load)
40
+ * min: 30,
41
+ * // 30 second timeout for connection acquisition
42
+ * acquire: 30000,
43
+ * // Mark for deletion after 10 seconds of inactivity
44
+ * idle: 10000,
45
+ * // Check for idle connections every 30 seconds
46
+ * evict: 30000
47
+ * }
3
48
  */
4
49
  export default {
50
+ // Development environment configuration
5
51
  development: {
6
52
  username: 'root',
7
53
  password: 'password',
@@ -10,8 +56,22 @@ export default {
10
56
  port: undefined,
11
57
  dialect: 'mariadb',
12
58
  timezone: '+09:00',
13
- logging: false
59
+ logging: false,
60
+ // pool: {
61
+ // // Maximum connections (adjust based on your DB's max_connections)
62
+ // max: 100,
63
+ // // Maintain minimum connections constantly
64
+ // min: 10,
65
+ // // Connection acquisition timeout
66
+ // acquire: 10000,
67
+ // // Mark for deletion after inactivity
68
+ // idle: 2000,
69
+ // // Check for idle connections interval
70
+ // evict: 10000
71
+ // }
14
72
  },
73
+
74
+ // Test environment configuration
15
75
  test: {
16
76
  username: 'root',
17
77
  password: 'password',
@@ -20,8 +80,22 @@ export default {
20
80
  port: undefined,
21
81
  dialect: 'mariadb',
22
82
  timezone: '+09:00',
23
- logging: false
83
+ logging: false,
84
+ // pool: {
85
+ // // Maximum connections (adjust based on your DB's max_connections)
86
+ // max: 100,
87
+ // // Maintain minimum connections constantly
88
+ // min: 10,
89
+ // // Connection acquisition timeout
90
+ // acquire: 10000,
91
+ // // Mark for deletion after inactivity
92
+ // idle: 3000,
93
+ // // Check for idle connections interval
94
+ // evict: 10000
95
+ // }
24
96
  },
97
+
98
+ // Production environment configuration
25
99
  production: {
26
100
  username: 'root',
27
101
  password: 'password',
@@ -30,6 +104,18 @@ export default {
30
104
  port: undefined,
31
105
  dialect: 'mariadb',
32
106
  timezone: '+09:00',
33
- logging: false
107
+ logging: false,
108
+ // pool: {
109
+ // // Maximum connections (adjust based on your DB's max_connections and instance count)
110
+ // max: 300,
111
+ // // Maintain minimum connections constantly
112
+ // min: 30,
113
+ // // Connection acquisition timeout
114
+ // acquire: 30000,
115
+ // // Mark for deletion after inactivity
116
+ // idle: 10000,
117
+ // // Check for idle connections interval
118
+ // evict: 30000
119
+ // }
34
120
  }
35
121
  }
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Logging configuration interface.
3
+ */
4
+ export default {
5
+ /**
6
+ * Morgan logging format. Common formats: 'combined', 'common', 'dev', 'short', 'tiny'
7
+ * You can also define custom format string, defaults to 'combined'.
8
+ * @type {string}
9
+ * @example
10
+ * ```js
11
+ * // Use predefined format
12
+ * format: 'combined',
13
+ *
14
+ * // Use custom format
15
+ * format: ':method :url :status :res[content-length] - :response-time ms',
16
+ * ```
17
+ */
18
+ format: 'combined',
19
+
20
+ /**
21
+ * Function to determine if logging should be skipped for a request.
22
+ * Return true to skip logging, false to log the request, defaults to none (undefined).
23
+ * @type {(req: express.Request, res: express.Response) => boolean}
24
+ * @example
25
+ * ```js
26
+ * // Skip logging for successful requests
27
+ * skip: (req, res) => res.statusCode < 400,
28
+ *
29
+ * // Skip logging for specific routes
30
+ * skip: (req, res) => req.path === '/health',
31
+ *
32
+ * // Skip logging in test environment
33
+ * skip: (req, res) => process.env.NODE_ENV === 'test',
34
+ * ```
35
+ */
36
+ skip: (req, res) => {
37
+ // Example: Skip logging for health check endpoints
38
+ // In actual implementation, customize based on your requirements
39
+ return req.path === '/health';
40
+ }
41
+ }
@@ -1,4 +1,4 @@
1
- import path from 'path';
1
+ import path from 'node:path';
2
2
 
3
3
  /**
4
4
  * View's configuration interface.
@@ -32,5 +32,23 @@ export default {
32
32
  * Extension for templates & partials, defaults to `.hbs`,
33
33
  * @type {string}
34
34
  */
35
- extension: '.hbs'
35
+ extension: '.hbs',
36
+
37
+ /**
38
+ * Hook function just before the view is rendered.
39
+ * For example, you can set your own local variables that can be used within the view.
40
+ * @type {(res: express.Response) => Promise<void>|void}
41
+ * @example
42
+ * ```js
43
+ * // The message set here can be referenced in the view as {{message}}.
44
+ * beforeRender: (req, res) => {
45
+ * res.locals.extra = 'Extra';
46
+ * }
47
+ * ```
48
+ */
49
+ beforeRender: (req, res) => {
50
+ // Example: Set local variables that can be used in templates
51
+ // In actual implementation, set the variables you need in your views
52
+ res.locals.message = 'Hello World';
53
+ }
36
54
  }