express-sweet 2.0.2 → 2.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +76 -9
- package/LICENSE +1 -1
- package/README.md +2193 -20
- package/configuration_sample/cjs/authentication.js +103 -0
- package/configuration_sample/cjs/config.js +74 -0
- package/configuration_sample/cjs/database.js +35 -0
- package/configuration_sample/cjs/view.js +36 -0
- package/configuration_sample/esm/authentication.js +103 -0
- package/configuration_sample/esm/config.js +74 -0
- package/configuration_sample/esm/database.js +35 -0
- package/configuration_sample/esm/view.js +36 -0
- package/dist/build.cjs +22 -22
- package/dist/build.mjs +22 -22
- package/package.json +8 -11
- package/screencaps/belongs-to-many.png +0 -0
- package/screencaps/belongs-to.png +0 -0
- package/screencaps/demonstration.webp +0 -0
- package/screencaps/has-many.png +0 -0
- package/screencaps/has-one.png +0 -0
- package/types/database/Database.d.ts +3 -171
- package/types/database/Model.d.ts +22 -19
- package/types/database/loadModels.d.ts +2 -1
- package/types/handlebars_helpers/array.d.ts +20 -0
- package/types/handlebars_helpers/comparison.d.ts +59 -189
- package/types/handlebars_helpers/date.d.ts +4 -4
- package/types/handlebars_helpers/html.d.ts +3 -3
- package/types/handlebars_helpers/index.d.ts +2 -0
- package/types/handlebars_helpers/layouts.d.ts +21 -0
- package/types/handlebars_helpers/math.d.ts +14 -21
- package/types/handlebars_helpers/number.d.ts +5 -5
- package/types/handlebars_helpers/object.d.ts +4 -4
- package/types/handlebars_helpers/string.d.ts +8 -13
- package/types/interfaces/AuthenticationConfig.d.ts +4 -11
- package/types/interfaces/BasicConfig.d.ts +11 -15
- package/types/interfaces/ViewConfig.d.ts +1 -3
- package/types/middlewares/Authentication.d.ts +3 -1
- package/types/middlewares/CORS.d.ts +3 -1
- package/types/middlewares/Environment.d.ts +3 -3
- package/types/middlewares/ErrorHandler.d.ts +3 -1
- package/types/middlewares/Http.d.ts +3 -1
- package/types/middlewares/Local.d.ts +3 -1
- package/types/middlewares/View.d.ts +6 -2
- package/types/mount.d.ts +3 -2
- package/types/routing/Router.d.ts +3 -1
- package/types/services/Authentication.d.ts +4 -2
- package/types/utils/Types.d.ts +2 -2
- package/types/utils/isAsyncFunction.d.ts +7 -7
- package/types/utils/isFunction.d.ts +8 -8
- package/types/utils/loadAuthenticationConfig.d.ts +2 -2
- package/types/utils/loadBasicConfig.d.ts +2 -2
- package/types/utils/loadDatabaseConfig.d.ts +2 -2
- package/types/utils/loadViewConfig.d.ts +2 -2
- package/INSTALL-Redis.md +0 -77
- package/QUICK_START.md +0 -149
- package/screencaps/login.jpg +0 -0
- package/screencaps/personal.jpg +0 -0
- package/screencaps/user-editing.jpg +0 -0
- package/screencaps/users.jpg +0 -0
|
@@ -1,316 +1,186 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Determine whether or not two values are equal (===).
|
|
3
|
-
* @example
|
|
4
|
-
* {{!-- results in: false --}}
|
|
5
|
-
* {{eq '3' 3}}
|
|
6
|
-
*
|
|
7
|
-
* {{#if (eqw foo 'bar')}}
|
|
8
|
-
* Hello
|
|
9
|
-
* {{/if}}
|
|
10
3
|
* @param {any} value1 First value to be compared with second.
|
|
11
4
|
* @param {any} value2 Second value to be compared with first.
|
|
12
5
|
* @return {boolean} Returns true if the value and type are the same, false if they are different.
|
|
6
|
+
* @example
|
|
7
|
+
* {{eq val1 val2}}
|
|
8
|
+
* {{#if (eqw val1 val2)}}...{{/if}}
|
|
13
9
|
*/
|
|
14
10
|
export declare const eq: (value1: any, value2: any) => boolean;
|
|
15
11
|
/**
|
|
16
12
|
* Determine whether or not two values are equal (==) i.e weak checking.
|
|
17
|
-
* @example
|
|
18
|
-
* {{!-- results in: true --}}
|
|
19
|
-
* {{eqw '3' 3}}
|
|
20
|
-
*
|
|
21
|
-
* {{#if (eqw foo 'bar')}}
|
|
22
|
-
* Hello
|
|
23
|
-
* {/if}}
|
|
24
13
|
* @param {any} value1 First value to be compared with second.
|
|
25
14
|
* @param {any} value2 Second value to be compared with first.
|
|
26
15
|
* @return {boolean} Returns true if the values are the same, false if they are different.
|
|
16
|
+
* @example
|
|
17
|
+
* {{eqw val1 val2}}
|
|
18
|
+
* {{#if (eqw val1 val2)}}...{{/if}}
|
|
27
19
|
*/
|
|
28
20
|
export declare const eqw: (value1: any, value2: any) => boolean;
|
|
29
21
|
/**
|
|
30
22
|
* Determine whether or not two values are not equal (!==).
|
|
31
|
-
* @example
|
|
32
|
-
* {{!-- results in: true --}}
|
|
33
|
-
* {{neq 4 3}}
|
|
34
|
-
*
|
|
35
|
-
* {{#if (neq foo 'bar')}}
|
|
36
|
-
* Hello
|
|
37
|
-
* {{/if}}
|
|
38
23
|
* @param {any} value1 First value to be compared with second.
|
|
39
24
|
* @param {any} value2 Second value to be compared with first.
|
|
40
25
|
* @return {boolean} Returns true if the value and type are different, false if they are the same.
|
|
26
|
+
* @example
|
|
27
|
+
* {{neq val1 val2}}
|
|
28
|
+
* {{#if (neq val1 val2)}}...{{/if}}
|
|
41
29
|
*/
|
|
42
30
|
export declare const neq: (value1: any, value2: any) => boolean;
|
|
43
31
|
/**
|
|
44
32
|
* Determine whether or not two values are not equal (!=) weak checking.
|
|
45
|
-
* @example
|
|
46
|
-
* {{!-- results in: false --}}
|
|
47
|
-
* {{neqw '3' 3}}
|
|
48
|
-
*
|
|
49
|
-
* {{#if (neqw foo 'bar')}}
|
|
50
|
-
* Hello
|
|
51
|
-
* {{/if}}
|
|
52
33
|
* @param {any} value1 First value to be compared with second.
|
|
53
34
|
* @param {any} value2 Second value to be compared with first.
|
|
54
35
|
* @return {boolean} Returns true if the values are different, false if they are the same.
|
|
36
|
+
* @example
|
|
37
|
+
* {{neqw val1 val2}}
|
|
38
|
+
* {{#if (neqw val1 val2)}}...{{/if}}
|
|
55
39
|
*/
|
|
56
40
|
export declare const neqw: (value1: any, value2: any) => boolean;
|
|
57
41
|
/**
|
|
58
42
|
* Check for less than condition (a < b).
|
|
59
|
-
* @example
|
|
60
|
-
* {{!-- results in: true --}}
|
|
61
|
-
* {{lt 2 3}}
|
|
62
|
-
*
|
|
63
|
-
* {{#if (lt 2 5)}}
|
|
64
|
-
* Hello
|
|
65
|
-
* {{/if}}
|
|
66
43
|
* @param {any} value1 First value to be compared with second.
|
|
67
44
|
* @param {any} value2 Second value to be compared with first.
|
|
68
45
|
* @return {boolean} Returns true if the first value is less than the second value, false otherwise.
|
|
46
|
+
* @example
|
|
47
|
+
* {{lt val1 val2}}
|
|
48
|
+
* {{#if (lt val1 val2)}}...{{/if}}
|
|
69
49
|
*/
|
|
70
50
|
export declare const lt: (value1: any, value2: any) => boolean;
|
|
71
51
|
/**
|
|
72
52
|
* Check for less than or equals condition (a <= b).
|
|
73
|
-
* @example
|
|
74
|
-
* {{!-- results in: true --}}
|
|
75
|
-
* {{lte 2 3}}
|
|
76
|
-
*
|
|
77
|
-
* {{#if (lte 2 5)}}
|
|
78
|
-
* Hello
|
|
79
|
-
* {{/if}}
|
|
80
53
|
* @param {any} value1 First value to be compared with second.
|
|
81
54
|
* @param {any} value2 Second value to be compared with first.
|
|
82
55
|
* @return {boolean} Returns true if the first value is less than or equal to the second value, false otherwise.
|
|
56
|
+
* @example
|
|
57
|
+
* {{lte val1 val2}}
|
|
58
|
+
* {{#if (lte val1 val2)}}...{{/if}}
|
|
83
59
|
*/
|
|
84
60
|
export declare const lte: (value1: any, value2: any) => boolean;
|
|
85
61
|
/**
|
|
86
62
|
* Check for greater than condition (a > b).
|
|
87
|
-
* @example
|
|
88
|
-
* {{!-- results in: false --}}
|
|
89
|
-
* {{gt 2 3}}
|
|
90
|
-
*
|
|
91
|
-
* {{#if (gt 5 6)}}
|
|
92
|
-
* Hello
|
|
93
|
-
* {{/if}}
|
|
94
63
|
* @param {any} value1 First value to be compared with second.
|
|
95
64
|
* @param {any} value2 Second value to be compared with first.
|
|
96
65
|
* @return {boolean} Returns true if the first value exceeds the second value, false otherwise.
|
|
66
|
+
* @example
|
|
67
|
+
* {{gt val1 val2}}
|
|
68
|
+
* {{#if (gt val1 val2)}}...{{/if}}
|
|
97
69
|
*/
|
|
98
70
|
export declare const gt: (value1: any, value2: any) => boolean;
|
|
99
71
|
/**
|
|
100
72
|
* Check for greater than or equals condition (a >= b).
|
|
101
|
-
* @example
|
|
102
|
-
* {{!-- results in: true --}}
|
|
103
|
-
* {{gte 3 3}}
|
|
104
|
-
*
|
|
105
|
-
* {{#if (gte 10 2)}}
|
|
106
|
-
* Hello
|
|
107
|
-
* {{/if}}
|
|
108
73
|
* @param {any} value1 First value to be compared with second.
|
|
109
74
|
* @param {any} value2 Second value to be compared with first.
|
|
110
75
|
* @return {boolean} Returns true if the first value is greater than or equal to the second value, false otherwise.
|
|
76
|
+
* @example
|
|
77
|
+
* {{gte val1 val2}}
|
|
78
|
+
* {{#if (gte val1 val2)}}...{{/if}}
|
|
111
79
|
*/
|
|
112
80
|
export declare const gte: (value1: any, value2: any) => boolean;
|
|
113
81
|
/**
|
|
114
82
|
* Logical NOT of any expression.
|
|
115
|
-
* @example
|
|
116
|
-
* {{!-- results in: false --}}
|
|
117
|
-
* {{not true}}
|
|
118
|
-
*
|
|
119
|
-
* {{!-- results in: true --}}
|
|
120
|
-
* {{not false}}
|
|
121
|
-
*
|
|
122
|
-
* {{#if (not (eq foo 'bar'))}}
|
|
123
|
-
* Hello
|
|
124
|
-
* {{/if}}
|
|
125
83
|
* @param {any} expression Any expression.
|
|
126
84
|
* @return {boolean} Returns the logical negation of the value.
|
|
85
|
+
* @example
|
|
86
|
+
* {{not val}}
|
|
87
|
+
* {{#if (not (eq val1 val2))}}...{{/if}}
|
|
127
88
|
*/
|
|
128
89
|
export declare const not: (expression: any) => boolean;
|
|
129
90
|
/**
|
|
130
91
|
* Helper to imitate the ternary '?:' conditional operator.
|
|
131
|
-
* @example
|
|
132
|
-
* {{!-- results in: foo --}}
|
|
133
|
-
* {{ifx true 'foo' 'bar'}}
|
|
134
|
-
*
|
|
135
|
-
* {{!-- results in: bar --}}
|
|
136
|
-
* {{ifx false 'foo' 'bar'}}
|
|
137
|
-
*
|
|
138
|
-
* {{!-- results in: 6 --}}
|
|
139
|
-
* {{ifx (eq value 1) 5 6}}
|
|
140
|
-
*
|
|
141
|
-
* {{!-- results in: 6 --}}
|
|
142
|
-
* {{ifx (not (eq value 1)) 5 6}}
|
|
143
|
-
*
|
|
144
|
-
* {{!-- The third parameter is optional, and by default it will be blank string ('') --}}
|
|
145
|
-
* {{!-- results in: active --}}
|
|
146
|
-
* {{ifx true 'active'}}
|
|
147
|
-
*
|
|
148
|
-
* {{!-- results in: '' --}}
|
|
149
|
-
* {{ifx false 'active'}}
|
|
150
92
|
* @param {boolean} condition Satisfying condition for getting first value. Either true of false.
|
|
151
93
|
* @param {any} value1 First value to be displayed as result..
|
|
152
94
|
* @param {any} value2 Second value to be displayed as result. Defaults to an empty string.
|
|
153
95
|
* @return {any} Returns the result of the ternary operator.
|
|
96
|
+
* @example
|
|
97
|
+
* {{ifx true val1 val2}}
|
|
98
|
+
* {{ifx false val1 val2}}
|
|
99
|
+
* {{ifx (eq val1 val2) val3 val4}}
|
|
100
|
+
* {{ifx (not (eq val1 val2)) val3 val4}}
|
|
101
|
+
* {{ifx true val}}
|
|
102
|
+
* {{ifx false val}}
|
|
154
103
|
*/
|
|
155
104
|
export declare const ifx: (condition: boolean, value1: any, value2: any) => any;
|
|
156
105
|
/**
|
|
157
106
|
* Check if it is empty.
|
|
158
107
|
* If the value is an array, returns true if there are no elements.
|
|
159
108
|
* If the value is a string, the leading and trailing spaces are trimmed and then checked.
|
|
160
|
-
* @example
|
|
161
|
-
* {{!-- results in: false --}}
|
|
162
|
-
* {{empty [5, 6]}}
|
|
163
|
-
*
|
|
164
|
-
* {{#if (empty 'foo')}}
|
|
165
|
-
* Hello
|
|
166
|
-
* {{/if}}
|
|
167
|
-
*
|
|
168
|
-
* {{!-- results in: false --}}
|
|
169
|
-
* {{empty 'Hello'}}
|
|
170
|
-
*
|
|
171
|
-
* {{!-- results in: true --}}
|
|
172
|
-
* {{empty ''}}
|
|
173
|
-
*
|
|
174
|
-
* {{!-- results in: true --}}
|
|
175
|
-
* {{empty ' '}}
|
|
176
109
|
* @param {any} value Character strings, arrays, objects, etc. to be checked.
|
|
177
110
|
* @return {boolean} Returns true if the value is empty, false otherwise.
|
|
111
|
+
* @example
|
|
112
|
+
* {{empty val}}
|
|
113
|
+
* {{#if (empty val)}}...{{/if}}
|
|
178
114
|
*/
|
|
179
115
|
export declare const empty: (value: any) => boolean;
|
|
180
116
|
/**
|
|
181
117
|
* Check that it is not empty.
|
|
182
118
|
* If the value is an array, returns true if there is an element.
|
|
183
119
|
* If the value is a string, the leading and trailing spaces are trimmed and then checked.
|
|
184
|
-
* @example
|
|
185
|
-
* {{!-- results in: true --}}
|
|
186
|
-
* {{notEmpty [5, 6]}}
|
|
187
|
-
*
|
|
188
|
-
* {{#if (notEmpty 'foo')}}
|
|
189
|
-
* Hello
|
|
190
|
-
* {{/if}}
|
|
191
|
-
*
|
|
192
|
-
* {{!-- results in: true --}}
|
|
193
|
-
* {{notEmpty 'Hello'}}
|
|
194
|
-
*
|
|
195
|
-
* {{!-- results in: false --}}
|
|
196
|
-
* {{notEmpty ''}}
|
|
197
|
-
*
|
|
198
|
-
* {{!-- results in: false --}}
|
|
199
|
-
* {{notEmpty ' '}}
|
|
200
120
|
* @param {any} value Character strings, arrays, objects, etc. to be checked.
|
|
201
121
|
* @return {boolean} Returns true if the value is not empty, false otherwise.
|
|
122
|
+
* @example
|
|
123
|
+
* {{notEmpty val}}
|
|
124
|
+
* {{#if (notEmpty val)}}...{{/if}}
|
|
202
125
|
*/
|
|
203
126
|
export declare const notEmpty: (value: any) => boolean;
|
|
204
127
|
/**
|
|
205
128
|
* Determine the length of an array.
|
|
206
|
-
*
|
|
207
|
-
* @example
|
|
208
|
-
* {{!-- results in: 2 --}}
|
|
209
|
-
* {{count [5, 6]}}
|
|
210
129
|
* @param {any[]} items Array whose elements to be counted.
|
|
211
130
|
* @return {number|false} Returns the length of the array if the value is an array, false if the value is not an array.
|
|
131
|
+
* @example
|
|
132
|
+
* {{count val}}
|
|
212
133
|
*/
|
|
213
134
|
export declare const count: (items: any[]) => number | false;
|
|
214
135
|
/**
|
|
215
136
|
* Returns the boolean AND of two or more parameters passed i.e it is true iff all the parameters are true.
|
|
216
|
-
* @example
|
|
217
|
-
* {{!-- results in: true --}}
|
|
218
|
-
* {{and true true}}
|
|
219
|
-
*
|
|
220
|
-
* {{!-- results in: false --}}
|
|
221
|
-
* {{and false true}}
|
|
222
|
-
*
|
|
223
|
-
* {{#if (and value1 value2)}}
|
|
224
|
-
* {{!-- do something --}}
|
|
225
|
-
* {{else}}
|
|
226
|
-
* {{!-- do something else --}}
|
|
227
|
-
* {{/if}}
|
|
228
137
|
* @param {...any} params Any number of boolean parameters.
|
|
229
138
|
* @return {boolean} Returns the result of the logical product.
|
|
139
|
+
* @example
|
|
140
|
+
* {{and val1 val2}}
|
|
141
|
+
* {{#if (and val1 val2)}}...{{/if}}
|
|
230
142
|
*/
|
|
231
143
|
export declare const and: (...params: any[]) => boolean;
|
|
232
144
|
/**
|
|
233
145
|
* Returns the boolean OR of two or more parameters passed i.e it is true if any of the parameters is true.
|
|
234
|
-
* @example
|
|
235
|
-
* {{!-- results in: true --}}
|
|
236
|
-
* {{or true false}}
|
|
237
|
-
*
|
|
238
|
-
* {{!-- results in: false --}}
|
|
239
|
-
* {{or false false}}
|
|
240
|
-
*
|
|
241
|
-
* {{#if (or value1 value2)}}
|
|
242
|
-
* {{!-- do something --}}
|
|
243
|
-
* {{else}}
|
|
244
|
-
* {{!-- do something else --}}
|
|
245
|
-
* {{/if}}
|
|
246
146
|
* @param {...any} params Any number of boolean parameters.
|
|
247
147
|
* @return {boolean} Returns the result of the OR.
|
|
148
|
+
* @example
|
|
149
|
+
* {{or val1 val2}}
|
|
150
|
+
* {{#if (or val1 val2)}}...{{/if}}
|
|
248
151
|
*/
|
|
249
152
|
export declare const or: (...params: any[]) => boolean;
|
|
250
153
|
/**
|
|
251
154
|
* Returns the first non-falsy value from the parameter list.
|
|
252
155
|
* Works quite similar to the SQL's "COALESCE()" function, but unlike this checks for the first non-false parameter.
|
|
253
|
-
* @example
|
|
254
|
-
* {{!-- results in: foo bar --}}
|
|
255
|
-
* {{coalesce 'foo bar' 'foob' 'unknown'}}
|
|
256
|
-
*
|
|
257
|
-
* {{!-- results in: foob --}}
|
|
258
|
-
* {{coalesce '' 'foob' 'unknown'}}
|
|
259
156
|
* @param {...any} params Any number of parameters.
|
|
260
157
|
* @return {any} Returns the first non-false element of the parameter.
|
|
158
|
+
* @example
|
|
159
|
+
* {{coalesce val1 val2}}
|
|
261
160
|
*/
|
|
262
161
|
export declare const coalesce: (...params: any[]) => any;
|
|
263
162
|
/**
|
|
264
163
|
* Returns boolean if the array contains the element strictly or non-strictly.
|
|
265
|
-
* @example
|
|
266
|
-
* {{!-- results in: true --}}
|
|
267
|
-
* {{includes [1, 2, 3] 2}}
|
|
268
|
-
*
|
|
269
|
-
* {{!-- results in: false --}}
|
|
270
|
-
* {{includes [1, 2, 3] '2'}}
|
|
271
|
-
*
|
|
272
|
-
* {{!-- results in: false --}}
|
|
273
|
-
* {{includes [1, 2, 3] '2' true}}
|
|
274
|
-
*
|
|
275
|
-
* {{!-- results in: true --}}
|
|
276
|
-
* {{includes [1, 2, 3] '2' false}}
|
|
277
|
-
*
|
|
278
|
-
* {{#if (includes [1, 2, 3] '2')}}
|
|
279
|
-
* {{!-- Do something --}}
|
|
280
|
-
* {{/if}}
|
|
281
|
-
*
|
|
282
|
-
* {{ifx (includes [1, 2, 3] '2') 'yes' 'no'}}
|
|
283
164
|
* @param {any[]} items The array.
|
|
284
165
|
* @param {any} value The value to be checked for existence in the array.
|
|
285
166
|
* @param {boolean} strict FALSE for non-strict checking. TRUE by default.
|
|
286
167
|
* @return {boolean} Returns true if the array contains the specified value, false otherwise.
|
|
168
|
+
* @example
|
|
169
|
+
* {{includes [1, 2, 3] 2}}
|
|
170
|
+
* {{includes [1, 2, 3] 2 true}}
|
|
171
|
+
* {{#if (includes [1, 2, 3] 2)}}...{{/if}}
|
|
172
|
+
* {{ifx (includes [1, 2, 3] 2) true false}}
|
|
287
173
|
*/
|
|
288
174
|
export declare const includes: (items: any[], value: any, strict?: boolean) => boolean;
|
|
289
175
|
/**
|
|
290
176
|
* Returns true if the given str matches the given regex.
|
|
291
|
-
* @example
|
|
292
|
-
* {{!-- results in: true --}}
|
|
293
|
-
* {{regexMatch 'foobar' 'foo'}}
|
|
294
|
-
*
|
|
295
|
-
* {{!-- results in: false --}}
|
|
296
|
-
* {{regexMatch 'bar' 'foo'}}
|
|
297
|
-
*
|
|
298
|
-
* {{!-- results in: false --}}
|
|
299
|
-
* {{regexMatch 'foobar' '^foo$'}}
|
|
300
|
-
*
|
|
301
|
-
* {{!-- results in: true --}}
|
|
302
|
-
* {{regexMatch 'Visit Here' 'here' 'i'}}
|
|
303
|
-
*
|
|
304
|
-
* {{!-- results in: false --}}
|
|
305
|
-
* {{regexMatch 'Visit Here' 'here'}}
|
|
306
|
-
*
|
|
307
|
-
* {{!-- results in: Match --}}
|
|
308
|
-
* {{#if (regexMatch 'foobar' 'foo')}}
|
|
309
|
-
* Match
|
|
310
|
-
* {{/if}}
|
|
311
177
|
* @param {string} val The string against which to match the regular expression.
|
|
312
178
|
* @param {string} pattern The text of the regular expression.
|
|
313
179
|
* @param {string} flags? Regular expression flags, such as global and case-insensitive searches. The default is none (undefined).
|
|
314
180
|
* @return {boolean} true if there is a match between the regular expression and the string str. Otherwise, false.
|
|
181
|
+
* @example
|
|
182
|
+
* {{regexMatch 'Hello, world!' 'Hello'}}
|
|
183
|
+
* {{regexMatch 'Hello, world!' 'Hello' 'i'}}
|
|
184
|
+
* {{#if (regexMatch 'Hello, world!' 'Hello')}}...{{/if}}
|
|
315
185
|
*/
|
|
316
186
|
export declare const regexMatch: (val: string, pattern: string, flags?: string) => boolean;
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
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
|
+
* @return {string} Returns formatted date.
|
|
3
7
|
* @example
|
|
4
8
|
* {{!-- results in: 2021/10/24 --}}
|
|
5
9
|
* {{formatDate 'YYYY/MM/DD' "2021-10-24T02:13:06.610Z"}}
|
|
@@ -9,9 +13,5 @@
|
|
|
9
13
|
*
|
|
10
14
|
* {{!-- results in: 2021/10/24 --}}
|
|
11
15
|
* {{formatDate 'YYYY/MM/DD' "2021-10-24T02:13:06.610Z" 'es'}}
|
|
12
|
-
* @param {string} format A format string based on moment.
|
|
13
|
-
* @param {string} date Date string to format.
|
|
14
|
-
* @param {string|string[]} locale Language or language-country locale string (or array of strings) available in https://github.com/moment/moment/tree/develop/locale .
|
|
15
|
-
* @return {string} Returns formatted date.
|
|
16
16
|
*/
|
|
17
17
|
export declare const formatDate: (format: string, date: string, locale: string | string[]) => string;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Returns the Assets path containing the file update time parameter.
|
|
3
|
-
* @example
|
|
4
|
-
* {{!-- results in: example.com/assets/style.css?1620526340463 --}}
|
|
5
|
-
* {{cacheBusting '/assets/style.css' '//example.com'}}
|
|
6
3
|
* @param {string} filePath Paths of Assets files such as CSS and JS in public directories.
|
|
7
4
|
* @param {string} baseUrl Application Origin URL. The default is none (undefined).
|
|
8
5
|
* @return {string} Returns the Assets file path with the update date and time parameters.
|
|
6
|
+
* @example
|
|
7
|
+
* {{!-- results in: example.com/assets/style.css?1620526340463 --}}
|
|
8
|
+
* {{cacheBusting '/assets/style.css' '//example.com'}}
|
|
9
9
|
*/
|
|
10
10
|
export declare const cacheBusting: (filePath: string, baseUrl?: string) => string;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export * as array from '~/handlebars_helpers/array';
|
|
1
2
|
export * as html from '~/handlebars_helpers/html';
|
|
2
3
|
export * as object from '~/handlebars_helpers/object';
|
|
3
4
|
export * as string from '~/handlebars_helpers/string';
|
|
@@ -5,3 +6,4 @@ export * as comparison from '~/handlebars_helpers/comparison';
|
|
|
5
6
|
export * as date from '~/handlebars_helpers/date';
|
|
6
7
|
export * as number from '~/handlebars_helpers/number';
|
|
7
8
|
export * as math from '~/handlebars_helpers/math';
|
|
9
|
+
export * as layouts from '~/handlebars_helpers/layouts';
|
|
@@ -0,0 +1,21 @@
|
|
|
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
|
+
* @return {string} String.
|
|
7
|
+
* @example
|
|
8
|
+
* {{{block "pageScripts"}}}
|
|
9
|
+
*/
|
|
10
|
+
export declare const block: (this: any, name: string, options: Handlebars.HelperOptions) => any;
|
|
11
|
+
/**
|
|
12
|
+
* Define block content within a page.
|
|
13
|
+
* Imported from {@link https://github.com/TryGhost/express-hbs|express-hbs}
|
|
14
|
+
* @param {string} name Block Name.
|
|
15
|
+
* @param {Handlebars.HelperOptions} options Helper Options.
|
|
16
|
+
* @example
|
|
17
|
+
* {{#contentFor "pageScripts"}}
|
|
18
|
+
* CONTENT HERE
|
|
19
|
+
* {{/contentFor}}
|
|
20
|
+
*/
|
|
21
|
+
export declare const contentFor: (this: any, name: string, options: any) => void;
|
|
@@ -1,67 +1,60 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Calculates the sum of two numbers.
|
|
3
|
-
* @example
|
|
4
|
-
* {{!-- results in: 3 --}}
|
|
5
|
-
* {{add 1 2}}
|
|
6
3
|
* @param {number|string} val1 The first number.
|
|
7
4
|
* @param {number|string} val2 The second number.
|
|
8
5
|
* @return {number}
|
|
6
|
+
* @example
|
|
7
|
+
* {{add 1 2}}
|
|
9
8
|
*/
|
|
10
9
|
export declare const add: (val1: number | string, val2: number | string) => number;
|
|
11
10
|
/**
|
|
12
11
|
* Calculates the difference of the given values.
|
|
13
|
-
* @example
|
|
14
|
-
* {{!-- results in: 3 --}}
|
|
15
|
-
* {{sub 5 2}}
|
|
16
12
|
* @param {number|string} val1 The first number.
|
|
17
13
|
* @param {number|string} val2 The second number.
|
|
18
14
|
* @return {number}
|
|
15
|
+
* @example
|
|
16
|
+
* {{sub 5 2}}
|
|
19
17
|
*/
|
|
20
18
|
export declare const sub: (val1: number | string, val2: number | string) => number;
|
|
21
19
|
/**
|
|
22
20
|
* Calculate the multiplication of the given values.
|
|
23
|
-
* @example
|
|
24
|
-
* {{!-- results in: 10 --}}
|
|
25
|
-
* {{multiply 5 2}}
|
|
26
21
|
* @param {number|string} val1 The first number.
|
|
27
22
|
* @param {number|string} val2 The second number.
|
|
28
23
|
* @return {number}
|
|
24
|
+
* @example
|
|
25
|
+
* {{multiply 5 2}}
|
|
29
26
|
*/
|
|
30
27
|
export declare const multiply: (val1: number | string, val2: number | string) => number;
|
|
31
28
|
/**
|
|
32
29
|
* Compute the division of the given values.
|
|
33
|
-
* @example
|
|
34
|
-
* {{!-- results in: 5 --}}
|
|
35
|
-
* {{divide 10 2}}
|
|
36
30
|
* @param {number|string} val1 The first number.
|
|
37
31
|
* @param {number|string} val2 The second number.
|
|
38
32
|
* @return {number}
|
|
33
|
+
* @example
|
|
34
|
+
* {{divide 10 2}}
|
|
39
35
|
*/
|
|
40
36
|
export declare const divide: (val1: number | string, val2: number | string) => number;
|
|
41
37
|
/**
|
|
42
38
|
* Round up the value.
|
|
43
|
-
* @example
|
|
44
|
-
* {{!-- results in: 6 --}}
|
|
45
|
-
* {{ceil 5.6}}
|
|
46
39
|
* @param {number|string} val Number to be rounded to nearest greater integer.
|
|
47
40
|
* @return {number}
|
|
41
|
+
* @example
|
|
42
|
+
* {{ceil 5.6}}
|
|
48
43
|
*/
|
|
49
44
|
export declare const ceil: (val: number | string) => number;
|
|
50
45
|
/**
|
|
51
46
|
* Rounds down a number.
|
|
52
|
-
* @example
|
|
53
|
-
* {{!-- results in: 5 --}}
|
|
54
|
-
* {{floor 5.6}}
|
|
55
47
|
* @param {number|string} val Number to be rounded to nearest lower integer.
|
|
56
48
|
* @return {number}
|
|
49
|
+
* @example
|
|
50
|
+
* {{floor 5.6}}
|
|
57
51
|
*/
|
|
58
52
|
export declare const floor: (val: number | string) => number;
|
|
59
53
|
/**
|
|
60
54
|
* Returns an absolute value.
|
|
61
|
-
* @example
|
|
62
|
-
* {{!-- results in: 5.6 --}}
|
|
63
|
-
* {{abs -5.6}}
|
|
64
55
|
* @param {number} val Number to perform absolute value operation on.
|
|
65
56
|
* @return {number}
|
|
57
|
+
* @example
|
|
58
|
+
* {{abs -5.6}}
|
|
66
59
|
*/
|
|
67
60
|
export declare const abs: (val: number | string) => number;
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
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
|
+
* @return {string} A string with a language-sensitive representation of the given number.
|
|
3
8
|
* @example
|
|
4
9
|
* {{!-- results in: 123,456.789 --}}
|
|
5
10
|
* {{number2locale 123456.789}}
|
|
@@ -7,10 +12,5 @@
|
|
|
7
12
|
* {{!-- German uses comma as decimal separator and period for thousands. --}}
|
|
8
13
|
* {{!-- results in: 123.456,789 --}}
|
|
9
14
|
* {{number2locale 123456.789 'de-DE'}}
|
|
10
|
-
* @param {number|string} val Target number or numeric string.
|
|
11
|
-
* @param {string|undefined} locales A string with a BCP 47 language tag, or an array of such strings.
|
|
12
|
-
* 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.
|
|
13
|
-
* In implementations without Intl.NumberFormat support, this parameter is ignored and the host's locale is usually used.
|
|
14
|
-
* @return {string} A string with a language-sensitive representation of the given number.
|
|
15
15
|
*/
|
|
16
16
|
export declare const number2locale: (val: number | string, locales?: string) => string;
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Stringify an object using JSON.stringify.
|
|
3
|
-
* @example
|
|
4
|
-
* {{jsonStringify value}}
|
|
5
3
|
* @param {any} value The value to convert to a JSON string.
|
|
6
4
|
* @param {number} indent The number of space characters to use as whitespace.
|
|
7
5
|
* @return {string} A JSON string representing the given value, or undefined.
|
|
6
|
+
* @example
|
|
7
|
+
* {{jsonStringify val}}
|
|
8
8
|
*/
|
|
9
9
|
export declare const jsonStringify: (value: any, indent?: number | string) => string | undefined;
|
|
10
10
|
/**
|
|
11
11
|
* Parses the given string using JSON.parse.
|
|
12
|
-
* @example
|
|
13
|
-
* {{jsonParse value}}
|
|
14
12
|
* @param {any} value Object to stringify.
|
|
15
13
|
* @return {any} JavaScript value or object described by a string.
|
|
14
|
+
* @example
|
|
15
|
+
* {{jsonParse val}}
|
|
16
16
|
*/
|
|
17
17
|
export declare const jsonParse: (value: any) => any;
|
|
@@ -1,30 +1,28 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Returns a new string with some or all matches of a pattern replaced by a replacement.
|
|
3
|
-
* @example
|
|
4
|
-
* {{replace 'The quick brown fox jumps over the lazy dog. If the dog reacted, was it really lazy?' 'dog' 'monkey'}}
|
|
5
3
|
* @param {string} value String.
|
|
6
4
|
* @param {string} find The string to be replaced.
|
|
7
5
|
* @param {string} replace The string to replace.
|
|
8
6
|
* @return {string} Character string after replacement.
|
|
7
|
+
* @example
|
|
8
|
+
* {{replace 'The quick brown fox jumps over the lazy dog. If the dog reacted, was it really lazy?' 'dog' 'monkey'}}
|
|
9
9
|
*/
|
|
10
10
|
export declare const replace: (value: string, find: string, replace: string) => string;
|
|
11
11
|
/**
|
|
12
12
|
* Split `string` by the given `character`.
|
|
13
|
-
* @example
|
|
14
|
-
* {{!-- results in: ['a', 'b', 'c'] --}}
|
|
15
|
-
* {{split "a,b,c" ","}}
|
|
16
|
-
*
|
|
17
|
-
* {{!-- results in: <div>a</div><div>b</div><div>c</div> --}}
|
|
18
|
-
* {{#each (split list ',')}}
|
|
19
|
-
* <div>{{this}}</div>
|
|
20
|
-
* {{/each}}
|
|
21
13
|
* @param {string} value String.
|
|
22
14
|
* @param {string} separator A character that delimits the substrings in this string. Default is a comma.
|
|
23
15
|
* @return {string[]} An Array of strings, split at each point where the separator occurs in the given string. The default is a comma.
|
|
16
|
+
* @example
|
|
17
|
+
* {{split "a,b,c" ","}}
|
|
18
|
+
* {{#each (split list ',')}}<div>{{this}}</div>{{/each}}
|
|
24
19
|
*/
|
|
25
20
|
export declare const split: (value: string, separator: string) => string[];
|
|
26
21
|
/**
|
|
27
22
|
* Convert bytes to just the right units(KB, MB, GB, TB, PB, EB, ZB, YB).
|
|
23
|
+
* @param {number} bytes Bytes.
|
|
24
|
+
* @param {number} decimals Number of decimal places to display. Default is 0.
|
|
25
|
+
* @return {string} Returns a value with units.
|
|
28
26
|
* @example
|
|
29
27
|
* {{!-- results in: 1 KB --}}
|
|
30
28
|
* {{formatBytes 1024}}
|
|
@@ -37,8 +35,5 @@ export declare const split: (value: string, separator: string) => string[];
|
|
|
37
35
|
*
|
|
38
36
|
* {{!-- results in: 0 Bytes --}}
|
|
39
37
|
* {{formatBytes 0}}
|
|
40
|
-
* @param {number} bytes Bytes.
|
|
41
|
-
* @param {number} decimals Number of decimal places to display. Default is 0.
|
|
42
|
-
* @return {string} Returns a value with units.
|
|
43
38
|
*/
|
|
44
39
|
export declare const formatBytes: (bytes: number, decimals?: number) => string;
|
|
@@ -56,7 +56,7 @@ export default interface AuthenticationConfig {
|
|
|
56
56
|
success_redirect: string;
|
|
57
57
|
/**
|
|
58
58
|
* URL to redirect after log off, defaults to `/login`.
|
|
59
|
-
*
|
|
59
|
+
* @type {string|((req: express.Request, res: express.Response) => string)}
|
|
60
60
|
* @example
|
|
61
61
|
* // Set the URL to redirect to in case of login failure as a string.
|
|
62
62
|
* failure_redirect: '/login',
|
|
@@ -66,17 +66,14 @@ export default interface AuthenticationConfig {
|
|
|
66
66
|
* // If the role stored in the cookie is admin, redirect to the admin login screen.
|
|
67
67
|
* return req.cookies.role === 'admin' ? '/adminlogin' : 'login';
|
|
68
68
|
* },
|
|
69
|
-
|
|
70
|
-
* @type {string|((req: express.Request, res: express.Response) => string)}
|
|
71
|
-
*/
|
|
69
|
+
*/
|
|
72
70
|
failure_redirect: string | ((req: express.Request, res: express.Response) => string);
|
|
73
71
|
/**
|
|
74
72
|
* This hook is called when authenticating a user.
|
|
75
73
|
* Please find the user information that owns the credentials based on the user name and password you received and return it.
|
|
76
74
|
* If the user who owns the credentials cannot be found, return null.
|
|
77
|
-
*
|
|
78
75
|
* Note that the user information must include an ID value that can identify the user.
|
|
79
|
-
*
|
|
76
|
+
* @type {(username: string, password: string, req: express.Request) => Promise<{[key: string]: any}|null>}
|
|
80
77
|
* @example
|
|
81
78
|
* authenticate_user: async (username, password, req) => {
|
|
82
79
|
* const UserModel = require('../models/UserModel');
|
|
@@ -88,8 +85,6 @@ export default interface AuthenticationConfig {
|
|
|
88
85
|
* raw: true
|
|
89
86
|
* });
|
|
90
87
|
* }
|
|
91
|
-
*
|
|
92
|
-
* @type {(username: string, password: string, req: express.Request) => Promise<{[key: string]: any}|null>}
|
|
93
88
|
*/
|
|
94
89
|
authenticate_user: (username: string, password: string, req: express.Request) => Promise<{
|
|
95
90
|
[key: string]: any;
|
|
@@ -98,7 +93,7 @@ export default interface AuthenticationConfig {
|
|
|
98
93
|
* This hook is called when user authentication is successful.
|
|
99
94
|
* Please search and return the authenticated user information to be set in the session based on the user ID of the parameter.
|
|
100
95
|
* The returned data will be set in the req.user property and the view's session variable.
|
|
101
|
-
*
|
|
96
|
+
* @type {(id: number|string) => Promise<{[key: string]: any}>}
|
|
102
97
|
* @example
|
|
103
98
|
* subscribe_user: async (id) => {
|
|
104
99
|
* const UserModel = require('../models/UserModel');
|
|
@@ -107,8 +102,6 @@ export default interface AuthenticationConfig {
|
|
|
107
102
|
* raw: true
|
|
108
103
|
* });
|
|
109
104
|
* }
|
|
110
|
-
*
|
|
111
|
-
* @type {(id: number|string) => Promise<{[key: string]: any}>}
|
|
112
105
|
*/
|
|
113
106
|
subscribe_user: (id: number | string) => Promise<{
|
|
114
107
|
[key: string]: any;
|