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
|
@@ -0,0 +1,103 @@
|
|
|
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
|
+
* The name of the session ID cookie to set in the response (and read from in the request).
|
|
21
|
+
* The default value is 'connect.sid'.
|
|
22
|
+
* @type {string|undefined}
|
|
23
|
+
*/
|
|
24
|
+
cookie_name: 'connect.sid',
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* If the session is stored in "redis", this field is required and should be set to the hostname of the Redis server.
|
|
28
|
+
* For example, to connect to redis on localhost on port 6379, set "redis://localhost:6379".
|
|
29
|
+
* To connect to a different host or port, use a connection string in the format "redis[s]://[[username][:password]@][host][:port][/db-number]".
|
|
30
|
+
* For example, "redis://alice:foobared@awesome.redis.server:6380".
|
|
31
|
+
* @type {string|undefined}
|
|
32
|
+
*/
|
|
33
|
+
redis_host: undefined,
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Authentication user ID field name, defaults to `username`.
|
|
37
|
+
* @type {string}
|
|
38
|
+
*/
|
|
39
|
+
username: 'email',
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Authentication password field name, defaults to `password`.
|
|
43
|
+
* @type {string}
|
|
44
|
+
*/
|
|
45
|
+
password: 'password',
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* URL to redirect after successful authentication, defaults to `/`.
|
|
49
|
+
* @type {string}
|
|
50
|
+
*/
|
|
51
|
+
success_redirect: '/',
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* URL to redirect after log off, defaults to `/login`.
|
|
55
|
+
* @type {string}
|
|
56
|
+
*/
|
|
57
|
+
failure_redirect: '/login',
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* This hook is called when authenticating a user.
|
|
61
|
+
* Please find the user information that owns the credentials based on the user name and password you received and return it.
|
|
62
|
+
* If the user who owns the credentials cannot be found, return null.
|
|
63
|
+
*
|
|
64
|
+
* Note that the user information must include an ID value that can identify the user.
|
|
65
|
+
*
|
|
66
|
+
* @type {(username: string, password: string, req: express.Request) => Promise<{[key: string]: any}|null>}
|
|
67
|
+
*/
|
|
68
|
+
authenticate_user: async (username, password, req) => {
|
|
69
|
+
return UserModel.findOne({
|
|
70
|
+
where: {
|
|
71
|
+
email: username,
|
|
72
|
+
password
|
|
73
|
+
},
|
|
74
|
+
raw: true
|
|
75
|
+
});
|
|
76
|
+
},
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* This hook is called when user authentication is successful.
|
|
80
|
+
* Please search and return the authenticated user information to be set in the session based on the user ID of the parameter.
|
|
81
|
+
* The returned data will be set in the req.user property and the view's session variable.
|
|
82
|
+
*
|
|
83
|
+
* @type {(id: number|string) => Promise<{[key: string]: any}>}
|
|
84
|
+
*/
|
|
85
|
+
subscribe_user: async (id) => {
|
|
86
|
+
return UserModel.findOne({
|
|
87
|
+
where: {id},
|
|
88
|
+
raw: true
|
|
89
|
+
});
|
|
90
|
+
},
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* URL without authentication. If the URL described in the access URL partially matches, authentication will not be performed, defaults to none.
|
|
94
|
+
* @type {(string|RegExp)[]}
|
|
95
|
+
*/
|
|
96
|
+
allow_unauthenticated: ['/api'],
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Authenticated user session expiration, defaults to 24 hours (24 * 3600000).
|
|
100
|
+
* @type {number}
|
|
101
|
+
*/
|
|
102
|
+
expiration: 24 * 3600000
|
|
103
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
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
|
+
* @type {(baseUrl: string): string}
|
|
42
|
+
* @example
|
|
43
|
+
* rewrite_base_url: baseUrl => {
|
|
44
|
+
* return `${baseUrl}/admin`;
|
|
45
|
+
* }
|
|
46
|
+
*/
|
|
47
|
+
rewrite_base_url: baseUrl => {
|
|
48
|
+
return baseUrl;
|
|
49
|
+
},
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* This is a hook for error handling.
|
|
53
|
+
* For example, you can use it when you want to send an external notification of the error received by this hook.
|
|
54
|
+
* @type {(error: any): void|Promise<void>}
|
|
55
|
+
* @example
|
|
56
|
+
* error_handler: async error => {
|
|
57
|
+
* // Notify system administrator of error.
|
|
58
|
+
* return new Promise((resolve, reject) => {
|
|
59
|
+
* const sendmail = require('sendmail')();
|
|
60
|
+
* sendmail({
|
|
61
|
+
* from: 'no-reply@example.com',
|
|
62
|
+
* to: 'administrator@example.com',
|
|
63
|
+
* subject: 'Error occurred',
|
|
64
|
+
* text: error.message
|
|
65
|
+
* }, error => {
|
|
66
|
+
* error ? reject(error) : resolve();
|
|
67
|
+
* });
|
|
68
|
+
* });
|
|
69
|
+
* }
|
|
70
|
+
*/
|
|
71
|
+
error_handler: error => {
|
|
72
|
+
console.error(`An error has occurred. Error message: ${error.message}`);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Database configuration.
|
|
3
|
+
*/
|
|
4
|
+
module.exports = {
|
|
5
|
+
development: {
|
|
6
|
+
username: 'root',
|
|
7
|
+
password: 'password',
|
|
8
|
+
database: 'sample_db',
|
|
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: 'sample_db',
|
|
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: 'sample_db',
|
|
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,103 @@
|
|
|
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
|
+
* The name of the session ID cookie to set in the response (and read from in the request).
|
|
21
|
+
* The default value is 'connect.sid'.
|
|
22
|
+
* @type {string|undefined}
|
|
23
|
+
*/
|
|
24
|
+
cookie_name: 'connect.sid',
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* If the session is stored in "redis", this field is required and should be set to the hostname of the Redis server.
|
|
28
|
+
* For example, to connect to redis on localhost on port 6379, set "redis://localhost:6379".
|
|
29
|
+
* To connect to a different host or port, use a connection string in the format "redis[s]://[[username][:password]@][host][:port][/db-number]".
|
|
30
|
+
* For example, "redis://alice:foobared@awesome.redis.server:6380".
|
|
31
|
+
* @type {string|undefined}
|
|
32
|
+
*/
|
|
33
|
+
redis_host: undefined,
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Authentication user ID field name, defaults to `username`.
|
|
37
|
+
* @type {string}
|
|
38
|
+
*/
|
|
39
|
+
username: 'email',
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Authentication password field name, defaults to `password`.
|
|
43
|
+
* @type {string}
|
|
44
|
+
*/
|
|
45
|
+
password: 'password',
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* URL to redirect after successful authentication, defaults to `/`.
|
|
49
|
+
* @type {string}
|
|
50
|
+
*/
|
|
51
|
+
success_redirect: '/',
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* URL to redirect after log off, defaults to `/login`.
|
|
55
|
+
* @type {string}
|
|
56
|
+
*/
|
|
57
|
+
failure_redirect: '/login',
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* This hook is called when authenticating a user.
|
|
61
|
+
* Please find the user information that owns the credentials based on the user name and password you received and return it.
|
|
62
|
+
* If the user who owns the credentials cannot be found, return null.
|
|
63
|
+
*
|
|
64
|
+
* Note that the user information must include an ID value that can identify the user.
|
|
65
|
+
*
|
|
66
|
+
* @type {(username: string, password: string, req: express.Request) => Promise<{[key: string]: any}|null>}
|
|
67
|
+
*/
|
|
68
|
+
authenticate_user: async (username, password, req) => {
|
|
69
|
+
return UserModel.findOne({
|
|
70
|
+
where: {
|
|
71
|
+
email: username,
|
|
72
|
+
password
|
|
73
|
+
},
|
|
74
|
+
raw: true
|
|
75
|
+
});
|
|
76
|
+
},
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* This hook is called when user authentication is successful.
|
|
80
|
+
* Please search and return the authenticated user information to be set in the session based on the user ID of the parameter.
|
|
81
|
+
* The returned data will be set in the req.user property and the view's session variable.
|
|
82
|
+
*
|
|
83
|
+
* @type {(id: number|string) => Promise<{[key: string]: any}>}
|
|
84
|
+
*/
|
|
85
|
+
subscribe_user: async (id) => {
|
|
86
|
+
return UserModel.findOne({
|
|
87
|
+
where: {id},
|
|
88
|
+
raw: true
|
|
89
|
+
});
|
|
90
|
+
},
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* URL without authentication. If the URL described in the access URL partially matches, authentication will not be performed, defaults to none.
|
|
94
|
+
* @type {(string|RegExp)[]}
|
|
95
|
+
*/
|
|
96
|
+
allow_unauthenticated: ['/api'],
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Authenticated user session expiration, defaults to 24 hours (24 * 3600000).
|
|
100
|
+
* @type {number}
|
|
101
|
+
*/
|
|
102
|
+
expiration: 24 * 3600000
|
|
103
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
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
|
+
* @type {(baseUrl: string): string}
|
|
42
|
+
* @example
|
|
43
|
+
* rewrite_base_url: baseUrl => {
|
|
44
|
+
* return `${baseUrl}/admin`;
|
|
45
|
+
* }
|
|
46
|
+
*/
|
|
47
|
+
rewrite_base_url: baseUrl => {
|
|
48
|
+
return baseUrl;
|
|
49
|
+
},
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* This is a hook for error handling.
|
|
53
|
+
* For example, you can use it when you want to send an external notification of the error received by this hook.
|
|
54
|
+
* @type {(error: any): void|Promise<void>}
|
|
55
|
+
* @example
|
|
56
|
+
* error_handler: async error => {
|
|
57
|
+
* // Notify system administrator of error.
|
|
58
|
+
* return new Promise((resolve, reject) => {
|
|
59
|
+
* const sendmail = require('sendmail')();
|
|
60
|
+
* sendmail({
|
|
61
|
+
* from: 'no-reply@example.com',
|
|
62
|
+
* to: 'administrator@example.com',
|
|
63
|
+
* subject: 'Error occurred',
|
|
64
|
+
* text: error.message
|
|
65
|
+
* }, error => {
|
|
66
|
+
* error ? reject(error) : resolve();
|
|
67
|
+
* });
|
|
68
|
+
* });
|
|
69
|
+
* }
|
|
70
|
+
*/
|
|
71
|
+
error_handler: error => {
|
|
72
|
+
console.error(`An error has occurred. Error message: ${error.message}`);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Database configuration.
|
|
3
|
+
*/
|
|
4
|
+
export default {
|
|
5
|
+
development: {
|
|
6
|
+
username: 'root',
|
|
7
|
+
password: 'password',
|
|
8
|
+
database: 'sample_db',
|
|
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: 'sample_db',
|
|
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: 'sample_db',
|
|
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
|
+
}
|