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
@@ -1,222 +0,0 @@
1
- /**
2
- * Determine whether or not two values are equal (===).
3
- * @param {any} value1 First value to be compared with second.
4
- * @param {any} value2 Second value to be compared with first.
5
- * @returns {boolean} Returns true if the value and type are the same, false if they are different.
6
- * @example
7
- * ```handlebars
8
- * {{eq val1 val2}}
9
- * {{#if (eqw val1 val2)}}...{{/if}}
10
- * ```
11
- */
12
- export declare const eq: (value1: any, value2: any) => boolean;
13
- /**
14
- * Determine whether or not two values are equal (==) i.e weak checking.
15
- * @param {any} value1 First value to be compared with second.
16
- * @param {any} value2 Second value to be compared with first.
17
- * @returns {boolean} Returns true if the values are the same, false if they are different.
18
- * @example
19
- * ```handlebars
20
- * {{eqw val1 val2}}
21
- * {{#if (eqw val1 val2)}}...{{/if}}
22
- * ```
23
- */
24
- export declare const eqw: (value1: any, value2: any) => boolean;
25
- /**
26
- * Determine whether or not two values are not equal (!==).
27
- * @param {any} value1 First value to be compared with second.
28
- * @param {any} value2 Second value to be compared with first.
29
- * @returns {boolean} Returns true if the value and type are different, false if they are the same.
30
- * @example
31
- * ```handlebars
32
- * {{neq val1 val2}}
33
- * {{#if (neq val1 val2)}}...{{/if}}
34
- * ```
35
- */
36
- export declare const neq: (value1: any, value2: any) => boolean;
37
- /**
38
- * Determine whether or not two values are not equal (!=) weak checking.
39
- * @param {any} value1 First value to be compared with second.
40
- * @param {any} value2 Second value to be compared with first.
41
- * @returns {boolean} Returns true if the values are different, false if they are the same.
42
- * @example
43
- * ```handlebars
44
- * {{neqw val1 val2}}
45
- * {{#if (neqw val1 val2)}}...{{/if}}
46
- * ```
47
- */
48
- export declare const neqw: (value1: any, value2: any) => boolean;
49
- /**
50
- * Check for less than condition (a < b).
51
- * @param {any} value1 First value to be compared with second.
52
- * @param {any} value2 Second value to be compared with first.
53
- * @returns {boolean} Returns true if the first value is less than the second value, false otherwise.
54
- * @example
55
- * ```handlebars
56
- * {{lt val1 val2}}
57
- * {{#if (lt val1 val2)}}...{{/if}}
58
- * ```
59
- */
60
- export declare const lt: (value1: any, value2: any) => boolean;
61
- /**
62
- * Check for less than or equals condition (a <= b).
63
- * @param {any} value1 First value to be compared with second.
64
- * @param {any} value2 Second value to be compared with first.
65
- * @returns {boolean} Returns true if the first value is less than or equal to the second value, false otherwise.
66
- * @example
67
- * ```handlebars
68
- * {{lte val1 val2}}
69
- * {{#if (lte val1 val2)}}...{{/if}}
70
- * ```
71
- */
72
- export declare const lte: (value1: any, value2: any) => boolean;
73
- /**
74
- * Check for greater than condition (a > b).
75
- * @param {any} value1 First value to be compared with second.
76
- * @param {any} value2 Second value to be compared with first.
77
- * @returns {boolean} Returns true if the first value exceeds the second value, false otherwise.
78
- * @example
79
- * ```handlebars
80
- * {{gt val1 val2}}
81
- * {{#if (gt val1 val2)}}...{{/if}}
82
- * ```
83
- */
84
- export declare const gt: (value1: any, value2: any) => boolean;
85
- /**
86
- * Check for greater than or equals condition (a >= b).
87
- * @param {any} value1 First value to be compared with second.
88
- * @param {any} value2 Second value to be compared with first.
89
- * @returns {boolean} Returns true if the first value is greater than or equal to the second value, false otherwise.
90
- * @example
91
- * ```handlebars
92
- * {{gte val1 val2}}
93
- * {{#if (gte val1 val2)}}...{{/if}}
94
- * ```
95
- */
96
- export declare const gte: (value1: any, value2: any) => boolean;
97
- /**
98
- * Logical NOT of any expression.
99
- * @param {any} expression Any expression.
100
- * @returns {boolean} Returns the logical negation of the value.
101
- * @example
102
- * ```handlebars
103
- * {{not val}}
104
- * {{#if (not (eq val1 val2))}}...{{/if}}
105
- * ```
106
- */
107
- export declare const not: (expression: any) => boolean;
108
- /**
109
- * Helper to imitate the ternary '?:' conditional operator.
110
- * @param {boolean} condition Satisfying condition for getting first value. Either true of false.
111
- * @param {any} value1 First value to be displayed as result..
112
- * @param {any} value2 Second value to be displayed as result. Defaults to an empty string.
113
- * @returns {any} Returns the result of the ternary operator.
114
- * @example
115
- * ```handlebars
116
- * {{ifx true val1 val2}}
117
- * {{ifx false val1 val2}}
118
- * {{ifx (eq val1 val2) val3 val4}}
119
- * {{ifx (not (eq val1 val2)) val3 val4}}
120
- * {{ifx true val}}
121
- * {{ifx false val}}
122
- * ```
123
- */
124
- export declare const ifx: (condition: boolean, value1: any, value2: any) => any;
125
- /**
126
- * Check if it is empty.
127
- * If the value is an array, returns true if there are no elements.
128
- * If the value is a string, the leading and trailing spaces are trimmed and then checked.
129
- * @param {any} value Character strings, arrays, objects, etc. to be checked.
130
- * @returns {boolean} Returns true if the value is empty, false otherwise.
131
- * @example
132
- * ```handlebars
133
- * {{empty val}}
134
- * {{#if (empty val)}}...{{/if}}
135
- * ```
136
- */
137
- export declare const empty: (value: any) => boolean;
138
- /**
139
- * Check that it is not empty.
140
- * If the value is an array, returns true if there is an element.
141
- * If the value is a string, the leading and trailing spaces are trimmed and then checked.
142
- * @param {any} value Character strings, arrays, objects, etc. to be checked.
143
- * @returns {boolean} Returns true if the value is not empty, false otherwise.
144
- * @example
145
- * ```handlebars
146
- * {{notEmpty val}}
147
- * {{#if (notEmpty val)}}...{{/if}}
148
- * ```
149
- */
150
- export declare const notEmpty: (value: any) => boolean;
151
- /**
152
- * Determine the length of an array.
153
- * @param {any[]} items Array whose elements to be counted.
154
- * @returns {number|false} Returns the length of the array if the value is an array, false if the value is not an array.
155
- * @example
156
- * ```handlebars
157
- * {{count val}}
158
- * ```
159
- */
160
- export declare const count: (items: any[]) => number | false;
161
- /**
162
- * Returns the boolean AND of two or more parameters passed i.e it is true iff all the parameters are true.
163
- * @param {...any} params Any number of boolean parameters.
164
- * @returns {boolean} Returns the result of the logical product.
165
- * @example
166
- * ```handlebars
167
- * {{and val1 val2}}
168
- * {{#if (and val1 val2)}}...{{/if}}
169
- * ```
170
- */
171
- export declare const and: (...params: any[]) => boolean;
172
- /**
173
- * Returns the boolean OR of two or more parameters passed i.e it is true if any of the parameters is true.
174
- * @param {...any} params Any number of boolean parameters.
175
- * @returns {boolean} Returns the result of the OR.
176
- * @example
177
- * ```handlebars
178
- * {{or val1 val2}}
179
- * {{#if (or val1 val2)}}...{{/if}}
180
- * ```
181
- */
182
- export declare const or: (...params: any[]) => boolean;
183
- /**
184
- * Returns the first non-falsy value from the parameter list.
185
- * Works quite similar to the SQL's "COALESCE()" function, but unlike this checks for the first non-false parameter.
186
- * @param {...any} params Any number of parameters.
187
- * @returns {any} Returns the first non-false element of the parameter.
188
- * @example
189
- * ```handlebars
190
- * {{coalesce val1 val2}}
191
- * ```
192
- */
193
- export declare const coalesce: (...params: any[]) => any;
194
- /**
195
- * Returns boolean if the array contains the element strictly or non-strictly.
196
- * @param {any[]} items The array.
197
- * @param {any} value The value to be checked for existence in the array.
198
- * @param {boolean} strict FALSE for non-strict checking. TRUE by default.
199
- * @returns {boolean} Returns true if the array contains the specified value, false otherwise.
200
- * @example
201
- * ```handlebars
202
- * {{includes [1, 2, 3] 2}}
203
- * {{includes [1, 2, 3] 2 true}}
204
- * {{#if (includes [1, 2, 3] 2)}}...{{/if}}
205
- * {{ifx (includes [1, 2, 3] 2) true false}}
206
- * ```
207
- */
208
- export declare const includes: (items: any[], value: any, strict?: boolean) => boolean;
209
- /**
210
- * Returns true if the given str matches the given regex.
211
- * @param {string} val The string against which to match the regular expression.
212
- * @param {string} pattern The text of the regular expression.
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.
215
- * @example
216
- * ```handlebars
217
- * {{regexMatch 'Hello, world!' 'Hello'}}
218
- * {{regexMatch 'Hello, world!' 'Hello' 'i'}}
219
- * {{#if (regexMatch 'Hello, world!' 'Hello')}}...{{/if}}
220
- * ```
221
- */
222
- export declare const regexMatch: (val: string, pattern: string, flags?: string) => boolean;
@@ -1,19 +0,0 @@
1
- /**
2
- * Use moment to format the date.
3
- * @param {string} format A format string based on moment.
4
- * @param {string} date Date string to format.
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
- * @returns {string} Returns formatted date.
7
- * @example
8
- * ```handlebars
9
- * {{!-- results in: 2021/10/24 --}}
10
- * {{formatDate 'YYYY/MM/DD' "2021-10-24T02:13:06.610Z"}}
11
- *
12
- * {{!-- results in: 2021/10/24 --}}
13
- * {{formatDate 'YYYY/MM/DD' "2021-10-24T02:13:06.610Z" 'jp'}}
14
- *
15
- * {{!-- results in: 2021/10/24 --}}
16
- * {{formatDate 'YYYY/MM/DD' "2021-10-24T02:13:06.610Z" 'es'}}
17
- * ```
18
- */
19
- export declare const formatDate: (format: string, date: string, locale: string | string[]) => string;
@@ -1,31 +0,0 @@
1
- /**
2
- * Returns the Assets path containing the file update time parameter.
3
- * @param {string} filePath Paths of Assets files such as CSS and JS in public directories.
4
- * @param {string} baseUrl Application Origin URL. The default is none (undefined).
5
- * @returns {string} Returns the Assets file path with the update date and time parameters.
6
- * @example
7
- * ```handlebars
8
- * {{!-- results in: example.com/assets/style.css?1620526340463 --}}
9
- * {{cacheBusting '/assets/style.css' '//example.com'}}
10
- * ```
11
- */
12
- export declare const cacheBusting: (filePath: string, baseUrl?: string) => string;
13
- /**
14
- * Removes HTML tags from a string, optionally allowing specific tags.
15
- * @param {string} str The string to remove HTML tags from.
16
- * @param {string|string[]} allowedTags An array of allowed HTML tags. Default is an empty array.
17
- * @param {string} replacement The string to replace HTML tags with. Default is blank.
18
- * @returns {string} The string with HTML tags removed.
19
- * @example
20
- * ```handlebars
21
- * {{!-- results in: lorem ipsum dolor sit amet --}}
22
- * {{{stripTags '<a href="https://example.com">lorem ipsum <strong>dolor</strong> <em>sit</em> amet</a>'}}}
23
- *
24
- * {{!-- results in: lorem ipsum <strong>dolor</strong> sit amet --}}
25
- * {{{stripTags '<a href="https://example.com">lorem ipsum <strong>dolor</strong> <em>sit</em> amet</a>' '<strong>' ''}}}
26
- *
27
- * {{!-- results in: 🍩lorem ipsum 🍩dolor🍩 🍩sit🍩 amet🍩 --}}
28
- * {{{stripTags '<a href="https://example.com">lorem ipsum <strong>dolor</strong> <em>sit</em> amet</a>' [] '🍩'}}}
29
- * ```
30
- */
31
- export declare const stripTags: (str: string, allowedTags?: string | string[], replacement?: string) => string;
@@ -1,25 +0,0 @@
1
- /**
2
- * Declare block race holders in layout.
3
- * Imported from {@link https://github.com/TryGhost/express-hbs|express-hbs}
4
- * @param {string} name Block Name.
5
- * @param {Handlebars.HelperOptions} options Helper Options.
6
- * @returns {string} String.
7
- * @example
8
- * ```handlebars
9
- * {{{block "pageScripts"}}}
10
- * ```
11
- */
12
- export declare const block: (this: any, name: string, options: Handlebars.HelperOptions) => any;
13
- /**
14
- * Define block content within a page.
15
- * Imported from {@link https://github.com/TryGhost/express-hbs|express-hbs}
16
- * @param {string} name Block Name.
17
- * @param {Handlebars.HelperOptions} options Helper Options.
18
- * @example
19
- * ```handlebars
20
- * {{#contentFor "pageScripts"}}
21
- * CONTENT HERE
22
- * {{/contentFor}}
23
- * ```
24
- */
25
- export declare const contentFor: (this: any, name: string, options: any) => void;
@@ -1,74 +0,0 @@
1
- /**
2
- * Calculates the sum of two numbers.
3
- * @param {number|string} val1 The first number.
4
- * @param {number|string} val2 The second number.
5
- * @returns {number}
6
- * @example
7
- * ```handlebars
8
- * {{add 1 2}}
9
- * ```
10
- */
11
- export declare const add: (val1: number | string, val2: number | string) => number;
12
- /**
13
- * Calculates the difference of the given values.
14
- * @param {number|string} val1 The first number.
15
- * @param {number|string} val2 The second number.
16
- * @returns {number}
17
- * @example
18
- * ```handlebars
19
- * {{sub 5 2}}
20
- * ```
21
- */
22
- export declare const sub: (val1: number | string, val2: number | string) => number;
23
- /**
24
- * Calculate the multiplication of the given values.
25
- * @param {number|string} val1 The first number.
26
- * @param {number|string} val2 The second number.
27
- * @returns {number}
28
- * @example
29
- * ```handlebars
30
- * {{multiply 5 2}}
31
- * ```
32
- */
33
- export declare const multiply: (val1: number | string, val2: number | string) => number;
34
- /**
35
- * Compute the division of the given values.
36
- * @param {number|string} val1 The first number.
37
- * @param {number|string} val2 The second number.
38
- * @returns {number}
39
- * @example
40
- * ```handlebars
41
- * {{divide 10 2}}
42
- * ```
43
- */
44
- export declare const divide: (val1: number | string, val2: number | string) => number;
45
- /**
46
- * Round up the value.
47
- * @param {number|string} val Number to be rounded to nearest greater integer.
48
- * @returns {number}
49
- * @example
50
- * ```handlebars
51
- * {{ceil 5.6}}
52
- * ```
53
- */
54
- export declare const ceil: (val: number | string) => number;
55
- /**
56
- * Rounds down a number.
57
- * @param {number|string} val Number to be rounded to nearest lower integer.
58
- * @returns {number}
59
- * @example
60
- * ```handlebars
61
- * {{floor 5.6}}
62
- * ```
63
- */
64
- export declare const floor: (val: number | string) => number;
65
- /**
66
- * Returns an absolute value.
67
- * @param {number} val Number to perform absolute value operation on.
68
- * @returns {number}
69
- * @example
70
- * ```handlebars
71
- * {{abs -5.6}}
72
- * ```
73
- */
74
- export declare const abs: (val: number | string) => number;
@@ -1,18 +0,0 @@
1
- /**
2
- * Returns the language-sensitive representation of a number as a string.
3
- * @param {number|string} val Target number or numeric string.
4
- * @param {string|undefined} locales A string with a BCP 47 language tag, or an array of such strings.
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
- * In implementations without Intl.NumberFormat support, this parameter is ignored and the host's locale is usually used.
7
- * @returns {string} A string with a language-sensitive representation of the given number.
8
- * @example
9
- * ```handlebars
10
- * {{!-- results in: 123,456.789 --}}
11
- * {{number2locale 123456.789}}
12
- *
13
- * {{!-- German uses comma as decimal separator and period for thousands. --}}
14
- * {{!-- results in: 123.456,789 --}}
15
- * {{number2locale 123456.789 'de-DE'}}
16
- * ```
17
- */
18
- export declare const number2locale: (val: number | string, locales?: string) => string;
@@ -1,21 +0,0 @@
1
- /**
2
- * Stringify an object using JSON.stringify.
3
- * @param {any} value The value to convert to a JSON string.
4
- * @param {number} indent The number of space characters to use as whitespace.
5
- * @returns {string} A JSON string representing the given value, or undefined.
6
- * @example
7
- * ```handlebars
8
- * {{jsonStringify val}}
9
- * ```
10
- */
11
- export declare const jsonStringify: (value: any, indent?: number | string) => string | undefined;
12
- /**
13
- * Parses the given string using JSON.parse.
14
- * @param {any} value JSON string to parse.
15
- * @returns {any} JavaScript value or object described by the string.
16
- * @example
17
- * ```handlebars
18
- * {{jsonParse val}}
19
- * ```
20
- */
21
- export declare const jsonParse: (value: any) => any;
@@ -1,45 +0,0 @@
1
- /**
2
- * Returns a new string with some or all matches of a pattern replaced by a replacement.
3
- * @param {string} value String.
4
- * @param {string} find The string to be replaced.
5
- * @param {string} replace The string to replace.
6
- * @returns {string} Character string after replacement.
7
- * @example
8
- * ```handlebars
9
- * {{replace 'The quick brown fox jumps over the lazy dog. If the dog reacted, was it really lazy?' 'dog' 'monkey'}}
10
- * ```
11
- */
12
- export declare const replace: (value: string, find: string, replace: string) => string;
13
- /**
14
- * Split `string` by the given `character`.
15
- * @param {string} value String.
16
- * @param {string} separator A character that delimits the substrings in this string. 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.
18
- * @example
19
- * ```handlebars
20
- * {{split "a,b,c" ","}}
21
- * {{#each (split list ',')}}<div>{{this}}</div>{{/each}}
22
- * ```
23
- */
24
- export declare const split: (value: string, separator: string) => string[];
25
- /**
26
- * Convert bytes to just the right units(KB, MB, GB, TB, PB, EB, ZB, YB).
27
- * @param {number} bytes Bytes.
28
- * @param {number} decimals Number of decimal places to display. Default is 0.
29
- * @returns {string} Returns a value with units.
30
- * @example
31
- * ```handlebars
32
- * {{!-- results in: 1 KB --}}
33
- * {{formatBytes 1024}}
34
- *
35
- * {{!-- results in: 1.21 KB --}}
36
- * {{formatBytes 1234 2}}
37
- *
38
- * {{!-- results in: 1.205 KB --}}
39
- * {{formatBytes 1234 3}}
40
- *
41
- * {{!-- results in: 0 Bytes --}}
42
- * {{formatBytes 0}}
43
- * ```
44
- */
45
- export declare const formatBytes: (bytes: number, decimals?: number) => string;
@@ -1,28 +0,0 @@
1
- import express from 'express';
2
- /**
3
- * Enables Cross-Origin Resource Sharing (CORS) middleware.
4
- * Allows requests from another domain to the application by setting appropriate headers.
5
- *
6
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS | MDN CORS}
7
- * @example
8
- * ```js
9
- * // Enable CORS in config/config.js
10
- * export default {
11
- * cors_enabled: true
12
- * };
13
- * ```
14
- */
15
- /**
16
- * Mount CORS middleware on Express application.
17
- * Sets appropriate CORS headers to allow cross-origin requests.
18
- * @param {express.Express} app Express application instance
19
- * @returns {Promise<void>}
20
- * @example
21
- * ```js
22
- * // This method is called automatically by express-sweet.mount()
23
- * import corsPolicy from './middlewares/corsPolicy';
24
- *
25
- * await corsPolicy(app);
26
- * ```
27
- */
28
- export default function corsPolicy(app: express.Express): Promise<void>;
@@ -1,34 +0,0 @@
1
- /**
2
- * Mount environment variables from .env file.
3
- * Reads the environment variable file specified in config and sets variables in process.env.
4
- * Prevents multiple loading with a global flag.
5
- *
6
- * @example
7
- * ```js
8
- * // Environment variables configuration in config/config.js
9
- * export default {
10
- * env_path: '.env' // Path to environment file
11
- * };
12
- * ```
13
- *
14
- * @example
15
- * ```bash
16
- * // .env file contents
17
- * NODE_ENV=development
18
- * DATABASE_URL=mysql://localhost/mydb
19
- * SECRET_KEY=mysecret
20
- * ```
21
- */
22
- /**
23
- * Mount environment variables on application.
24
- * Loads .env file and sets variables in process.env if not already loaded.
25
- * @returns {Promise<void>}
26
- * @example
27
- * ```js
28
- * // This method is called automatically by express-sweet.mount()
29
- * import envLoader from './middlewares/envLoader';
30
- *
31
- * await envLoader();
32
- * ```
33
- */
34
- export default function envLoader(): Promise<void>;
@@ -1,32 +0,0 @@
1
- import express from 'express';
2
- /**
3
- * Error handling middleware for Express applications.
4
- * Catches 404 errors and provides customizable error handling through hooks.
5
- *
6
- * @example
7
- * ```js
8
- * // Custom error handling in config/config.js
9
- * export default {
10
- * hook_handle_error: (error, req, res, next) => {
11
- * if (error.status === 404)
12
- * res.render('error/404');
13
- * else
14
- * res.render('error/500');
15
- * }
16
- * };
17
- * ```
18
- */
19
- /**
20
- * Mount error handling middleware on Express application.
21
- * Sets up 404 error catching and custom error handling hooks.
22
- * @param {express.Express} app Express application instance
23
- * @returns {Promise<void>}
24
- * @example
25
- * ```js
26
- * // This method is called automatically by express-sweet.mount()
27
- * import errorHandler from './middlewares/errorHandler';
28
- *
29
- * await errorHandler(app);
30
- * ```
31
- */
32
- export default function errorHandler(app: express.Express): Promise<void>;
@@ -1,25 +0,0 @@
1
- /**
2
- * Set global variables accessible throughout the application.
3
- * Variables can be accessed like "global.xxx" in all router and model classes.
4
- *
5
- * Global variables set:
6
- * - APP_DIR: The directory where app.js is located (process.cwd())
7
- *
8
- * @example
9
- * ```js
10
- * // Access in any router or model
11
- * console.log(global.APP_DIR); // "/path/to/your/app"
12
- * ```
13
- */
14
- /**
15
- * Mount global variables on application.
16
- * Sets up global.APP_DIR for access throughout the application.
17
- * @example
18
- * ```js
19
- * // This method is called automatically by express-sweet.mount()
20
- * import globalVars from './middlewares/globalVars';
21
- *
22
- * globalVars();
23
- * ```
24
- */
25
- export default function globalVars(): void;
@@ -1,44 +0,0 @@
1
- import express from 'express';
2
- /**
3
- * Set local variables accessible in Handlebars views.
4
- * Variables can be accessed in all views as {{var}} or {{{var}}}.
5
- *
6
- * Local variables set:
7
- * - baseUrl: The base URL for this application (undefined if URL construction fails)
8
- * - currentPath: The current request path
9
- *
10
- * @example
11
- * ```handlebars
12
- * // Using in Handlebars templates
13
- * {{#if baseUrl}}
14
- * <a href="{{baseUrl}}/home">Home</a>
15
- * {{/if}}
16
- * {{#if (eq currentPath '/dashboard')}}Active{{/if}}
17
- * ```
18
- *
19
- * @example
20
- * // Base URL rewriting in config/config.js
21
- * // The hook receives undefined if URL construction fails
22
- * ```js
23
- * export default {
24
- * rewrite_base_url: baseUrl => {
25
- * if (!baseUrl) return 'http://localhost:3000'; // Fallback
26
- * return `${baseUrl}/admin`;
27
- * }
28
- * };
29
- * ```
30
- */
31
- /**
32
- * Mount local variables middleware on Express application.
33
- * Sets up baseUrl and currentPath variables for use in views.
34
- * @param {express.Express} app Express application instance
35
- * @returns {Promise<void>}
36
- * @example
37
- * ```js
38
- * // This method is called automatically by express-sweet.mount()
39
- * import localVars from './middlewares/localVars';
40
- *
41
- * await localVars(app);
42
- * ```
43
- */
44
- export default function localVars(app: express.Express): Promise<void>;
@@ -1,15 +0,0 @@
1
- import express from 'express';
2
- /**
3
- * Mount authentication middleware on Express application.
4
- * Sets up Passport.js with local strategy, session management, and route protection.
5
- * @param {express.Express} app Express application instance
6
- * @returns {Promise<void>}
7
- * @example
8
- * ```js
9
- * // This method is called automatically by express-sweet.mount()
10
- * import passportAuth from './middlewares/passportAuth';
11
- *
12
- * await passportAuth(app);
13
- * ```
14
- */
15
- export default function passportAuth(app: express.Express): Promise<void>;
@@ -1,27 +0,0 @@
1
- import express from 'express';
2
- /**
3
- * HTTP middleware setup for Express application.
4
- * Configures JSON/URL-encoded parsing, cookie parsing, static files, and request logging.
5
- *
6
- * @example
7
- * ```js
8
- * // Body size configuration in config/config.js
9
- * export default {
10
- * max_body_size: '100mb' // Controls request body size limit
11
- * };
12
- * ```
13
- */
14
- /**
15
- * Mount HTTP middleware on Express application.
16
- * Sets up request parsing, cookies, static files, and logging.
17
- * @param {express.Express} app Express application instance
18
- * @returns {Promise<void>}
19
- * @example
20
- * ```js
21
- * // This method is called automatically by express-sweet.mount()
22
- * import requestParser from './middlewares/requestParser';
23
- *
24
- * await requestParser(app);
25
- * ```
26
- */
27
- export default function requestParser(app: express.Express): Promise<void>;