express-sweet 2.0.3 → 2.0.5

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.
@@ -56,6 +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
+ * @type {string|((req: express.Request, res: express.Response) => string)}
59
60
  * @example
60
61
  * // Set the URL to redirect to in case of login failure as a string.
61
62
  * failure_redirect: '/login',
@@ -65,15 +66,14 @@ export default interface AuthenticationConfig {
65
66
  * // If the role stored in the cookie is admin, redirect to the admin login screen.
66
67
  * return req.cookies.role === 'admin' ? '/adminlogin' : 'login';
67
68
  * },
68
- *
69
- * @type {string|((req: express.Request, res: express.Response) => string)}
70
- */
69
+ */
71
70
  failure_redirect: string | ((req: express.Request, res: express.Response) => string);
72
71
  /**
73
72
  * This hook is called when authenticating a user.
74
73
  * Please find the user information that owns the credentials based on the user name and password you received and return it.
75
74
  * If the user who owns the credentials cannot be found, return null.
76
75
  * Note that the user information must include an ID value that can identify the user.
76
+ * @type {(username: string, password: string, req: express.Request) => Promise<{[key: string]: any}|null>}
77
77
  * @example
78
78
  * authenticate_user: async (username, password, req) => {
79
79
  * const UserModel = require('../models/UserModel');
@@ -85,8 +85,6 @@ export default interface AuthenticationConfig {
85
85
  * raw: true
86
86
  * });
87
87
  * }
88
- *
89
- * @type {(username: string, password: string, req: express.Request) => Promise<{[key: string]: any}|null>}
90
88
  */
91
89
  authenticate_user: (username: string, password: string, req: express.Request) => Promise<{
92
90
  [key: string]: any;
@@ -95,6 +93,7 @@ export default interface AuthenticationConfig {
95
93
  * This hook is called when user authentication is successful.
96
94
  * Please search and return the authenticated user information to be set in the session based on the user ID of the parameter.
97
95
  * The returned data will be set in the req.user property and the view's session variable.
96
+ * @type {(id: number|string) => Promise<{[key: string]: any}>}
98
97
  * @example
99
98
  * subscribe_user: async (id) => {
100
99
  * const UserModel = require('../models/UserModel');
@@ -103,8 +102,6 @@ export default interface AuthenticationConfig {
103
102
  * raw: true
104
103
  * });
105
104
  * }
106
- *
107
- * @type {(id: number|string) => Promise<{[key: string]: any}>}
108
105
  */
109
106
  subscribe_user: (id: number | string) => Promise<{
110
107
  [key: string]: any;
@@ -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(err.status||500).end();</code>)
59
- * @type {(err: any, req: express.Request, res: express.Response, next: express.NextFunction) => void}
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: (err, req, res, next) => {
62
- * if (err.status === 404)
63
- * // If the URL cannot be found, a 404 error screen (views/error-404.hbs) is displayed.
64
- * res.render('error-404');
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-unknown.hbs) is displayed.
67
- * res.render('error-unknown');
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?: (err: any, req: express.Request, res: express.Response, next: express.NextFunction) => void;
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
  }
@@ -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
- * Returns true for asynchronous functions, false otherwise.
3
- * @example
4
- * utils.isAsyncFunction(async () => {});// true
5
- * utils.isAsyncFunction(() => {});// false
6
- * @param {any} value.
7
- * @return {boolean}
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
- * Returns true for functions, false otherwise.
3
- * @example
4
- * utils.isFunction(() => {});// true
5
- * utils.isFunction(async () => {});// true
6
- * utils.isFunction('');// false
7
- * @param {any} value.
8
- * @return {boolean}
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;