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
@@ -2,89 +2,107 @@
2
2
  * Determine whether or not two values are equal (===).
3
3
  * @param {any} value1 First value to be compared with second.
4
4
  * @param {any} value2 Second value to be compared with first.
5
- * @return {boolean} Returns true if the value and type are the same, false if they are different.
5
+ * @returns {boolean} Returns true if the value and type are the same, false if they are different.
6
6
  * @example
7
+ * ```handlebars
7
8
  * {{eq val1 val2}}
8
9
  * {{#if (eqw val1 val2)}}...{{/if}}
10
+ * ```
9
11
  */
10
12
  export declare const eq: (value1: any, value2: any) => boolean;
11
13
  /**
12
14
  * Determine whether or not two values are equal (==) i.e weak checking.
13
15
  * @param {any} value1 First value to be compared with second.
14
16
  * @param {any} value2 Second value to be compared with first.
15
- * @return {boolean} Returns true if the values are the same, false if they are different.
17
+ * @returns {boolean} Returns true if the values are the same, false if they are different.
16
18
  * @example
19
+ * ```handlebars
17
20
  * {{eqw val1 val2}}
18
21
  * {{#if (eqw val1 val2)}}...{{/if}}
22
+ * ```
19
23
  */
20
24
  export declare const eqw: (value1: any, value2: any) => boolean;
21
25
  /**
22
26
  * Determine whether or not two values are not equal (!==).
23
27
  * @param {any} value1 First value to be compared with second.
24
28
  * @param {any} value2 Second value to be compared with first.
25
- * @return {boolean} Returns true if the value and type are different, false if they are the same.
29
+ * @returns {boolean} Returns true if the value and type are different, false if they are the same.
26
30
  * @example
31
+ * ```handlebars
27
32
  * {{neq val1 val2}}
28
33
  * {{#if (neq val1 val2)}}...{{/if}}
34
+ * ```
29
35
  */
30
36
  export declare const neq: (value1: any, value2: any) => boolean;
31
37
  /**
32
38
  * Determine whether or not two values are not equal (!=) weak checking.
33
39
  * @param {any} value1 First value to be compared with second.
34
40
  * @param {any} value2 Second value to be compared with first.
35
- * @return {boolean} Returns true if the values are different, false if they are the same.
41
+ * @returns {boolean} Returns true if the values are different, false if they are the same.
36
42
  * @example
43
+ * ```handlebars
37
44
  * {{neqw val1 val2}}
38
45
  * {{#if (neqw val1 val2)}}...{{/if}}
46
+ * ```
39
47
  */
40
48
  export declare const neqw: (value1: any, value2: any) => boolean;
41
49
  /**
42
50
  * Check for less than condition (a < b).
43
51
  * @param {any} value1 First value to be compared with second.
44
52
  * @param {any} value2 Second value to be compared with first.
45
- * @return {boolean} Returns true if the first value is less than the second value, false otherwise.
53
+ * @returns {boolean} Returns true if the first value is less than the second value, false otherwise.
46
54
  * @example
55
+ * ```handlebars
47
56
  * {{lt val1 val2}}
48
57
  * {{#if (lt val1 val2)}}...{{/if}}
58
+ * ```
49
59
  */
50
60
  export declare const lt: (value1: any, value2: any) => boolean;
51
61
  /**
52
62
  * Check for less than or equals condition (a <= b).
53
63
  * @param {any} value1 First value to be compared with second.
54
64
  * @param {any} value2 Second value to be compared with first.
55
- * @return {boolean} Returns true if the first value is less than or equal to the second value, false otherwise.
65
+ * @returns {boolean} Returns true if the first value is less than or equal to the second value, false otherwise.
56
66
  * @example
67
+ * ```handlebars
57
68
  * {{lte val1 val2}}
58
69
  * {{#if (lte val1 val2)}}...{{/if}}
70
+ * ```
59
71
  */
60
72
  export declare const lte: (value1: any, value2: any) => boolean;
61
73
  /**
62
74
  * Check for greater than condition (a > b).
63
75
  * @param {any} value1 First value to be compared with second.
64
76
  * @param {any} value2 Second value to be compared with first.
65
- * @return {boolean} Returns true if the first value exceeds the second value, false otherwise.
77
+ * @returns {boolean} Returns true if the first value exceeds the second value, false otherwise.
66
78
  * @example
79
+ * ```handlebars
67
80
  * {{gt val1 val2}}
68
81
  * {{#if (gt val1 val2)}}...{{/if}}
82
+ * ```
69
83
  */
70
84
  export declare const gt: (value1: any, value2: any) => boolean;
71
85
  /**
72
86
  * Check for greater than or equals condition (a >= b).
73
87
  * @param {any} value1 First value to be compared with second.
74
88
  * @param {any} value2 Second value to be compared with first.
75
- * @return {boolean} Returns true if the first value is greater than or equal to the second value, false otherwise.
89
+ * @returns {boolean} Returns true if the first value is greater than or equal to the second value, false otherwise.
76
90
  * @example
91
+ * ```handlebars
77
92
  * {{gte val1 val2}}
78
93
  * {{#if (gte val1 val2)}}...{{/if}}
94
+ * ```
79
95
  */
80
96
  export declare const gte: (value1: any, value2: any) => boolean;
81
97
  /**
82
98
  * Logical NOT of any expression.
83
99
  * @param {any} expression Any expression.
84
- * @return {boolean} Returns the logical negation of the value.
100
+ * @returns {boolean} Returns the logical negation of the value.
85
101
  * @example
102
+ * ```handlebars
86
103
  * {{not val}}
87
104
  * {{#if (not (eq val1 val2))}}...{{/if}}
105
+ * ```
88
106
  */
89
107
  export declare const not: (expression: any) => boolean;
90
108
  /**
@@ -92,14 +110,16 @@ export declare const not: (expression: any) => boolean;
92
110
  * @param {boolean} condition Satisfying condition for getting first value. Either true of false.
93
111
  * @param {any} value1 First value to be displayed as result..
94
112
  * @param {any} value2 Second value to be displayed as result. Defaults to an empty string.
95
- * @return {any} Returns the result of the ternary operator.
113
+ * @returns {any} Returns the result of the ternary operator.
96
114
  * @example
115
+ * ```handlebars
97
116
  * {{ifx true val1 val2}}
98
117
  * {{ifx false val1 val2}}
99
118
  * {{ifx (eq val1 val2) val3 val4}}
100
119
  * {{ifx (not (eq val1 val2)) val3 val4}}
101
120
  * {{ifx true val}}
102
121
  * {{ifx false val}}
122
+ * ```
103
123
  */
104
124
  export declare const ifx: (condition: boolean, value1: any, value2: any) => any;
105
125
  /**
@@ -107,10 +127,12 @@ export declare const ifx: (condition: boolean, value1: any, value2: any) => any;
107
127
  * If the value is an array, returns true if there are no elements.
108
128
  * If the value is a string, the leading and trailing spaces are trimmed and then checked.
109
129
  * @param {any} value Character strings, arrays, objects, etc. to be checked.
110
- * @return {boolean} Returns true if the value is empty, false otherwise.
130
+ * @returns {boolean} Returns true if the value is empty, false otherwise.
111
131
  * @example
132
+ * ```handlebars
112
133
  * {{empty val}}
113
134
  * {{#if (empty val)}}...{{/if}}
135
+ * ```
114
136
  */
115
137
  export declare const empty: (value: any) => boolean;
116
138
  /**
@@ -118,45 +140,55 @@ export declare const empty: (value: any) => boolean;
118
140
  * If the value is an array, returns true if there is an element.
119
141
  * If the value is a string, the leading and trailing spaces are trimmed and then checked.
120
142
  * @param {any} value Character strings, arrays, objects, etc. to be checked.
121
- * @return {boolean} Returns true if the value is not empty, false otherwise.
143
+ * @returns {boolean} Returns true if the value is not empty, false otherwise.
122
144
  * @example
145
+ * ```handlebars
123
146
  * {{notEmpty val}}
124
147
  * {{#if (notEmpty val)}}...{{/if}}
148
+ * ```
125
149
  */
126
150
  export declare const notEmpty: (value: any) => boolean;
127
151
  /**
128
152
  * Determine the length of an array.
129
153
  * @param {any[]} items Array whose elements to be counted.
130
- * @return {number|false} Returns the length of the array if the value is an array, false if the value is not an array.
154
+ * @returns {number|false} Returns the length of the array if the value is an array, false if the value is not an array.
131
155
  * @example
156
+ * ```handlebars
132
157
  * {{count val}}
158
+ * ```
133
159
  */
134
160
  export declare const count: (items: any[]) => number | false;
135
161
  /**
136
162
  * Returns the boolean AND of two or more parameters passed i.e it is true iff all the parameters are true.
137
163
  * @param {...any} params Any number of boolean parameters.
138
- * @return {boolean} Returns the result of the logical product.
164
+ * @returns {boolean} Returns the result of the logical product.
139
165
  * @example
166
+ * ```handlebars
140
167
  * {{and val1 val2}}
141
168
  * {{#if (and val1 val2)}}...{{/if}}
169
+ * ```
142
170
  */
143
171
  export declare const and: (...params: any[]) => boolean;
144
172
  /**
145
173
  * Returns the boolean OR of two or more parameters passed i.e it is true if any of the parameters is true.
146
174
  * @param {...any} params Any number of boolean parameters.
147
- * @return {boolean} Returns the result of the OR.
175
+ * @returns {boolean} Returns the result of the OR.
148
176
  * @example
177
+ * ```handlebars
149
178
  * {{or val1 val2}}
150
179
  * {{#if (or val1 val2)}}...{{/if}}
180
+ * ```
151
181
  */
152
182
  export declare const or: (...params: any[]) => boolean;
153
183
  /**
154
184
  * Returns the first non-falsy value from the parameter list.
155
185
  * Works quite similar to the SQL's "COALESCE()" function, but unlike this checks for the first non-false parameter.
156
186
  * @param {...any} params Any number of parameters.
157
- * @return {any} Returns the first non-false element of the parameter.
187
+ * @returns {any} Returns the first non-false element of the parameter.
158
188
  * @example
189
+ * ```handlebars
159
190
  * {{coalesce val1 val2}}
191
+ * ```
160
192
  */
161
193
  export declare const coalesce: (...params: any[]) => any;
162
194
  /**
@@ -164,23 +196,27 @@ export declare const coalesce: (...params: any[]) => any;
164
196
  * @param {any[]} items The array.
165
197
  * @param {any} value The value to be checked for existence in the array.
166
198
  * @param {boolean} strict FALSE for non-strict checking. TRUE by default.
167
- * @return {boolean} Returns true if the array contains the specified value, false otherwise.
199
+ * @returns {boolean} Returns true if the array contains the specified value, false otherwise.
168
200
  * @example
201
+ * ```handlebars
169
202
  * {{includes [1, 2, 3] 2}}
170
203
  * {{includes [1, 2, 3] 2 true}}
171
204
  * {{#if (includes [1, 2, 3] 2)}}...{{/if}}
172
205
  * {{ifx (includes [1, 2, 3] 2) true false}}
206
+ * ```
173
207
  */
174
208
  export declare const includes: (items: any[], value: any, strict?: boolean) => boolean;
175
209
  /**
176
210
  * Returns true if the given str matches the given regex.
177
211
  * @param {string} val The string against which to match the regular expression.
178
212
  * @param {string} pattern The text of the regular expression.
179
- * @param {string} flags? Regular expression flags, such as global and case-insensitive searches. The default is none (undefined).
180
- * @return {boolean} true if there is a match between the regular expression and the string str. Otherwise, false.
213
+ * @param {string} flags Regular expression flags, such as global and case-insensitive searches. The default is none (undefined).
214
+ * @returns {boolean} true if there is a match between the regular expression and the string str. Otherwise, false.
181
215
  * @example
216
+ * ```handlebars
182
217
  * {{regexMatch 'Hello, world!' 'Hello'}}
183
218
  * {{regexMatch 'Hello, world!' 'Hello' 'i'}}
184
219
  * {{#if (regexMatch 'Hello, world!' 'Hello')}}...{{/if}}
220
+ * ```
185
221
  */
186
222
  export declare const regexMatch: (val: string, pattern: string, flags?: string) => boolean;
@@ -3,8 +3,9 @@
3
3
  * @param {string} format A format string based on moment.
4
4
  * @param {string} date Date string to format.
5
5
  * @param {string|string[]} locale Language or language-country locale string (or array of strings) available in https://github.com/moment/moment/tree/develop/locale .
6
- * @return {string} Returns formatted date.
6
+ * @returns {string} Returns formatted date.
7
7
  * @example
8
+ * ```handlebars
8
9
  * {{!-- results in: 2021/10/24 --}}
9
10
  * {{formatDate 'YYYY/MM/DD' "2021-10-24T02:13:06.610Z"}}
10
11
  *
@@ -13,5 +14,6 @@
13
14
  *
14
15
  * {{!-- results in: 2021/10/24 --}}
15
16
  * {{formatDate 'YYYY/MM/DD' "2021-10-24T02:13:06.610Z" 'es'}}
17
+ * ```
16
18
  */
17
19
  export declare const formatDate: (format: string, date: string, locale: string | string[]) => string;
@@ -2,10 +2,12 @@
2
2
  * Returns the Assets path containing the file update time parameter.
3
3
  * @param {string} filePath Paths of Assets files such as CSS and JS in public directories.
4
4
  * @param {string} baseUrl Application Origin URL. The default is none (undefined).
5
- * @return {string} Returns the Assets file path with the update date and time parameters.
5
+ * @returns {string} Returns the Assets file path with the update date and time parameters.
6
6
  * @example
7
+ * ```handlebars
7
8
  * {{!-- results in: example.com/assets/style.css?1620526340463 --}}
8
9
  * {{cacheBusting '/assets/style.css' '//example.com'}}
10
+ * ```
9
11
  */
10
12
  export declare const cacheBusting: (filePath: string, baseUrl?: string) => string;
11
13
  /**
@@ -13,8 +15,9 @@ export declare const cacheBusting: (filePath: string, baseUrl?: string) => strin
13
15
  * @param {string} str The string to remove HTML tags from.
14
16
  * @param {string|string[]} allowedTags An array of allowed HTML tags. Default is an empty array.
15
17
  * @param {string} replacement The string to replace HTML tags with. Default is blank.
16
- * @return {string} The string with HTML tags removed.
18
+ * @returns {string} The string with HTML tags removed.
17
19
  * @example
20
+ * ```handlebars
18
21
  * {{!-- results in: lorem ipsum dolor sit amet --}}
19
22
  * {{{stripTags '<a href="https://example.com">lorem ipsum <strong>dolor</strong> <em>sit</em> amet</a>'}}}
20
23
  *
@@ -23,5 +26,6 @@ export declare const cacheBusting: (filePath: string, baseUrl?: string) => strin
23
26
  *
24
27
  * {{!-- results in: 🍩lorem ipsum 🍩dolor🍩 🍩sit🍩 amet🍩 --}}
25
28
  * {{{stripTags '<a href="https://example.com">lorem ipsum <strong>dolor</strong> <em>sit</em> amet</a>' [] '🍩'}}}
29
+ * ```
26
30
  */
27
31
  export declare const stripTags: (str: string, allowedTags?: string | string[], replacement?: string) => string;
@@ -1,9 +1,73 @@
1
- export * as array from '~/handlebars_helpers/array';
2
- export * as html from '~/handlebars_helpers/html';
3
- export * as object from '~/handlebars_helpers/object';
4
- export * as string from '~/handlebars_helpers/string';
5
- export * as comparison from '~/handlebars_helpers/comparison';
6
- export * as date from '~/handlebars_helpers/date';
7
- export * as number from '~/handlebars_helpers/number';
8
- export * as math from '~/handlebars_helpers/math';
9
- export * as layouts from '~/handlebars_helpers/layouts';
1
+ /**
2
+ * Handlebars template helpers for Express Sweet.
3
+ *
4
+ * Provides a comprehensive set of custom Handlebars helpers for array manipulation,
5
+ * string operations, date formatting, mathematical operations, comparisons, and more.
6
+ * These helpers are automatically registered with the Handlebars engine.
7
+ *
8
+ * @module handlebars_helpers
9
+ * @see {@link https://handlebarsjs.com/guide/ | Handlebars Guide}
10
+ * @example
11
+ * ```handlebars
12
+ * // Using comparison helpers in templates
13
+ * {{#if (eq status 'active')}}
14
+ * <span class="badge-active">Active</span>
15
+ * {{/if}}
16
+ * ```
17
+ *
18
+ * @example
19
+ * ```handlebars
20
+ * // Using string helpers in templates
21
+ * {{replace title 'old' 'new'}}
22
+ * {{formatBytes fileSize 2}}
23
+ * ```
24
+ *
25
+ * @example
26
+ * ```handlebars
27
+ * // Using date helpers in templates
28
+ * {{formatDate 'YYYY/MM/DD' createdAt}}
29
+ * ```
30
+ *
31
+ * @example
32
+ * ```handlebars
33
+ * // Using math helpers in templates
34
+ * {{add price tax}}
35
+ * {{multiply quantity unitPrice}}
36
+ * ```
37
+ */
38
+ /**
39
+ * Array manipulation helpers (findObjectInArray)
40
+ */
41
+ export * as array from './array';
42
+ /**
43
+ * HTML processing helpers (cacheBusting, stripTags)
44
+ */
45
+ export * as html from './html';
46
+ /**
47
+ * Object utilities helpers (jsonStringify, jsonParse)
48
+ */
49
+ export * as object from './object';
50
+ /**
51
+ * String manipulation helpers (replace, split, formatBytes)
52
+ */
53
+ export * as string from './string';
54
+ /**
55
+ * Comparison and logic helpers (eq, neq, gt, lt, and, or, etc.)
56
+ */
57
+ export * as comparison from './comparison';
58
+ /**
59
+ * Date formatting helpers (formatDate)
60
+ */
61
+ export * as date from './date';
62
+ /**
63
+ * Number formatting helpers (number2locale)
64
+ */
65
+ export * as number from './number';
66
+ /**
67
+ * Mathematical operation helpers (add, sub, multiply, divide, etc.)
68
+ */
69
+ export * as math from './math';
70
+ /**
71
+ * Layout and template helpers (contentFor blocks)
72
+ */
73
+ export * as layouts from './layouts';
@@ -3,9 +3,11 @@
3
3
  * Imported from {@link https://github.com/TryGhost/express-hbs|express-hbs}
4
4
  * @param {string} name Block Name.
5
5
  * @param {Handlebars.HelperOptions} options Helper Options.
6
- * @return {string} String.
6
+ * @returns {string} String.
7
7
  * @example
8
+ * ```handlebars
8
9
  * {{{block "pageScripts"}}}
10
+ * ```
9
11
  */
10
12
  export declare const block: (this: any, name: string, options: Handlebars.HelperOptions) => any;
11
13
  /**
@@ -14,8 +16,10 @@ export declare const block: (this: any, name: string, options: Handlebars.Helper
14
16
  * @param {string} name Block Name.
15
17
  * @param {Handlebars.HelperOptions} options Helper Options.
16
18
  * @example
19
+ * ```handlebars
17
20
  * {{#contentFor "pageScripts"}}
18
21
  * CONTENT HERE
19
22
  * {{/contentFor}}
23
+ * ```
20
24
  */
21
25
  export declare const contentFor: (this: any, name: string, options: any) => void;
@@ -2,59 +2,73 @@
2
2
  * Calculates the sum of two numbers.
3
3
  * @param {number|string} val1 The first number.
4
4
  * @param {number|string} val2 The second number.
5
- * @return {number}
5
+ * @returns {number}
6
6
  * @example
7
+ * ```handlebars
7
8
  * {{add 1 2}}
9
+ * ```
8
10
  */
9
11
  export declare const add: (val1: number | string, val2: number | string) => number;
10
12
  /**
11
13
  * Calculates the difference of the given values.
12
14
  * @param {number|string} val1 The first number.
13
15
  * @param {number|string} val2 The second number.
14
- * @return {number}
16
+ * @returns {number}
15
17
  * @example
18
+ * ```handlebars
16
19
  * {{sub 5 2}}
20
+ * ```
17
21
  */
18
22
  export declare const sub: (val1: number | string, val2: number | string) => number;
19
23
  /**
20
24
  * Calculate the multiplication of the given values.
21
25
  * @param {number|string} val1 The first number.
22
26
  * @param {number|string} val2 The second number.
23
- * @return {number}
27
+ * @returns {number}
24
28
  * @example
29
+ * ```handlebars
25
30
  * {{multiply 5 2}}
31
+ * ```
26
32
  */
27
33
  export declare const multiply: (val1: number | string, val2: number | string) => number;
28
34
  /**
29
35
  * Compute the division of the given values.
30
36
  * @param {number|string} val1 The first number.
31
37
  * @param {number|string} val2 The second number.
32
- * @return {number}
38
+ * @returns {number}
33
39
  * @example
40
+ * ```handlebars
34
41
  * {{divide 10 2}}
42
+ * ```
35
43
  */
36
44
  export declare const divide: (val1: number | string, val2: number | string) => number;
37
45
  /**
38
46
  * Round up the value.
39
47
  * @param {number|string} val Number to be rounded to nearest greater integer.
40
- * @return {number}
48
+ * @returns {number}
41
49
  * @example
50
+ * ```handlebars
42
51
  * {{ceil 5.6}}
52
+ * ```
43
53
  */
44
54
  export declare const ceil: (val: number | string) => number;
45
55
  /**
46
56
  * Rounds down a number.
47
57
  * @param {number|string} val Number to be rounded to nearest lower integer.
48
- * @return {number}
58
+ * @returns {number}
49
59
  * @example
60
+ * ```handlebars
50
61
  * {{floor 5.6}}
62
+ * ```
51
63
  */
52
64
  export declare const floor: (val: number | string) => number;
53
65
  /**
54
66
  * Returns an absolute value.
55
67
  * @param {number} val Number to perform absolute value operation on.
56
- * @return {number}
68
+ * @returns {number}
57
69
  * @example
70
+ * ```handlebars
58
71
  * {{abs -5.6}}
72
+ * ```
59
73
  */
60
74
  export declare const abs: (val: number | string) => number;
@@ -4,13 +4,15 @@
4
4
  * @param {string|undefined} locales A string with a BCP 47 language tag, or an array of such strings.
5
5
  * Corresponds to the <a href="/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#locales">locales</a> parameter of the Intl.NumberFormat() constructor.
6
6
  * In implementations without Intl.NumberFormat support, this parameter is ignored and the host's locale is usually used.
7
- * @return {string} A string with a language-sensitive representation of the given number.
7
+ * @returns {string} A string with a language-sensitive representation of the given number.
8
8
  * @example
9
+ * ```handlebars
9
10
  * {{!-- results in: 123,456.789 --}}
10
11
  * {{number2locale 123456.789}}
11
12
  *
12
13
  * {{!-- German uses comma as decimal separator and period for thousands. --}}
13
14
  * {{!-- results in: 123.456,789 --}}
14
15
  * {{number2locale 123456.789 'de-DE'}}
16
+ * ```
15
17
  */
16
18
  export declare const number2locale: (val: number | string, locales?: string) => string;
@@ -2,16 +2,20 @@
2
2
  * Stringify an object using JSON.stringify.
3
3
  * @param {any} value The value to convert to a JSON string.
4
4
  * @param {number} indent The number of space characters to use as whitespace.
5
- * @return {string} A JSON string representing the given value, or undefined.
5
+ * @returns {string} A JSON string representing the given value, or undefined.
6
6
  * @example
7
+ * ```handlebars
7
8
  * {{jsonStringify val}}
9
+ * ```
8
10
  */
9
11
  export declare const jsonStringify: (value: any, indent?: number | string) => string | undefined;
10
12
  /**
11
13
  * Parses the given string using JSON.parse.
12
14
  * @param {any} value Object to stringify.
13
- * @return {any} JavaScript value or object described by a string.
15
+ * @returns {any} JavaScript value or object described by a string.
14
16
  * @example
17
+ * ```handlebars
15
18
  * {{jsonParse val}}
19
+ * ```
16
20
  */
17
21
  export declare const jsonParse: (value: any) => any;
@@ -3,27 +3,32 @@
3
3
  * @param {string} value String.
4
4
  * @param {string} find The string to be replaced.
5
5
  * @param {string} replace The string to replace.
6
- * @return {string} Character string after replacement.
6
+ * @returns {string} Character string after replacement.
7
7
  * @example
8
+ * ```handlebars
8
9
  * {{replace 'The quick brown fox jumps over the lazy dog. If the dog reacted, was it really lazy?' 'dog' 'monkey'}}
10
+ * ```
9
11
  */
10
12
  export declare const replace: (value: string, find: string, replace: string) => string;
11
13
  /**
12
14
  * Split `string` by the given `character`.
13
15
  * @param {string} value String.
14
16
  * @param {string} separator A character that delimits the substrings in this string. Default is a comma.
15
- * @return {string[]} An Array of strings, split at each point where the separator occurs in the given string. The default is a comma.
17
+ * @returns {string[]} An Array of strings, split at each point where the separator occurs in the given string. The default is a comma.
16
18
  * @example
19
+ * ```handlebars
17
20
  * {{split "a,b,c" ","}}
18
21
  * {{#each (split list ',')}}<div>{{this}}</div>{{/each}}
22
+ * ```
19
23
  */
20
24
  export declare const split: (value: string, separator: string) => string[];
21
25
  /**
22
26
  * Convert bytes to just the right units(KB, MB, GB, TB, PB, EB, ZB, YB).
23
27
  * @param {number} bytes Bytes.
24
28
  * @param {number} decimals Number of decimal places to display. Default is 0.
25
- * @return {string} Returns a value with units.
29
+ * @returns {string} Returns a value with units.
26
30
  * @example
31
+ * ```handlebars
27
32
  * {{!-- results in: 1 KB --}}
28
33
  * {{formatBytes 1024}}
29
34
  *
@@ -35,5 +40,6 @@ export declare const split: (value: string, separator: string) => string[];
35
40
  *
36
41
  * {{!-- results in: 0 Bytes --}}
37
42
  * {{formatBytes 0}}
43
+ * ```
38
44
  */
39
45
  export declare const formatBytes: (bytes: number, decimals?: number) => string;
package/types/index.d.ts CHANGED
@@ -1,6 +1,93 @@
1
+ /**
2
+ * Express Sweet - A powerful Express.js extension library
3
+ *
4
+ * Express Sweet streamlines web development with utilities and enhancements for Express.js applications.
5
+ * It provides database abstraction, authentication, view templating, routing, and various middleware components.
6
+ *
7
+ * @module express-sweet
8
+ * @author Takuya Motoshima
9
+ * @see {@link https://github.com/takuya-motoshima/express-sweet | Express Sweet Repository}
10
+ * @example
11
+ * ```js
12
+ * // Basic usage
13
+ * import express from 'express';
14
+ * import * as expx from 'express-sweet';
15
+ *
16
+ * const app = express();
17
+ * await expx.mount(app);
18
+ *
19
+ * app.listen(3000, () => {
20
+ * console.log('Server running on port 3000');
21
+ * });
22
+ * ```
23
+ *
24
+ * @example
25
+ * ```js
26
+ * // Using database models
27
+ * import * as expx from 'express-sweet';
28
+ *
29
+ * export default class extends expx.database.Model {
30
+ * static get table() {
31
+ * return 'users';
32
+ * }
33
+ * static get attributes() {
34
+ * return {
35
+ * id: { type: this.DataTypes.INTEGER, primaryKey: true },
36
+ * name: this.DataTypes.STRING,
37
+ * email: this.DataTypes.STRING
38
+ * };
39
+ * }
40
+ * }
41
+ * ```
42
+ *
43
+ * @example
44
+ * ```js
45
+ * // Using authentication service
46
+ * import * as expx from 'express-sweet';
47
+ *
48
+ * router.post('/login', async (req, res, next) => {
49
+ * const isAuthenticated = await expx.services.Authentication.authenticate(req, res, next);
50
+ * res.json(isAuthenticated);
51
+ * });
52
+ * ```
53
+ */
54
+ /**
55
+ * Main application mount function
56
+ * @function mount
57
+ */
1
58
  export { default as mount } from '~/mount';
2
- export * as database from '~/database';
3
- export * as services from '~/services';
4
- export * as utils from '~/utils';
5
- export * as middlewares from '~/middlewares';
6
- export * as interfaces from '~/interfaces';
59
+ /**
60
+ * Database utilities and ORM functionality
61
+ * @namespace database
62
+ */
63
+ export * as database from './database';
64
+ /**
65
+ * Authentication and other services
66
+ * @namespace services
67
+ */
68
+ export * as services from './services';
69
+ /**
70
+ * Utility functions for type checking and configuration loading
71
+ * @namespace utils
72
+ */
73
+ export * as utils from './utils';
74
+ /**
75
+ * Express middleware components
76
+ * @namespace middlewares
77
+ */
78
+ export * as middlewares from './middlewares';
79
+ /**
80
+ * TypeScript interfaces for configuration
81
+ * @namespace interfaces
82
+ */
83
+ export * as interfaces from './interfaces';
84
+ /**
85
+ * Custom Handlebars template helpers
86
+ * @namespace handlebars_helpers
87
+ */
88
+ export * as handlebars_helpers from './handlebars_helpers';
89
+ /**
90
+ * Express routing utilities
91
+ * @namespace routing
92
+ */
93
+ export * as routing from './routing';