express-sweet 1.0.16 → 1.0.19

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 (47) hide show
  1. package/CHANGELOG.md +40 -2
  2. package/INSTALL-Redis.md +51 -0
  3. package/README.md +13 -44
  4. package/dist/build.common.js +19 -11
  5. package/dist/build.esm.js +19 -11
  6. package/docs/{styles/docs.css → docs.css} +99 -100
  7. package/docs/docs.js +41 -0
  8. package/docs/{images → img/associations}/belongs-to-many.png +0 -0
  9. package/docs/{images → img/associations}/belongs-to.png +0 -0
  10. package/docs/{images → img/associations}/has-many.png +0 -0
  11. package/docs/{images → img/associations}/has-one.png +0 -0
  12. package/docs/img/demos/login&users.jfif +0 -0
  13. package/docs/img/hero.svg +1 -0
  14. package/docs/{images → img}/logo.svg +0 -0
  15. package/docs/index.html +2552 -3144
  16. package/docs/templates/cjs/authentication.js +96 -0
  17. package/docs/templates/cjs/config.js +78 -0
  18. package/docs/templates/cjs/database.js +35 -0
  19. package/docs/templates/cjs/view.js +36 -0
  20. package/docs/templates/esm/authentication.js +96 -0
  21. package/docs/templates/esm/config.js +78 -0
  22. package/docs/templates/esm/database.js +35 -0
  23. package/docs/templates/esm/view.js +36 -0
  24. package/package.json +9 -6
  25. package/types/database/Model.d.ts +8 -8
  26. package/types/handlebars_helpers/date.d.ts +14 -0
  27. package/types/handlebars_helpers/index.d.ts +2 -1
  28. package/types/handlebars_helpers/string.d.ts +20 -0
  29. package/types/interfaces/AuthenticationOptions.d.ts +13 -0
  30. package/types/middlewares/CORS.d.ts +1 -1
  31. package/types/package.d.ts +3 -0
  32. package/types/services/AWSRekognitionClient.d.ts +2 -2
  33. package/types/services/RedisClient.d.ts +1 -1
  34. package/types/utils/Types.d.ts +8 -0
  35. package/types/utils/index.d.ts +7 -2
  36. package/types/utils/isArray.d.ts +8 -0
  37. package/types/utils/isAsyncFunction.d.ts +12 -0
  38. package/types/utils/isObject.d.ts +8 -0
  39. package/types/utils/isString.d.ts +8 -0
  40. package/docs/images/all.jpg +0 -0
  41. package/docs/images/edit-user.png +0 -0
  42. package/docs/images/home.png +0 -0
  43. package/docs/images/login.png +0 -0
  44. package/docs/images/logo-dark.svg +0 -12
  45. package/docs/images/new-user.png +0 -0
  46. package/docs/images/user-list.png +0 -0
  47. package/docs/scripts/docs.js +0 -23
@@ -0,0 +1,96 @@
1
+ const UserModel = require('../models/UserModel');
2
+
3
+ /**
4
+ * User authentication configuration interface.
5
+ */
6
+ module.exports = {
7
+ /**
8
+ * Enable user authentication, defaults to disabled (false).
9
+ * @type {boolean}
10
+ */
11
+ enabled: true,
12
+
13
+ /**
14
+ * The session store instance, defaults to a new MemoryStore(memory) instance.
15
+ * @type {'memory|redis'}
16
+ */
17
+ session_store: 'memory',
18
+
19
+ /**
20
+ * If the session is stored in "redis", this field is required and should be set to the hostname of the Redis server.
21
+ * For example, to connect to redis on localhost on port 6379, set "redis://localhost:6379".
22
+ * To connect to a different host or port, use a connection string in the format "redis[s]://[[username][:password]@][host][:port][/db-number]".
23
+ * For example, "redis://alice:foobared@awesome.redis.server:6380".
24
+ * @type {string|undefined}
25
+ */
26
+ redis_host: undefined,
27
+
28
+ /**
29
+ * Authentication user ID field name, defaults to `username`.
30
+ * @type {string}
31
+ */
32
+ username: 'email',
33
+
34
+ /**
35
+ * Authentication password field name, defaults to `password`.
36
+ * @type {string}
37
+ */
38
+ password: 'password',
39
+
40
+ /**
41
+ * URL to redirect after successful authentication, defaults to `/`.
42
+ * @type {string}
43
+ */
44
+ success_redirect: '/',
45
+
46
+ /**
47
+ * URL to redirect after log off, defaults to `/login`.
48
+ * @type {string}
49
+ */
50
+ failure_redirect: '/login',
51
+
52
+ /**
53
+ * This hook is called when authenticating a user.
54
+ * Please find the user information that owns the credentials based on the user name and password you received and return it.
55
+ * If the user who owns the credentials cannot be found, return null.
56
+ *
57
+ * Note that the user information must include an ID value that can identify the user.
58
+ *
59
+ * @type {(username: string, password: string) => Promise<{[key: string]: any}|null>}
60
+ */
61
+ authenticate_user: async (username, password) => {
62
+ return UserModel.findOne({
63
+ where: {
64
+ email: username,
65
+ password: password
66
+ },
67
+ raw: true
68
+ });
69
+ },
70
+
71
+ /**
72
+ * This hook is called when user authentication is successful.
73
+ * Please search and return the authenticated user information to be set in the session based on the user ID of the parameter.
74
+ * The returned data will be set in the req.user property and the view's session variable.
75
+ *
76
+ * @type {(id: number|string) => Promise<{[key: string]: any}>}
77
+ */
78
+ subscribe_user: async (id) => {
79
+ return UserModel.findOne({
80
+ where: {id},
81
+ raw: true
82
+ });
83
+ },
84
+
85
+ /**
86
+ * URL without authentication. If the URL described in the access URL partially matches, authentication will not be performed, defaults to none.
87
+ * @type {(string|RegExp)[]}
88
+ */
89
+ allow_unauthenticated: ['/api'],
90
+
91
+ /**
92
+ * Authenticated user session expiration, defaults to 24 hours (24 * 3600000).
93
+ * @type {number}
94
+ */
95
+ expiration: 24 * 3600000
96
+ }
@@ -0,0 +1,78 @@
1
+ const path = require('path');
2
+
3
+ /**
4
+ * Express Sweet basic configuration interface.
5
+ */
6
+ module.exports = {
7
+ /**
8
+ * Environment variable file (.env) path, defaults to none (undefined).
9
+ * @type {string}
10
+ */
11
+ env_path: '.env',
12
+
13
+ /**
14
+ * CORS permission, defaults to invalid (false).
15
+ * @type {{enabled: boolean}}
16
+ */
17
+ cors_enabled: true,
18
+
19
+ /**
20
+ * Maximum body size you can request, defaults to `100kb`.
21
+ * @type {string|number}
22
+ */
23
+ max_body_size: '100kb',
24
+
25
+ /**
26
+ * Absolute path to the router directory, defaults to `<application root directory>/routes`.
27
+ * @type {string}
28
+ */
29
+ router_dir: path.join(process.cwd(), 'routes'),
30
+
31
+ /**
32
+ * The endpoint to run when the root URL is requested, defaults to none (undefined).
33
+ * @type {string}
34
+ */
35
+ default_router: '/home',
36
+
37
+ /**
38
+ * This is a hook that rewrites the base URL.
39
+ * 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.
40
+ * The default value is the referrer's origin (eg https://example.com).
41
+ *
42
+ * @example
43
+ * rewrite_base_url: baseUrl => {
44
+ * return `${baseUrl}/admin`;
45
+ * }
46
+ *
47
+ * @type {(baseUrl: string): string}
48
+ */
49
+ rewrite_base_url: baseUrl => {
50
+ return baseUrl;
51
+ },
52
+
53
+ /**
54
+ * This is a hook for error handling.
55
+ * For example, you can use it when you want to send an external notification of the error received by this hook.
56
+ *
57
+ * @example
58
+ * error_handler: async err => {
59
+ * // Notify system administrator of error.
60
+ * return new Promise((resolve, reject) => {
61
+ * const sendmail = require('sendmail')();
62
+ * sendmail({
63
+ * from: 'no-reply@example.com',
64
+ * to: 'administrator@example.com',
65
+ * subject: 'Error occurred',
66
+ * text: err.message
67
+ * }, err => {
68
+ * err ? reject(err) : resolve();
69
+ * });
70
+ * });
71
+ * }
72
+ *
73
+ * @type {(err: any): void|Promise<void>}
74
+ */
75
+ error_handler: err => {
76
+ console.error(`An error has occurred. Error message: ${err.message}`);
77
+ }
78
+ }
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Database configuration.
3
+ */
4
+ module.exports = {
5
+ development: {
6
+ username: 'root',
7
+ password: 'password',
8
+ database: 'mydb',
9
+ host: 'localhost',
10
+ port: undefined,
11
+ dialect: 'mariadb',
12
+ timezone: '+09:00',
13
+ logging: false
14
+ },
15
+ test: {
16
+ username: 'root',
17
+ password: 'password',
18
+ database: 'mydb',
19
+ host: 'localhost',
20
+ port: undefined,
21
+ dialect: 'mariadb',
22
+ timezone: '+09:00',
23
+ logging: false
24
+ },
25
+ production: {
26
+ username: 'root',
27
+ password: 'password',
28
+ database: 'mydb',
29
+ host: 'localhost',
30
+ port: undefined,
31
+ dialect: 'mariadb',
32
+ timezone: '+09:00',
33
+ logging: false
34
+ }
35
+ }
@@ -0,0 +1,36 @@
1
+ const path = require('path');
2
+
3
+ /**
4
+ * View's configuration interface.
5
+ */
6
+ module.exports = {
7
+ /**
8
+ * Absolute path to the directory where the view files are located, defaults to `<application root directory>/views`.
9
+ * @type {string}
10
+ */
11
+ views_dir: path.join(process.cwd(), 'views'),
12
+
13
+ /**
14
+ * Path to partials templates, one or several directories, defaults to `<application root directory>/views/partials`.
15
+ * @type {string|string[]}
16
+ */
17
+ partials_dir: path.join(process.cwd(), 'views/partials'),
18
+
19
+ /**
20
+ * Path to layout templates, defaults to `<application root directory>/views/layout`.
21
+ * @type {string}
22
+ */
23
+ layouts_dir: path.join(process.cwd(), 'views/layout'),
24
+
25
+ /**
26
+ * Absolute path to default layout template. defaults to `<application root directory>/views/layout/default.hbs`.
27
+ * @type {string}
28
+ */
29
+ default_layout: path.join(process.cwd(), 'views/layout/default.hbs'),
30
+
31
+ /**
32
+ * Extension for templates & partials, defaults to `.hbs`,
33
+ * @type {string}
34
+ */
35
+ extension: '.hbs'
36
+ }
@@ -0,0 +1,96 @@
1
+ import UserModel from '../models/UserModel';
2
+
3
+ /**
4
+ * User authentication configuration interface.
5
+ */
6
+ export default {
7
+ /**
8
+ * Enable user authentication, defaults to disabled (false).
9
+ * @type {boolean}
10
+ */
11
+ enabled: true,
12
+
13
+ /**
14
+ * The session store instance, defaults to a new MemoryStore(memory) instance.
15
+ * @type {'memory|redis'}
16
+ */
17
+ session_store: 'memory',
18
+
19
+ /**
20
+ * If the session is stored in "redis", this field is required and should be set to the hostname of the Redis server.
21
+ * For example, to connect to redis on localhost on port 6379, set "redis://localhost:6379".
22
+ * To connect to a different host or port, use a connection string in the format "redis[s]://[[username][:password]@][host][:port][/db-number]".
23
+ * For example, "redis://alice:foobared@awesome.redis.server:6380".
24
+ * @type {string|undefined}
25
+ */
26
+ redis_host: undefined,
27
+
28
+ /**
29
+ * Authentication user ID field name, defaults to `username`.
30
+ * @type {string}
31
+ */
32
+ username: 'email',
33
+
34
+ /**
35
+ * Authentication password field name, defaults to `password`.
36
+ * @type {string}
37
+ */
38
+ password: 'password',
39
+
40
+ /**
41
+ * URL to redirect after successful authentication, defaults to `/`.
42
+ * @type {string}
43
+ */
44
+ success_redirect: '/',
45
+
46
+ /**
47
+ * URL to redirect after log off, defaults to `/login`.
48
+ * @type {string}
49
+ */
50
+ failure_redirect: '/login',
51
+
52
+ /**
53
+ * This hook is called when authenticating a user.
54
+ * Please find the user information that owns the credentials based on the user name and password you received and return it.
55
+ * If the user who owns the credentials cannot be found, return null.
56
+ *
57
+ * Note that the user information must include an ID value that can identify the user.
58
+ *
59
+ * @type {(username: string, password: string) => Promise<{[key: string]: any}|null>}
60
+ */
61
+ authenticate_user: async (username, password) => {
62
+ return UserModel.findOne({
63
+ where: {
64
+ email: username,
65
+ password: password
66
+ },
67
+ raw: true
68
+ });
69
+ },
70
+
71
+ /**
72
+ * This hook is called when user authentication is successful.
73
+ * Please search and return the authenticated user information to be set in the session based on the user ID of the parameter.
74
+ * The returned data will be set in the req.user property and the view's session variable.
75
+ *
76
+ * @type {(id: number|string) => Promise<{[key: string]: any}>}
77
+ */
78
+ subscribe_user: async (id) => {
79
+ return UserModel.findOne({
80
+ where: {id},
81
+ raw: true
82
+ });
83
+ },
84
+
85
+ /**
86
+ * URL without authentication. If the URL described in the access URL partially matches, authentication will not be performed, defaults to none.
87
+ * @type {(string|RegExp)[]}
88
+ */
89
+ allow_unauthenticated: ['/api'],
90
+
91
+ /**
92
+ * Authenticated user session expiration, defaults to 24 hours (24 * 3600000).
93
+ * @type {number}
94
+ */
95
+ expiration: 24 * 3600000
96
+ }
@@ -0,0 +1,78 @@
1
+ import path from 'path';
2
+
3
+ /**
4
+ * Express Sweet basic configuration interface.
5
+ */
6
+ export default {
7
+ /**
8
+ * Environment variable file (.env) path, defaults to none (undefined).
9
+ * @type {string}
10
+ */
11
+ env_path: '.env',
12
+
13
+ /**
14
+ * CORS permission, defaults to invalid (false).
15
+ * @type {{enabled: boolean}}
16
+ */
17
+ cors_enabled: true,
18
+
19
+ /**
20
+ * Maximum body size you can request, defaults to `100kb`.
21
+ * @type {string|number}
22
+ */
23
+ max_body_size: '100kb',
24
+
25
+ /**
26
+ * Absolute path to the router directory, defaults to `<application root directory>/routes`.
27
+ * @type {string}
28
+ */
29
+ router_dir: path.join(process.cwd(), 'routes'),
30
+
31
+ /**
32
+ * The endpoint to run when the root URL is requested, defaults to none (undefined).
33
+ * @type {string}
34
+ */
35
+ default_router: '/home',
36
+
37
+ /**
38
+ * This is a hook that rewrites the base URL.
39
+ * 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.
40
+ * The default value is the referrer's origin (eg https://example.com).
41
+ *
42
+ * @example
43
+ * rewrite_base_url: baseUrl => {
44
+ * return `${baseUrl}/admin`;
45
+ * }
46
+ *
47
+ * @type {(baseUrl: string): string}
48
+ */
49
+ rewrite_base_url: baseUrl => {
50
+ return baseUrl;
51
+ },
52
+
53
+ /**
54
+ * This is a hook for error handling.
55
+ * For example, you can use it when you want to send an external notification of the error received by this hook.
56
+ *
57
+ * @example
58
+ * error_handler: async err => {
59
+ * // Notify system administrator of error.
60
+ * return new Promise((resolve, reject) => {
61
+ * const sendmail = require('sendmail')();
62
+ * sendmail({
63
+ * from: 'no-reply@example.com',
64
+ * to: 'administrator@example.com',
65
+ * subject: 'Error occurred',
66
+ * text: err.message
67
+ * }, err => {
68
+ * err ? reject(err) : resolve();
69
+ * });
70
+ * });
71
+ * }
72
+ *
73
+ * @type {(err: any): void|Promise<void>}
74
+ */
75
+ error_handler: err => {
76
+ console.error(`An error has occurred. Error message: ${err.message}`);
77
+ }
78
+ }
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Database configuration.
3
+ */
4
+ export default {
5
+ development: {
6
+ username: 'root',
7
+ password: 'password',
8
+ database: 'mydb',
9
+ host: 'localhost',
10
+ port: undefined,
11
+ dialect: 'mariadb',
12
+ timezone: '+09:00',
13
+ logging: false
14
+ },
15
+ test: {
16
+ username: 'root',
17
+ password: 'password',
18
+ database: 'mydb',
19
+ host: 'localhost',
20
+ port: undefined,
21
+ dialect: 'mariadb',
22
+ timezone: '+09:00',
23
+ logging: false
24
+ },
25
+ production: {
26
+ username: 'root',
27
+ password: 'password',
28
+ database: 'mydb',
29
+ host: 'localhost',
30
+ port: undefined,
31
+ dialect: 'mariadb',
32
+ timezone: '+09:00',
33
+ logging: false
34
+ }
35
+ }
@@ -0,0 +1,36 @@
1
+ import path from 'path';
2
+
3
+ /**
4
+ * View's configuration interface.
5
+ */
6
+ export default {
7
+ /**
8
+ * Absolute path to the directory where the view files are located, defaults to `<application root directory>/views`.
9
+ * @type {string}
10
+ */
11
+ views_dir: path.join(process.cwd(), 'views'),
12
+
13
+ /**
14
+ * Path to partials templates, one or several directories, defaults to `<application root directory>/views/partials`.
15
+ * @type {string|string[]}
16
+ */
17
+ partials_dir: path.join(process.cwd(), 'views/partials'),
18
+
19
+ /**
20
+ * Path to layout templates, defaults to `<application root directory>/views/layout`.
21
+ * @type {string}
22
+ */
23
+ layouts_dir: path.join(process.cwd(), 'views/layout'),
24
+
25
+ /**
26
+ * Absolute path to default layout template. defaults to `<application root directory>/views/layout/default.hbs`.
27
+ * @type {string}
28
+ */
29
+ default_layout: path.join(process.cwd(), 'views/layout/default.hbs'),
30
+
31
+ /**
32
+ * Extension for templates & partials, defaults to `.hbs`,
33
+ * @type {string}
34
+ */
35
+ extension: '.hbs'
36
+ }
package/package.json CHANGED
@@ -1,19 +1,19 @@
1
1
  {
2
2
  "name": "express-sweet",
3
- "version": "1.0.16",
3
+ "version": "1.0.19",
4
4
  "description": "Extend Express functionality with Express Sweet and start developing fast, minimal web applications.",
5
5
  "main": "dist/build.common.js",
6
6
  "module": "dist/build.esm.js",
7
7
  "types": "types/index.d.ts",
8
8
  "files": [
9
- "LICENSE",
10
- "README.md",
11
- "CHANGELOG.md",
12
9
  "dist/",
13
10
  "docs/",
14
- "example/",
15
11
  "types/",
16
- "package.json"
12
+ "CHANGELOG.md",
13
+ "INSTALL-Redis.md",
14
+ "LICENSE",
15
+ "package.json",
16
+ "README.md"
17
17
  ],
18
18
  "scripts": {
19
19
  "watch": "node --max-old-space-size=8192 node_modules/rollup/dist/bin/rollup -c rollup.config.js --watch",
@@ -68,6 +68,7 @@
68
68
  "body-parser": "^1.19.0",
69
69
  "class-transformer": "^0.2.3",
70
70
  "class-validator": "^0.12.2",
71
+ "connect-redis": "^6.1.3",
71
72
  "cookie-parser": "~1.4.4",
72
73
  "cors": "^2.8.5",
73
74
  "debug": "~2.6.9",
@@ -90,12 +91,14 @@
90
91
  "nodejs-shared": "^1.0.2",
91
92
  "passport": "^0.4.1",
92
93
  "passport-local": "^1.0.0",
94
+ "redis": "^4.1.0",
93
95
  "reflect-metadata": "^0.1.13",
94
96
  "sequelize": "^5.22.4",
95
97
  "uniqid": "^5.2.0"
96
98
  },
97
99
  "devDependencies": {
98
100
  "@types/aws-sdk": "^2.7.0",
101
+ "@types/connect-redis": "^0.0.18",
99
102
  "@types/cookie-parser": "^1.4.2",
100
103
  "@types/debug": "^4.1.5",
101
104
  "@types/express": "^4.17.11",
@@ -189,10 +189,10 @@ export default class Model extends sequelize.Model {
189
189
  * }
190
190
  *
191
191
  * @see https://sequelize.org/master/manual/transactions.html
192
- * @param {sequelize.TransactionOptions} opts? Options provided when the transaction is created.
193
- * @return {Promise<sequelize.Transaction>} Returns a transaction object to identify the transaction being executed.
192
+ * @param {sequelize.TransactionOptions} options? Options provided when the transaction is created.
193
+ * @return {Promise<sequelize.Transaction>} Returns a transaction object to identify the transaction being executed.
194
194
  */
195
- static begin(opts?: sequelize.TransactionOptions): Promise<sequelize.Transaction>;
195
+ static begin(options?: sequelize.TransactionOptions): Promise<sequelize.Transaction>;
196
196
  /**
197
197
  * Returns data that matches the ID.
198
198
  */
@@ -212,10 +212,10 @@ export default class Model extends sequelize.Model {
212
212
  *
213
213
  * @see https://sequelize.org/master/manual/raw-queries.html
214
214
  *
215
- * @param {string} sql SQL string.
216
- * @param {object} opts Query options.
217
- * @return {Promise<any>} By default, the function will return two arguments: an array of results, and a metadata object, containing number of affected rows etc.
218
- * If you are running a type of query where you don't need the metadata, for example a SELECT query, you can pass in a query type to make sequelize format the results:
215
+ * @param {string} sql SQL string.
216
+ * @param {object} options Query options.
217
+ * @return {Promise<any>} By default, the function will return two arguments: an array of results, and a metadata object, containing number of affected rows etc.
218
+ * If you are running a type of query where you don't need the metadata, for example a SELECT query, you can pass in a query type to make sequelize format the results:
219
219
  */
220
- static query(sql: string, opts: sequelize.QueryOptionsWithType<sequelize.QueryTypes.UPDATE> | sequelize.QueryOptionsWithType<sequelize.QueryTypes.BULKUPDATE> | sequelize.QueryOptionsWithType<sequelize.QueryTypes.INSERT> | sequelize.QueryOptionsWithType<sequelize.QueryTypes.UPSERT> | sequelize.QueryOptionsWithType<sequelize.QueryTypes.DELETE> | sequelize.QueryOptionsWithType<sequelize.QueryTypes.BULKDELETE> | sequelize.QueryOptionsWithType<sequelize.QueryTypes.SHOWTABLES> | sequelize.QueryOptionsWithType<sequelize.QueryTypes.DESCRIBE> | sequelize.QueryOptionsWithType<sequelize.QueryTypes.SELECT> | sequelize.QueryOptionsWithType<sequelize.QueryTypes.SELECT> | sequelize.QueryOptionsWithType<sequelize.QueryTypes.RAW> | sequelize.QueryOptionsWithType<sequelize.QueryTypes.RAW>): Promise<any>;
220
+ static query(sql: string, options: sequelize.QueryOptionsWithType<sequelize.QueryTypes.UPDATE> | sequelize.QueryOptionsWithType<sequelize.QueryTypes.BULKUPDATE> | sequelize.QueryOptionsWithType<sequelize.QueryTypes.INSERT> | sequelize.QueryOptionsWithType<sequelize.QueryTypes.UPSERT> | sequelize.QueryOptionsWithType<sequelize.QueryTypes.DELETE> | sequelize.QueryOptionsWithType<sequelize.QueryTypes.BULKDELETE> | sequelize.QueryOptionsWithType<sequelize.QueryTypes.SHOWTABLES> | sequelize.QueryOptionsWithType<sequelize.QueryTypes.DESCRIBE> | sequelize.QueryOptionsWithType<sequelize.QueryTypes.SELECT> | sequelize.QueryOptionsWithType<sequelize.QueryTypes.SELECT> | sequelize.QueryOptionsWithType<sequelize.QueryTypes.RAW> | sequelize.QueryOptionsWithType<sequelize.QueryTypes.RAW>): Promise<any>;
221
221
  }
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Use moment to format the date.
3
+ *
4
+ * @example
5
+ * {{format_date 'YYYY/MM/DD' "2021-10-24T02:13:06.610Z"}} => 2021/10/24
6
+ * {{format_date 'YYYY/MM/DD' "2021-10-24T02:13:06.610Z" 'jp'}} => 2021/10/24
7
+ * {{format_date 'YYYY/MM/DD' "2021-10-24T02:13:06.610Z" 'es'}} => 2021/10/24
8
+ *
9
+ * @param {string} format A format string based on moment.
10
+ * @param {string} date Date string to format.
11
+ * @param {string|string[]} locale Language or language-country locale string (or array of strings) available in https://github.com/moment/moment/tree/develop/locale .
12
+ * @returns {string} Returns formatted date.
13
+ */
14
+ export declare function format_date(format: string, date: string, locale: string | string[]): string;
@@ -2,4 +2,5 @@ import * as html from './html';
2
2
  import * as object from './object';
3
3
  import * as string from './string';
4
4
  import * as comparison from './comparison';
5
- export { html, object, string, comparison };
5
+ import * as date from './date';
6
+ export { html, object, string, comparison, date };
@@ -10,3 +10,23 @@
10
10
  * @return {string} Character string after replacement.
11
11
  */
12
12
  export declare function replace(value: string, find: string, replace: string): string;
13
+ /**
14
+ * Split `string` by the given `character`.
15
+ *
16
+ * @example
17
+ * <!-- Basic usage. -->
18
+ * {{split "a,b,c" ","}} => ['a', 'b', 'c']
19
+ *
20
+ * <!-- Use with EACH. -->
21
+ * {{#each (split list ',')}}
22
+ * {{this}}<br>
23
+ * {{/each}}
24
+ * => a<br>
25
+ * b<br>
26
+ * c<br>
27
+ *
28
+ * @param {string} value String.
29
+ * @param {string} separator A character that delimits the substrings in this string. Default is a comma.
30
+ * @return {string}
31
+ */
32
+ export declare function split(value: string, separator: string): string[];
@@ -7,6 +7,19 @@ export default interface {
7
7
  * @type {boolean}
8
8
  */
9
9
  enabled: boolean;
10
+ /**
11
+ * The session store instance, defaults to a new MemoryStore(memory) instance.
12
+ * @type {'memory'|'redis'}
13
+ */
14
+ session_store: 'memory' | 'redis';
15
+ /**
16
+ * If the session is stored in "redis", this field is required and should be set to the hostname of the Redis server.
17
+ * For example, to connect to redis on localhost on port 6379, set "redis://localhost:6379".
18
+ * To connect to a different host or port, use a connection string in the format "redis[s]://[[username][:password]@][host][:port][/db-number]".
19
+ * For example, "redis://alice:foobared@awesome.redis.server:6380".
20
+ * @type {string|undefined}
21
+ */
22
+ redis_host?: string;
10
23
  /**
11
24
  * Authentication user ID field name, defaults to `username`.
12
25
  * @type {string}
@@ -6,7 +6,7 @@ export default class {
6
6
  /**
7
7
  * Mount on application.
8
8
  */
9
- static mount(app: express.Express): undefined;
9
+ static mount(app: express.Express): void;
10
10
  /**
11
11
  * Returns the option.
12
12
  *
@@ -34,6 +34,7 @@ export declare var dependencies: {
34
34
  "body-parser": string;
35
35
  "class-transformer": string;
36
36
  "class-validator": string;
37
+ "connect-redis": string;
37
38
  "cookie-parser": string;
38
39
  cors: string;
39
40
  debug: string;
@@ -56,12 +57,14 @@ export declare var dependencies: {
56
57
  "nodejs-shared": string;
57
58
  passport: string;
58
59
  "passport-local": string;
60
+ redis: string;
59
61
  "reflect-metadata": string;
60
62
  sequelize: string;
61
63
  uniqid: string;
62
64
  };
63
65
  export declare var devDependencies: {
64
66
  "@types/aws-sdk": string;
67
+ "@types/connect-redis": string;
65
68
  "@types/cookie-parser": string;
66
69
  "@types/debug": string;
67
70
  "@types/express": string;