express-sweet 4.0.0 → 5.0.0

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 (93) hide show
  1. package/CHANGELOG.md +209 -397
  2. package/LICENSE +1 -1
  3. package/README.md +210 -1174
  4. package/dist/build.cjs +32 -73
  5. package/dist/build.mjs +32 -73
  6. package/package.json +45 -61
  7. package/screenshots/avatar.png +0 -0
  8. package/screenshots/edit-profile.png +0 -0
  9. package/screenshots/hero-banner.png +0 -0
  10. package/screenshots/home.png +0 -0
  11. package/screenshots/mount-flow.mmd +11 -0
  12. package/screenshots/mount-flow.png +0 -0
  13. package/screenshots/new-person.png +0 -0
  14. package/screenshots/people.png +0 -0
  15. package/screenshots/sign-in.png +0 -0
  16. package/types/database/DatabaseManager.d.ts +15 -10
  17. package/types/database/Model.d.ts +29 -43
  18. package/types/database/index.d.ts +0 -1
  19. package/types/database/loadModels.d.ts +7 -13
  20. package/types/helpers/array.d.ts +21 -0
  21. package/types/helpers/comparison.d.ts +217 -0
  22. package/types/helpers/date.d.ts +20 -0
  23. package/types/helpers/html.d.ts +35 -0
  24. package/types/{handlebars_helpers → helpers}/index.d.ts +0 -2
  25. package/types/helpers/layouts.d.ts +29 -0
  26. package/types/helpers/math.d.ts +85 -0
  27. package/types/helpers/number.d.ts +19 -0
  28. package/types/helpers/object.d.ts +28 -0
  29. package/types/helpers/string.d.ts +45 -0
  30. package/types/index.d.ts +6 -9
  31. package/types/middleware/auth.d.ts +186 -0
  32. package/types/middleware/cors.d.ts +19 -0
  33. package/types/middleware/env.d.ts +24 -0
  34. package/types/middleware/error.d.ts +26 -0
  35. package/types/middleware/globals.d.ts +13 -0
  36. package/types/{middlewares → middleware}/index.d.ts +12 -13
  37. package/types/middleware/locals.d.ts +33 -0
  38. package/types/middleware/parser.d.ts +30 -0
  39. package/types/middleware/router.d.ts +31 -0
  40. package/types/middleware/views.d.ts +37 -0
  41. package/types/mount.d.ts +1 -2
  42. package/types/{interfaces → types}/AppConfig.d.ts +11 -19
  43. package/types/{interfaces → types}/AuthenticationConfig.d.ts +10 -11
  44. package/types/{interfaces → types}/DatabaseConfig.d.ts +0 -1
  45. package/types/{interfaces → types}/LoggingConfig.d.ts +0 -1
  46. package/types/{interfaces → types}/UploadConfig.d.ts +0 -1
  47. package/types/{interfaces → types}/ViewConfig.d.ts +1 -2
  48. package/types/{interfaces → types}/index.d.ts +1 -2
  49. package/types/utils/index.d.ts +0 -1
  50. package/types/utils/loadAppConfig.d.ts +1 -1
  51. package/types/utils/loadAuthenticationConfig.d.ts +1 -1
  52. package/types/utils/loadLoggingConfig.d.ts +1 -1
  53. package/types/utils/loadUploadConfig.d.ts +1 -1
  54. package/types/utils/loadViewConfig.d.ts +1 -1
  55. package/configuration_sample/cjs/authentication.js +0 -138
  56. package/configuration_sample/cjs/config.js +0 -92
  57. package/configuration_sample/cjs/database.js +0 -121
  58. package/configuration_sample/cjs/logging.js +0 -41
  59. package/configuration_sample/cjs/upload.js +0 -91
  60. package/configuration_sample/cjs/view.js +0 -54
  61. package/configuration_sample/esm/authentication.js +0 -136
  62. package/configuration_sample/esm/config.js +0 -92
  63. package/configuration_sample/esm/database.js +0 -121
  64. package/configuration_sample/esm/logging.js +0 -41
  65. package/configuration_sample/esm/upload.js +0 -91
  66. package/configuration_sample/esm/view.js +0 -54
  67. package/screencaps/belongs-to-many.png +0 -0
  68. package/screencaps/belongs-to.png +0 -0
  69. package/screencaps/demonstration.webp +0 -0
  70. package/screencaps/has-many.png +0 -0
  71. package/screencaps/has-one.png +0 -0
  72. package/types/handlebars_helpers/array.d.ts +0 -22
  73. package/types/handlebars_helpers/comparison.d.ts +0 -222
  74. package/types/handlebars_helpers/date.d.ts +0 -19
  75. package/types/handlebars_helpers/html.d.ts +0 -31
  76. package/types/handlebars_helpers/layouts.d.ts +0 -25
  77. package/types/handlebars_helpers/math.d.ts +0 -74
  78. package/types/handlebars_helpers/number.d.ts +0 -18
  79. package/types/handlebars_helpers/object.d.ts +0 -21
  80. package/types/handlebars_helpers/string.d.ts +0 -45
  81. package/types/middlewares/corsPolicy.d.ts +0 -28
  82. package/types/middlewares/envLoader.d.ts +0 -34
  83. package/types/middlewares/errorHandler.d.ts +0 -32
  84. package/types/middlewares/globalVars.d.ts +0 -25
  85. package/types/middlewares/localVars.d.ts +0 -44
  86. package/types/middlewares/passportAuth.d.ts +0 -15
  87. package/types/middlewares/requestParser.d.ts +0 -27
  88. package/types/middlewares/routeMapper.d.ts +0 -54
  89. package/types/middlewares/viewEngine.d.ts +0 -49
  90. package/types/services/Authentication.d.ts +0 -95
  91. package/types/services/index.d.ts +0 -33
  92. package/types/types/global.d.ts +0 -38
  93. package/types/utils/Types.d.ts +0 -29
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "express-sweet",
3
- "version": "4.0.0",
4
- "description": "EXPRESS SWEET is a powerful Express.js extension that streamlines your workflow and boosts productivity with a suite of utilities and enhancements.",
3
+ "version": "5.0.0",
4
+ "description": "Express.js, supercharged. Auth, ORM, routing, views — everything snaps together so you can ship fast and stay sharp.",
5
5
  "type": "module",
6
6
  "main": "dist/build.cjs",
7
7
  "module": "dist/build.mjs",
@@ -15,99 +15,83 @@
15
15
  "files": [
16
16
  "dist/",
17
17
  "types/",
18
- "CHANGELOG.md",
19
- "LICENSE",
20
- "package.json",
18
+ "screenshots/",
21
19
  "README.md",
22
- "screencaps/",
23
- "configuration_sample/"
20
+ "CHANGELOG.md",
21
+ "LICENSE"
24
22
  ],
25
23
  "scripts": {
26
24
  "build": "node --max-old-space-size=8192 node_modules/rollup/dist/bin/rollup -c rollup.config.js",
27
25
  "prebuild": "rm -rf dist types",
28
- "prewatch": "rm -rf dist types",
29
- "watch": "node --max-old-space-size=8192 node_modules/rollup/dist/bin/rollup -c rollup.config.js --watch",
30
- "docs:build": "typedoc",
31
- "docs:clean": "rm -rf docs",
32
- "docs:watch": "typedoc --watch",
33
- "docs:serve": "typedoc && npx serve docs -p 8080"
26
+ "diagram": "npx -y @mermaid-js/mermaid-cli -i screenshots/mount-flow.mmd -o screenshots/mount-flow.png -b transparent"
34
27
  },
35
28
  "repository": {
36
29
  "type": "git",
37
- "url": "git+https://github.com/takuya-motoshima/express-sweet.git"
30
+ "url": "git+https://github.com/shumatsumonobu/express-sweet.git"
38
31
  },
39
32
  "keywords": [
40
- "nodejs",
41
33
  "express",
42
34
  "framework",
43
- "web",
44
- "rest",
45
- "restful",
46
- "router",
47
- "app",
48
- "api",
49
- "shared",
50
- "library",
51
- "lib",
35
+ "mvc",
36
+ "routing",
37
+ "middleware",
38
+ "authentication",
39
+ "passport",
40
+ "sequelize",
41
+ "orm",
42
+ "handlebars",
43
+ "session",
44
+ "redis",
45
+ "file-upload",
52
46
  "typescript",
53
- "ts",
54
47
  "esm",
55
- "es6",
56
- "orm",
57
- "mysql",
58
- "mariadb",
59
- "sqlite",
60
- "postgresql",
61
- "postgres",
62
- "mssql"
48
+ "commonjs"
63
49
  ],
64
- "author": "Takuya Motoshima <developer.takuyamotoshima@gmail.com> (https://x.com/takuya_motech)",
50
+ "author": "shumatsumonobu <shumatsumonobu@gmail.com> (https://x.com/shumatsumonobu)",
65
51
  "license": "MIT",
66
52
  "engines": {
67
53
  "node": ">=18.0.0"
68
54
  },
69
55
  "bugs": {
70
- "url": "https://github.com/takuya-motoshima/express-sweet/issues",
71
- "email": "developer.takuyamotoshima@gmail.com"
56
+ "url": "https://github.com/shumatsumonobu/express-sweet/issues",
57
+ "email": "shumatsumonobu@gmail.com"
72
58
  },
73
- "homepage": "https://github.com/takuya-motoshima/express-sweet#readme",
59
+ "homepage": "https://github.com/shumatsumonobu/express-sweet#readme",
74
60
  "dependencies": {
75
- "connect-redis": "^7.1.0",
61
+ "connect-redis": "^9.0.0",
76
62
  "cookie-parser": "^1.4.7",
77
- "dotenv": "^8.2.0",
63
+ "dotenv": "^17.3.1",
78
64
  "express": "^5.2.1",
79
- "express-handlebars": "^7.1.3",
80
- "express-session": "^1.18.2",
81
- "glob": "^10.3.12",
82
- "http-errors": "~1.6.3",
83
- "mariadb": "^3.2.3",
65
+ "express-handlebars": "^8.0.6",
66
+ "express-session": "^1.19.0",
67
+ "glob": "^13.0.6",
68
+ "http-errors": "~2.0.1",
84
69
  "moment": "^2.30.1",
85
70
  "morgan": "^1.10.1",
86
- "multer": "^2.0.2",
71
+ "multer": "^2.1.1",
87
72
  "passport": "^0.7.0",
88
73
  "passport-local": "^1.0.0",
89
- "redis": "^4.6.8",
90
- "sequelize": "^6.37.7",
74
+ "redis": "^5.11.0",
75
+ "sequelize": "^6.37.8",
91
76
  "striptags": "^3.2.0"
92
77
  },
93
78
  "devDependencies": {
94
- "@rollup/plugin-commonjs": "^26.0.1",
79
+ "@rollup/plugin-commonjs": "^29.0.2",
95
80
  "@rollup/plugin-json": "^6.1.0",
96
- "@rollup/plugin-node-resolve": "^15.2.3",
97
- "@rollup/plugin-terser": "^0.4.4",
98
- "@types/cookie-parser": "^1.4.2",
81
+ "@rollup/plugin-node-resolve": "^16.0.3",
82
+ "@rollup/plugin-terser": "^1.0.0",
83
+ "@types/cookie-parser": "^1.4.10",
99
84
  "@types/express": "^5.0.6",
100
85
  "@types/express-session": "^1.18.2",
101
- "@types/glob": "^8.1.0",
102
- "@types/http-errors": "^1.8.0",
103
- "@types/morgan": "^1.9.9",
104
- "@types/multer": "^2.0.0",
105
- "@types/node": "^22.5.1",
106
- "@types/passport": "^1.0.16",
107
- "@types/passport-local": "^1.0.33",
108
- "rollup": "^4.45.1",
86
+ "@types/http-errors": "^2.0.5",
87
+ "@types/morgan": "^1.9.10",
88
+ "@types/multer": "^2.1.0",
89
+ "@types/node": "^25.5.0",
90
+ "@types/passport": "^1.0.17",
91
+ "@types/passport-local": "^1.0.38",
92
+ "rollup": "^4.59.0",
109
93
  "rollup-plugin-typescript2": "^0.36.0",
110
- "typedoc": "^0.28.11",
111
- "typescript": "^5.5.4"
94
+ "sqlite3": "^6.0.1",
95
+ "typescript": "^5.9.3"
112
96
  }
113
97
  }
Binary file
Binary file
Binary file
Binary file
@@ -0,0 +1,11 @@
1
+ flowchart TD
2
+ A["expx.mount(app)"] --> B["Global variables"]
3
+ B --> C[".env file loading\n.env"]
4
+ C --> D["Sequelize model initialization\nconfig/database.js, models/"]
5
+ D --> E["Body parser, cookies, static files, Morgan logging\nconfig/logging.js, public/"]
6
+ E --> F["Handlebars view engine\nconfig/view.js, views/"]
7
+ F --> G["CORS policy\nconfig/config.js"]
8
+ G --> H["Local variables for views"]
9
+ H --> I["Passport.js authentication & session\nconfig/authentication.js"]
10
+ I --> J["File-based URL routing\nconfig/config.js, routes/"]
11
+ J --> K["Error handler\nconfig/config.js, views/errors/"]
Binary file
Binary file
Binary file
Binary file
@@ -1,17 +1,24 @@
1
1
  import sequelize from 'sequelize';
2
2
  /**
3
- * Database manager class for handling Sequelize database connections.
4
- * Implements singleton pattern to ensure single database connection across the application.
3
+ * Singleton manager for the Sequelize database connection.
4
+ *
5
+ * Ensures a single shared Sequelize instance is used across all models and services.
6
+ * The instance is lazily created on the first call to {@link getInstance} and reused thereafter.
7
+ *
5
8
  * @example
6
9
  * ```js
7
- * // Get database instance
8
- * const db = await DatabaseManager.getInstance();
10
+ * import * as expx from 'express-sweet';
11
+ *
12
+ * // Get the shared Sequelize instance
13
+ * const db = await expx.database.DatabaseManager.getInstance();
9
14
  *
10
- * // Check connection
11
- * const isConnected = await DatabaseManager.isConnected();
15
+ * // Check if the database is reachable
16
+ * if (await expx.database.DatabaseManager.isConnected()) {
17
+ * console.log('Database OK');
18
+ * }
12
19
  *
13
- * // Get configuration
14
- * const config = await DatabaseManager.getConfig();
20
+ * // Graceful shutdown
21
+ * await expx.database.DatabaseManager.close();
15
22
  * ```
16
23
  */
17
24
  export default class DatabaseManager {
@@ -54,7 +61,6 @@ export default class DatabaseManager {
54
61
  * This returns the raw configuration before Sequelize processing.
55
62
  * @returns {Promise<object>} Database configuration object containing all loaded options
56
63
  * @throws {Error} When configuration loading fails
57
- * @see {@link https://sequelize.org/docs/v6/other-topics/dialect-specific-things/ | Sequelize Dialect Options}
58
64
  * @example
59
65
  * ```js
60
66
  * const config = await DatabaseManager.getConfig();
@@ -69,7 +75,6 @@ export default class DatabaseManager {
69
75
  * This returns the actual options used by the Sequelize instance,
70
76
  * which may include defaults and processed values.
71
77
  * @returns {Promise<object>} Sequelize runtime options object
72
- * @see {@link https://sequelize.org/api/v6/class/src/sequelize.js~sequelize#instance-constructor-options | Sequelize Constructor Options}
73
78
  * @example
74
79
  * ```js
75
80
  * const options = await DatabaseManager.getSequelizeOptions();
@@ -1,12 +1,11 @@
1
1
  import sequelize from 'sequelize';
2
2
  declare const Model_base: any;
3
3
  /**
4
- * Model base class that extends Sequelize.Model for database operations.
5
- * This is a class that abstracts the tables in the database and provides
6
- * convenient access to the database connection, Query Builder, and additional methods.
4
+ * Abstract base class for database models, extending Sequelize.Model.
5
+ * Provides convenient access to the shared database connection, query utilities,
6
+ * transaction management, and Sequelize data types.
7
7
  *
8
8
  * @extends {sequelize.Model}
9
- * @see {@link https://sequelize.org/api/v6/class/src/model.js~model | Sequelize Model}
10
9
  * @example
11
10
  * ```js
12
11
  * // Creating a custom model
@@ -74,7 +73,6 @@ export default class Model extends Model_base {
74
73
  * List of columns in the table accessed by this model.
75
74
  * This member must be defined in a subclass.
76
75
  * @type {sequelize.ModelAttributes}
77
- * @see {@link https://sequelize.org/api/v6/variable/index.html#static-variable-DataTypes | Sequelize DataTypes}
78
76
  * @example
79
77
  * ```js
80
78
  * import * as expx from 'express-sweet';
@@ -109,7 +107,6 @@ export default class Model extends Model_base {
109
107
  * A convenience class holding commonly used data types.
110
108
  * This is an alias for `sequelize.DataTypes`.
111
109
  * @type {sequelize.DataTypes}
112
- * @see {@link https://sequelize.org/api/v6/variable/index.html#static-variable-DataTypes | Sequelize DataTypes}
113
110
  * @example
114
111
  * ```js
115
112
  * {id: this.DataTypes.INTEGER}
@@ -121,13 +118,12 @@ export default class Model extends Model_base {
121
118
  /**
122
119
  * An enum of query types used by sequelize.query.
123
120
  * @type {sequelize.QueryTypes}
124
- * @see {@link https://sequelize.org/api/v6/variable/index.html#static-variable-QueryTypes | Sequelize QueryTypes}
125
121
  */
126
122
  static readonly QueryTypes: {
127
123
  [key: string]: string;
128
124
  };
129
125
  /**
130
- * Operator.
126
+ * Sequelize query operators for building WHERE conditions.
131
127
  * @type {sequelize.Op}
132
128
  * @example
133
129
  * ```js
@@ -183,11 +179,9 @@ export default class Model extends Model_base {
183
179
  [key: string]: any;
184
180
  };
185
181
  /**
186
- * Creates a object representing a database function. This can be used in search queries, both in where and
187
- * order parts, and as default values in column definitions. If you want to refer to columns in your
188
- * function, you should use `sequelize.col`, so that the columns are properly interpreted as columns and not a strings.
182
+ * Creates an object representing a database function for use in queries (WHERE, ORDER BY, etc.)
183
+ * and as column default values. Use {@link col} to reference columns within function arguments.
189
184
  * @type {sequelize.fn}
190
- * @see {@link https://sequelize.org/api/v6/class/src/sequelize.js~sequelize#static-method-fn | Sequelize fn}
191
185
  * @example
192
186
  * ```js
193
187
  * import BookModel from '../models/BookModel';
@@ -201,16 +195,14 @@ export default class Model extends Model_base {
201
195
  */
202
196
  static readonly fn: (fn: string, ...args: unknown[]) => any;
203
197
  /**
204
- * Creates a object representing a column in the DB. This is often useful in conjunction with
205
- * `sequelize.fn`, since raw string arguments to fn will be escaped.
198
+ * Creates an object representing a database column reference.
199
+ * Useful with {@link fn} to prevent column names from being escaped as strings.
206
200
  * @type {sequelize.col}
207
- * @see {@link https://sequelize.org/api/v6/class/src/sequelize.js~sequelize#static-method-col | Sequelize col}
208
201
  */
209
202
  static readonly col: (col: string) => any;
210
203
  /**
211
- * Creates a object representing a literal, i.e. something that will not be escaped.
204
+ * Creates an object representing a raw SQL literal that will not be escaped.
212
205
  * @type {sequelize.literal}
213
- * @see {@link https://sequelize.org/api/v6/class/src/sequelize.js~sequelize#static-method-literal | Sequelize literal}
214
206
  * @example
215
207
  * ```js
216
208
  * import BookModel from '../models/BookModel';
@@ -228,10 +220,9 @@ export default class Model extends Model_base {
228
220
  */
229
221
  static readonly literal: (val: string) => any;
230
222
  /**
231
- * A way of specifying attr = condition.
232
- * The attr can either be an object taken from Model.rawAttributes or an object from sequelize utility functions.
223
+ * Creates a WHERE condition comparing an attribute (or function result) against a value.
224
+ * The attribute can be a raw attribute from the model or a Sequelize utility like {@link fn}.
233
225
  * @type {sequelize.where}
234
- * @see {@link https://sequelize.org/api/v6/class/src/sequelize.js~sequelize#static-method-where | Sequelize where}
235
226
  * @example
236
227
  * ```js
237
228
  * import BookModel from '../models/BookModel';
@@ -249,10 +240,9 @@ export default class Model extends Model_base {
249
240
  */
250
241
  static readonly where: (attr: sequelize.AttributeType, comparator: string, logic: sequelize.LogicType) => sequelize.Utils.Where;
251
242
  /**
252
- * Reference to sequelize.Transaction.
253
- * This includes properties such as isolation level enums used with the transaction option.
243
+ * Reference to the Sequelize Transaction class.
244
+ * Use this to access isolation level enums and transaction type constants.
254
245
  * @type {sequelize.Transaction}
255
- * @see {@link https://sequelize.org/api/v6/class/src/transaction.js~transaction | Sequelize Transaction}
256
246
  * @example
257
247
  * ```js
258
248
  * BookModel.Transaction.ISOLATION_LEVELS.READ_UNCOMMITTED // "READ UNCOMMITTED"
@@ -270,11 +260,9 @@ export default class Model extends Model_base {
270
260
  */
271
261
  static init(): Promise<any>;
272
262
  /**
273
- * Associate the model.
274
- * Define associations with other models such as "hasOne", "hasMany", "belongsTo", "belongsToMany".
275
- * If you omit the alias (as) option, the associated name will be hasOne, singular for belongsTo, and plural for hasMany.
276
- * This method is called automatically from within the "express-sweet.mount" method, so you don't have to run it yourself.
277
- * @see {@link https://sequelize.org/api/v6/class/src/associations/base.js~association | Sequelize Associations}
263
+ * Defines associations with other models (hasOne, hasMany, belongsTo, belongsToMany).
264
+ * Override this method in subclasses to declare relationships.
265
+ * Called automatically by `express-sweet.mount()` after all models are initialized.
278
266
  * @example
279
267
  * ```js
280
268
  * import * as expx from 'express-sweet';
@@ -294,10 +282,9 @@ export default class Model extends Model_base {
294
282
  */
295
283
  static association(): void;
296
284
  /**
297
- * Starts a transaction and returns a transaction object to identify the running transaction.
298
- * @see https://sequelize.org/api/v6/class/src/transaction.js~transaction
299
- * @param {sequelize.TransactionOptions} options Options provided when the transaction is created.
300
- * @returns {Promise<sequelize.Transaction>} Returns a transaction object to identify the transaction being executed.
285
+ * Starts a new database transaction.
286
+ * @param {sequelize.TransactionOptions} options Transaction options (isolation level, type, etc.).
287
+ * @returns {Promise<sequelize.Transaction>} The transaction object for use in subsequent queries.
301
288
  * @example
302
289
  * ```js
303
290
  * // Simple transaction usage example.
@@ -333,10 +320,10 @@ export default class Model extends Model_base {
333
320
  */
334
321
  static begin(options?: sequelize.TransactionOptions): Promise<sequelize.Transaction>;
335
322
  /**
336
- * Returns data that matches the ID.
337
- * This is a convenience method that wraps findOne with ID condition.
338
- * @param {number} id The ID to search for
339
- * @returns {Promise<object|null>} Returns the model instance or null if not found
323
+ * Finds a single record by its primary key (`id` column).
324
+ * Convenience wrapper around `findOne({where: {id}, raw: true})`.
325
+ * @param {number} id The primary key value to search for.
326
+ * @returns {Promise<object|null>} The raw record object, or `null` if not found.
340
327
  * @example
341
328
  * ```js
342
329
  * import BookModel from '../models/BookModel';
@@ -347,13 +334,12 @@ export default class Model extends Model_base {
347
334
  */
348
335
  static findById(id: number): Promise<{} | null>;
349
336
  /**
350
- * Raw Queries.
351
- * As there are often use cases in which it is just easier to execute raw / already prepared SQL queries, you can use the Model.query method.
352
- * @see https://sequelize.org/master/manual/raw-queries.html
353
- * @param {string} sql SQL string.
354
- * @param {object} options Query options.
355
- * @returns {Promise<any>} By default, the function will return two arguments: an array of results, and a metadata object, containing number of affected rows etc.
356
- * If you are running a type of query where you don't need the metadata, for example a SELECT query, you can pass in a query type to make sequelize format the results:
337
+ * Executes a raw SQL query against the database.
338
+ * By default returns `[results, metadata]`. Pass a `type` option (e.g., `QueryTypes.SELECT`)
339
+ * to receive formatted results directly.
340
+ * @param {string} sql The SQL query string.
341
+ * @param {object} options Query options including query type, replacements, etc.
342
+ * @returns {Promise<any>} Query results (format depends on the `type` option).
357
343
  * @example
358
344
  * ```js
359
345
  * // By default the function will return two arguments - a results array, and an object containing metadata (such as amount of affected rows, etc).
@@ -4,7 +4,6 @@
4
4
  * Provides Sequelize-based database abstraction with singleton connection management,
5
5
  * custom Model base class, and automatic model loading system.
6
6
  *
7
- * @module database
8
7
  * @example
9
8
  * ```js
10
9
  * // Using DatabaseManager
@@ -1,23 +1,17 @@
1
1
  /**
2
- * Model initialization and association for Sequelize models.
3
- * Loads all model files from the models/ directory, initializes them, then sets up associations.
4
- * All models must be pre-loaded before associating to prevent circular dependency issues.
5
- * @returns {Promise<void>}
6
- * @example
7
- * ```js
8
- * // This function is called automatically by express-sweet.mount()
9
- * import loadModels from '~/database/loadModels';
10
- * await loadModels();
11
- * ```
2
+ * Loads, initializes, and associates all Sequelize models from the `models/` directory.
12
3
  *
4
+ * All models are initialized first, then associations are set up in a separate pass.
5
+ * This two-phase approach prevents circular dependency errors when models reference each other.
6
+ *
7
+ * @returns {Promise<void>}
13
8
  * @example
14
9
  * ```bash
15
- * // Model file structure
10
+ * # Expected directory structure
16
11
  * models/
17
12
  * ├── UserModel.js
18
13
  * ├── ProfileModel.js
19
14
  * └── BookModel.js
20
15
  * ```
21
16
  */
22
- declare const _default: () => Promise<void>;
23
- export default _default;
17
+ export default function loadModels(): Promise<void>;
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Finds the first object in an array whose specified field matches the given value.
3
+ * Returns `null` if no match is found or if parameters are invalid.
4
+ * @param {Array<{[key: string]: any}>} array The array of objects to search.
5
+ * @param {string} fieldName The property name to match against.
6
+ * @param {*} fieldValue The value to match.
7
+ * @returns {object|null} The first matching object, or `null` if not found.
8
+ * @example
9
+ * ```handlebars
10
+ * {{!-- Look up a category name by its ID --}}
11
+ * {{lookup (findObjectInArray categories 'id' categoryId) 'name'}}
12
+ *
13
+ * {{!-- Use within an each block to cross-reference related data --}}
14
+ * {{#each orders}}
15
+ * {{lookup (findObjectInArray ../users 'id' this.userId) 'name'}}
16
+ * {{/each}}
17
+ * ```
18
+ */
19
+ export declare const findObjectInArray: (array: Array<{
20
+ [key: string]: any;
21
+ }>, fieldName: string, fieldValue: any) => object | null;