express-sweet 2.0.3 → 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 +26 -3
- package/LICENSE +1 -1
- package/README.md +137 -53
- package/configuration_sample/cjs/config.js +8 -10
- package/configuration_sample/esm/config.js +8 -10
- package/dist/build.cjs +2 -2
- package/dist/build.mjs +2 -2
- package/package.json +2 -2
- package/types/database/Model.d.ts +13 -13
- package/types/handlebars_helpers/array.d.ts +20 -0
- package/types/handlebars_helpers/comparison.d.ts +50 -50
- 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 +1 -0
- package/types/handlebars_helpers/layouts.d.ts +4 -4
- package/types/handlebars_helpers/math.d.ts +14 -14
- 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 -8
- package/types/interfaces/AuthenticationConfig.d.ts +4 -7
- package/types/interfaces/BasicConfig.d.ts +10 -11
- package/types/interfaces/ViewConfig.d.ts +1 -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
|
@@ -32,12 +32,11 @@ export default interface BasicConfig {
|
|
|
32
32
|
* This is a hook that rewrites the base URL.
|
|
33
33
|
* If you want to rewrite the app.locals.baseUrl property and the view's baseUrl variable, use this hook to return a new base URL.
|
|
34
34
|
* The default value is the referrer's origin (eg https://example.com).
|
|
35
|
+
* @type {(baseUrl: string): string}
|
|
35
36
|
* @example
|
|
36
37
|
* rewrite_base_url: baseUrl => {
|
|
37
38
|
* return `${baseUrl}/admin`;
|
|
38
39
|
* }
|
|
39
|
-
*
|
|
40
|
-
* @type {(baseUrl: string): string}
|
|
41
40
|
*/
|
|
42
41
|
rewrite_base_url?: (baseUrl: string) => string;
|
|
43
42
|
/**
|
|
@@ -55,17 +54,17 @@ export default interface BasicConfig {
|
|
|
55
54
|
is_ajax: (req: express.Request) => boolean;
|
|
56
55
|
/**
|
|
57
56
|
* Hooks the default behavior on request errors.
|
|
58
|
-
* If unset, simply returns an error HTTP status. (<code>res.status(
|
|
59
|
-
* @type {(
|
|
57
|
+
* If unset, simply returns an error HTTP status. (<code>res.status(error.status||500).end();</code>)
|
|
58
|
+
* @type {(error: any, req: express.Request, res: express.Response, next: express.NextFunction) => void}
|
|
60
59
|
* @example
|
|
61
|
-
* hook_handle_error: (
|
|
62
|
-
* if (
|
|
63
|
-
* // If the URL cannot be found, a 404 error screen (views/
|
|
64
|
-
* res.render('
|
|
60
|
+
* hook_handle_error: (error, req, res, next) => {
|
|
61
|
+
* if (error.status === 404)
|
|
62
|
+
* // If the URL cannot be found, a 404 error screen (views/errors/404.hbs) is displayed.
|
|
63
|
+
* res.render('errors/404');
|
|
65
64
|
* else
|
|
66
|
-
* // For other errors, unknown error screen (views/error
|
|
67
|
-
* res.render('error
|
|
65
|
+
* // For other errors, unknown error screen (views/error/500.hbs) is displayed.
|
|
66
|
+
* res.render('error/500');
|
|
68
67
|
* },
|
|
69
68
|
*/
|
|
70
|
-
hook_handle_error?: (
|
|
69
|
+
hook_handle_error?: (error: any, req: express.Request, res: express.Response, next: express.NextFunction) => void;
|
|
71
70
|
}
|
|
@@ -31,13 +31,12 @@ export default interface SesOptions {
|
|
|
31
31
|
/**
|
|
32
32
|
* Hook function just before the view is rendered.
|
|
33
33
|
* For example, you can set your own local variables that can be used within the view.
|
|
34
|
+
* @type {(res: express.Response) => Promise<void>|void}
|
|
34
35
|
* @example
|
|
35
36
|
* // The message set here can be referenced in the view as {{message}}.
|
|
36
37
|
* beforeRender: (req, res) => {
|
|
37
38
|
* res.locals.extra = 'Extra';
|
|
38
39
|
* }
|
|
39
|
-
*
|
|
40
|
-
* @type {(res: express.Response) => Promise<void>|void}
|
|
41
40
|
*/
|
|
42
41
|
beforeRender?: (req: express.Request, res: express.Response) => Promise<void> | void;
|
|
43
42
|
}
|
package/types/utils/Types.d.ts
CHANGED
|
@@ -4,11 +4,11 @@
|
|
|
4
4
|
export default class {
|
|
5
5
|
/**
|
|
6
6
|
* Returns true for asynchronous functions, false otherwise.
|
|
7
|
+
* @param {Function} value.
|
|
8
|
+
* @return {boolean}
|
|
7
9
|
* @example
|
|
8
10
|
* Types.isAsyncFunction(async () => {});// true
|
|
9
11
|
* Types.isAsyncFunction(() => {});// false
|
|
10
|
-
* @param {Function} value.
|
|
11
|
-
* @return {boolean}
|
|
12
12
|
*/
|
|
13
13
|
static isAsyncFunction(value: Function): boolean;
|
|
14
14
|
/**
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
* Returns true for asynchronous functions, false otherwise.
|
|
3
|
+
* @param {any} value.
|
|
4
|
+
* @return {boolean}
|
|
5
|
+
* @example
|
|
6
|
+
* utils.isAsyncFunction(async () => {});// true
|
|
7
|
+
* utils.isAsyncFunction(() => {});// false
|
|
8
|
+
*/
|
|
9
9
|
declare const _default: (value: any) => boolean;
|
|
10
10
|
export default _default;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
2
|
+
* Returns true for functions, false otherwise.
|
|
3
|
+
* @param {any} value.
|
|
4
|
+
* @return {boolean}
|
|
5
|
+
* @example
|
|
6
|
+
* utils.isFunction(() => {});// true
|
|
7
|
+
* utils.isFunction(async () => {});// true
|
|
8
|
+
* utils.isFunction('');// false
|
|
9
|
+
*/
|
|
10
10
|
declare const _default: (value: any) => boolean;
|
|
11
11
|
export default _default;
|