express-sweet-generator 2.0.0 → 2.0.2
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/README.md +1 -1
- package/package.json +1 -2
- package/templates/cjs/bin/www.ejs +1 -1
- package/templates/cjs/config/database.js +3 -3
- package/templates/cjs/package.json.ejs +3 -2
- package/templates/esm/bin/www.ejs +1 -1
- package/templates/esm/config/database.js +3 -3
- package/templates/esm/package.json.ejs +3 -2
- package/CHANGELOG.md +0 -286
- package/templates/cjs/exceptions/UserIconIsNotWriteable.js +0 -6
- package/templates/cjs/routes/test.js +0 -8
- package/templates/esm/exceptions/UserIconIsNotWriteable.js +0 -6
- package/templates/esm/routes/test.js +0 -8
package/README.md
CHANGED
|
@@ -7,7 +7,7 @@ The latest API reference for Express Sweet can be found [here](https://takuya-mo
|
|
|
7
7
|
The API reference for previous versions can be found [here](https://takuya-motoshima.github.io/express-sweet/v1/).
|
|
8
8
|
|
|
9
9
|
## Release Notes
|
|
10
|
-
All changes can be found [here](CHANGELOG.md).
|
|
10
|
+
All changes can be found [here](https://github.com/takuya-motoshima/express-sweet/blob/HEAD/CHANGELOG.md).
|
|
11
11
|
|
|
12
12
|
## Quick Start
|
|
13
13
|
See [here](QUICK_START.md).
|
package/package.json
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "express-sweet-generator",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.2",
|
|
4
4
|
"description": "Express Sweet application generator.",
|
|
5
5
|
"main": "bin/express-sweet-cli.js",
|
|
6
6
|
"files": [
|
|
7
7
|
"LICENSE",
|
|
8
8
|
"README.md",
|
|
9
9
|
"QUICK_START.md",
|
|
10
|
-
"CHANGELOG.md",
|
|
11
10
|
"bin/",
|
|
12
11
|
"templates/",
|
|
13
12
|
"screencaps/"
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
module.exports = {
|
|
5
5
|
development: {
|
|
6
6
|
username: 'root',
|
|
7
|
-
|
|
7
|
+
password: 'password',
|
|
8
8
|
database: 'express_sweet_db',
|
|
9
9
|
host: 'localhost',
|
|
10
10
|
port: undefined,
|
|
@@ -14,7 +14,7 @@ module.exports = {
|
|
|
14
14
|
},
|
|
15
15
|
test: {
|
|
16
16
|
username: 'root',
|
|
17
|
-
|
|
17
|
+
password: 'password',
|
|
18
18
|
database: 'express_sweet_db',
|
|
19
19
|
host: 'localhost',
|
|
20
20
|
port: undefined,
|
|
@@ -24,7 +24,7 @@ module.exports = {
|
|
|
24
24
|
},
|
|
25
25
|
production: {
|
|
26
26
|
username: 'root',
|
|
27
|
-
|
|
27
|
+
password: 'password',
|
|
28
28
|
database: 'express_sweet_db',
|
|
29
29
|
host: 'localhost',
|
|
30
30
|
port: undefined,
|
|
@@ -9,10 +9,11 @@
|
|
|
9
9
|
},
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"debug": "~2.6.9",
|
|
12
|
-
"express
|
|
12
|
+
"express": "^4.19.2",
|
|
13
|
+
"express-sweet": "^2.0.2",
|
|
13
14
|
"express-validator": "^6.14.2",
|
|
14
15
|
"http-errors": "~1.6.3",
|
|
15
|
-
"nodejs-shared": "^1.0.
|
|
16
|
+
"nodejs-shared": "^1.0.28"
|
|
16
17
|
},
|
|
17
18
|
"devDependencies": {
|
|
18
19
|
"nodemon": "^2.0.20"
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
export default {
|
|
5
5
|
development: {
|
|
6
6
|
username: 'root',
|
|
7
|
-
|
|
7
|
+
password: 'password',
|
|
8
8
|
database: 'express_sweet_db',
|
|
9
9
|
host: 'localhost',
|
|
10
10
|
port: undefined,
|
|
@@ -14,7 +14,7 @@ export default {
|
|
|
14
14
|
},
|
|
15
15
|
test: {
|
|
16
16
|
username: 'root',
|
|
17
|
-
|
|
17
|
+
password: 'password',
|
|
18
18
|
database: 'express_sweet_db',
|
|
19
19
|
host: 'localhost',
|
|
20
20
|
port: undefined,
|
|
@@ -24,7 +24,7 @@ export default {
|
|
|
24
24
|
},
|
|
25
25
|
production: {
|
|
26
26
|
username: 'root',
|
|
27
|
-
|
|
27
|
+
password: 'password',
|
|
28
28
|
database: 'express_sweet_db',
|
|
29
29
|
host: 'localhost',
|
|
30
30
|
port: undefined,
|
|
@@ -12,10 +12,11 @@
|
|
|
12
12
|
"debug": "~2.6.9",
|
|
13
13
|
"esm": "^3.2.25",
|
|
14
14
|
"esm-wallaby": "^3.2.26",
|
|
15
|
-
"express
|
|
15
|
+
"express": "^4.19.2",
|
|
16
|
+
"express-sweet": "^2.0.2",
|
|
16
17
|
"express-validator": "^6.14.2",
|
|
17
18
|
"http-errors": "~1.6.3",
|
|
18
|
-
"nodejs-shared": "^1.0.
|
|
19
|
+
"nodejs-shared": "^1.0.28"
|
|
19
20
|
},
|
|
20
21
|
"devDependencies": {
|
|
21
22
|
"nodemon": "^2.0.20"
|
package/CHANGELOG.md
DELETED
|
@@ -1,286 +0,0 @@
|
|
|
1
|
-
# Changelog
|
|
2
|
-
All notable changes to this project will be documented in this file.
|
|
3
|
-
|
|
4
|
-
## [2.0.0] - 2024/3/24
|
|
5
|
-
### Changed
|
|
6
|
-
- Express Sweet version 2 no longer depends on the AWS SDK.
|
|
7
|
-
The `services.AWSRekognitionClient` and `services.AWSSesClient` have been migrated to the [AWS SDK Extension](https://www.npmjs.com/package/aws-sdk-extension) NPM package, so please install from there if needed.
|
|
8
|
-
|
|
9
|
-
## [1.0.20] - 2024/3/22
|
|
10
|
-
### Changed
|
|
11
|
-
- Changed the default value of the template cookie secure attribute (`cookie_secure` in the `config/config.js` file) from true to false.
|
|
12
|
-
If `cookie_secure` is enabled, the login will always fail because no session cookie is written when the demo is run on a local server (HTTP).
|
|
13
|
-
|
|
14
|
-
## [1.0.19] - 2024/3/21
|
|
15
|
-
### Fixed
|
|
16
|
-
- The client build module (public/build) of the template was out of date, so it was updated to the latest version.
|
|
17
|
-
|
|
18
|
-
## [1.0.18] - 2024/3/6
|
|
19
|
-
### Changed
|
|
20
|
-
- Updated [metronic-extension](https://www.npmjs.com/package/metronic-extension) of templates from v1.0.1 to v3.0.9.
|
|
21
|
-
|
|
22
|
-
## [1.0.17] - 2024/3/6
|
|
23
|
-
### Fixed
|
|
24
|
-
- Fixed a typo in the name of the common JS module loaded from the template view.
|
|
25
|
-
|
|
26
|
-
## [1.0.16] - 2024/3/5
|
|
27
|
-
### Changed
|
|
28
|
-
- Changed sample DB name from `sampledb` to `express_sweet_db`.
|
|
29
|
-
|
|
30
|
-
## [1.0.15] - 2024/2/29
|
|
31
|
-
### Changed
|
|
32
|
-
- Added the ability to change color themes in template applications.
|
|
33
|
-
- Updated template application theme to Metronic v8.1.8.
|
|
34
|
-
|
|
35
|
-
## [1.0.14] - 2023/12/30
|
|
36
|
-
### Changed
|
|
37
|
-
- The `Secure` and `HttpOnly` attributes of the session cookie can now be set from the authentication configuration file (`config/authentication.js`).
|
|
38
|
-
|
|
39
|
-
config/authentication.js:
|
|
40
|
-
```js
|
|
41
|
-
/**
|
|
42
|
-
* Specifies the boolean value for the Secure Set-Cookie attribute.
|
|
43
|
-
* The default is true, which sets the Secure attribute on the cookie.
|
|
44
|
-
* @type {boolean|undefined}
|
|
45
|
-
*/
|
|
46
|
-
cookie_secure: false,
|
|
47
|
-
// cookie_secure: true,
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Specifies the boolean value for the HttpOnly Set-Cookie attribute.
|
|
51
|
-
* Defaults to true, which sets the HttpOnly attribute on the cookie.
|
|
52
|
-
* @type {boolean|undefined}
|
|
53
|
-
*/
|
|
54
|
-
cookie_httpOnly: true,
|
|
55
|
-
```
|
|
56
|
-
|
|
57
|
-
## [1.0.13] - 2023/12/30
|
|
58
|
-
### Changed
|
|
59
|
-
- The cookie name for storing session IDs can now be set in the `cookie_name` field of the authentication configuration file (`config/authentication.js`).
|
|
60
|
-
|
|
61
|
-
config/authentication.js:
|
|
62
|
-
```js
|
|
63
|
-
/**
|
|
64
|
-
* The name of the session ID cookie to set in the response (and read from in the request).
|
|
65
|
-
* The default value is 'connect.sid'.
|
|
66
|
-
* @type {string|undefined}
|
|
67
|
-
*/
|
|
68
|
-
cookie_name: 'connect.sid'
|
|
69
|
-
```
|
|
70
|
-
|
|
71
|
-
## [1.0.12] - 2023/7/17
|
|
72
|
-
### Changed
|
|
73
|
-
- The beforeRender option in the view configuration (config/view.js) can now specify asynchronous functions.
|
|
74
|
-
|
|
75
|
-
### Added
|
|
76
|
-
- New Math-related view helpers have been added.
|
|
77
|
-
|Helper|Description|
|
|
78
|
-
|--|--|
|
|
79
|
-
|add|Calculates the sum of two numbers.|
|
|
80
|
-
|sub|Calculates the difference of the given values.|
|
|
81
|
-
|multiply|Calculate the multiplication of the given values.|
|
|
82
|
-
|divide|Compute the division of the given values.|
|
|
83
|
-
|ceil|Round up the value.|
|
|
84
|
-
|floor|Rounds down a number.|
|
|
85
|
-
|abs|Returns an absolute value.|
|
|
86
|
-
|
|
87
|
-
## [1.0.11] - 2023/7/12
|
|
88
|
-
### Changed
|
|
89
|
-
- Moved the Ajax determination option (is_ajax) in the authentication configuration (config/authentication.js) to the basic configuration (config/config.js).
|
|
90
|
-
|
|
91
|
-
config/config.js:
|
|
92
|
-
```js
|
|
93
|
-
is_ajax: req => {
|
|
94
|
-
// If the request URL begins with /api, it is assumed to be Ajax.
|
|
95
|
-
return /^\/api/.test(req.path);
|
|
96
|
-
// return !!req.xhr;
|
|
97
|
-
}
|
|
98
|
-
```
|
|
99
|
-
- The error handle option (error_handler) in the basic configuration (config/config.js) has been removed and an option to hook error handles (hook_handle_error) added instead.
|
|
100
|
-
|
|
101
|
-
config/config.js:
|
|
102
|
-
```js
|
|
103
|
-
hook_handle_error: (err, req, res, next) => {
|
|
104
|
-
if (err.status === 404)
|
|
105
|
-
// If the URL cannot be found, a 404 error screen (views/error-404.hbs) is displayed.
|
|
106
|
-
res.render('error-404');
|
|
107
|
-
else
|
|
108
|
-
// For other errors, unknown error screen (views/error-unknown.hbs) is displayed.
|
|
109
|
-
res.render('error-unknown');
|
|
110
|
-
}
|
|
111
|
-
```
|
|
112
|
-
|
|
113
|
-
## [1.0.10] - 2023/7/11
|
|
114
|
-
### Changed
|
|
115
|
-
- The URL to redirect to when login fails (failure_redirect) option in the authentication configuration (config/authentication.js) can now be defined with a function.
|
|
116
|
-
|
|
117
|
-
config/authentication.js:
|
|
118
|
-
```js
|
|
119
|
-
// Set the URL to redirect to in case of login failure as a string.
|
|
120
|
-
failure_redirect: '/login',
|
|
121
|
-
|
|
122
|
-
// Dynamically set the url to redirect to on login failure.
|
|
123
|
-
failure_redirect: (req, res) => {
|
|
124
|
-
// If the role stored in the cookie is admin, redirect to the admin login screen.
|
|
125
|
-
return req.cookies.role === 'admin' ? '/adminlogin' : 'login';
|
|
126
|
-
},
|
|
127
|
-
```
|
|
128
|
-
- The arguments of the failureRedirect method of the authentication service class (services/Authentication) have changed.
|
|
129
|
-
The argument to the Authentication.failureRedirect method used to be just express.Response, but now it requires express.Request and express.Response.
|
|
130
|
-
|
|
131
|
-
Example of login routes:
|
|
132
|
-
```js
|
|
133
|
-
import {Router} from 'express';
|
|
134
|
-
import * as sweet from 'express-sweet';
|
|
135
|
-
const router = Router();
|
|
136
|
-
const Authentication = sweet.services.Authentication;
|
|
137
|
-
|
|
138
|
-
router.post('/login', async (req, res, next) => {
|
|
139
|
-
const isAuth = await Authentication.authenticate(req, res, next);
|
|
140
|
-
if (isAuth)
|
|
141
|
-
Authentication.successRedirect(res);
|
|
142
|
-
else
|
|
143
|
-
Authentication.failureRedirect(req, res);
|
|
144
|
-
});
|
|
145
|
-
export default router;
|
|
146
|
-
```
|
|
147
|
-
|
|
148
|
-
## [1.0.9] - 2023/6/29
|
|
149
|
-
### Changed
|
|
150
|
-
- Changed helper function names in the view (Handlebars) from SnakeCase to CamelCase.
|
|
151
|
-
|After|Before|Description|
|
|
152
|
-
|--|--|--|
|
|
153
|
-
|notEmpty|not_empty|Check that it is not empty.|
|
|
154
|
-
|formatDate|format_date|Use moment to format the date.|
|
|
155
|
-
|cacheBusting|cache_busting|Returns the Assets path containing the file update time parameter.|
|
|
156
|
-
|jsonStringify|json_stringify|Stringify an object using JSON.stringify.|
|
|
157
|
-
|jsonParse|json_parse|Parses the given string using JSON.parse.|
|
|
158
|
-
|formatBytes|format_bytes|Convert bytes to just the right units(KB, MB, GB, TB, PB, EB, ZB, YB).|
|
|
159
|
-
|
|
160
|
-
### Added
|
|
161
|
-
- Added view helper to convert numeric values to strings with language-sensitive representations.
|
|
162
|
-
```html
|
|
163
|
-
{{number2locale 123456.789}} => 123,456.789
|
|
164
|
-
|
|
165
|
-
{{!-- German uses comma as decimal separator and period for thousands. --}}
|
|
166
|
-
{{number2locale 123456.789 'de-DE'}} => 123.456,789
|
|
167
|
-
```
|
|
168
|
-
|
|
169
|
-
## [1.0.8] - 2023/6/12
|
|
170
|
-
### Changed
|
|
171
|
-
- In the latest express-sweet v1.0.27, an express.Request object has been added to the arguments of the beforeRender function in the view configuration (config/view.js).
|
|
172
|
-
The view settings of the template have also been changed along with this update. (templates/cjs/config/view.js, templates/esm/config/view.js)
|
|
173
|
-
|
|
174
|
-
express-sweet v1.0.27 or later (current):
|
|
175
|
-
```js
|
|
176
|
-
beforeRender: (req, res) => {}
|
|
177
|
-
```
|
|
178
|
-
|
|
179
|
-
express-sweet v1.0.26 or earlier:
|
|
180
|
-
```js
|
|
181
|
-
beforeRender: res => {}
|
|
182
|
-
```
|
|
183
|
-
|
|
184
|
-
## [1.0.7] - 2022/10/24
|
|
185
|
-
### Fixed
|
|
186
|
-
- Added is_ajax option to user authentication.
|
|
187
|
-
|
|
188
|
-
config/authentication.js:
|
|
189
|
-
```js
|
|
190
|
-
is_ajax: req => {
|
|
191
|
-
// If the request URL begins with /api, it is assumed to be Ajax.
|
|
192
|
-
return /^\/api/.test(req.path);
|
|
193
|
-
// return !!req.xhr;
|
|
194
|
-
}
|
|
195
|
-
```
|
|
196
|
-
|
|
197
|
-
## [1.0.6] - 2022/10/20
|
|
198
|
-
### Fixed
|
|
199
|
-
- A request body object has been added to the parameters of the callback function for user authentication.
|
|
200
|
-
|
|
201
|
-
config/authentication.js:
|
|
202
|
-
```js
|
|
203
|
-
authenticate_user: async (username, password, req) => {
|
|
204
|
-
const UserModel = require('../models/UserModel');
|
|
205
|
-
return UserModel.findOne({
|
|
206
|
-
where: {
|
|
207
|
-
email: username,
|
|
208
|
-
password
|
|
209
|
-
},
|
|
210
|
-
raw: true
|
|
211
|
-
});
|
|
212
|
-
}
|
|
213
|
-
```
|
|
214
|
-
- Removed dependent packages(aws-sdk,express,passport,passport-local,sequelize) already included in express-sweet from the template package.json.
|
|
215
|
-
- Template application has been updated.
|
|
216
|
-
<p align="center">
|
|
217
|
-
<img alt="login" src="screencaps/login.jpg" width="45%">
|
|
218
|
-
<img alt="users" src="screencaps/users.jpg" width="45%">
|
|
219
|
-
</p>
|
|
220
|
-
<p align="center">
|
|
221
|
-
<img alt="user-editing" src="screencaps/user-editing.jpg" width="45%">
|
|
222
|
-
<img alt="personal" src="screencaps/personal.jpg" width="45%">
|
|
223
|
-
</p>
|
|
224
|
-
|
|
225
|
-
## [1.0.5] - 2022/7/27
|
|
226
|
-
### Fixed
|
|
227
|
-
- You can now set hook functions that are called before the view is rendered.
|
|
228
|
-
Hook functions can be used, for example, to set local variables that can be used in the view.
|
|
229
|
-
|
|
230
|
-
To use, add the beforeRender hook function to "config/view.js" as follows.
|
|
231
|
-
```js
|
|
232
|
-
beforeRender: res => {
|
|
233
|
-
res.locals.extra = 'Extra';
|
|
234
|
-
}
|
|
235
|
-
```
|
|
236
|
-
|
|
237
|
-
## [1.0.4] - 2022/5/18
|
|
238
|
-
### Fixed
|
|
239
|
-
- Version 1.0.18 of express-sweet now supports redis as session store for authentication, so we have added the relevant options (session_store, redis_host) to the authentication configuration of the template.
|
|
240
|
-
|
|
241
|
-
## [1.0.3] - 2022/5/17
|
|
242
|
-
### Fixed
|
|
243
|
-
- Fix UX of template views.
|
|
244
|
-
|
|
245
|
-
## [1.0.2] - 2022/2/13
|
|
246
|
-
### Fixed
|
|
247
|
-
- Changed the type of 'config/authentication.js#allow_unauthenticated' from'string[]' to'(string|RegExp)[]}'.
|
|
248
|
-
|
|
249
|
-
## [1.0.1] - 2021/6/10
|
|
250
|
-
### Fixed
|
|
251
|
-
- Removed packages that don't need to be installed from the template package.json.
|
|
252
|
-
- Added ESM template.
|
|
253
|
-
|
|
254
|
-
Create an EJS template application:
|
|
255
|
-
```sh
|
|
256
|
-
express-sweet -o esm myapp;
|
|
257
|
-
```
|
|
258
|
-
|
|
259
|
-
Create a CJS template application:
|
|
260
|
-
```sh
|
|
261
|
-
express-sweet myapp;
|
|
262
|
-
# or
|
|
263
|
-
express-sweet -o cjs myapp;
|
|
264
|
-
```
|
|
265
|
-
|
|
266
|
-
[1.0.1]: https://github.com/takuya-motoshima/express-sweet-generator/compare/v1.0.0...v1.0.1
|
|
267
|
-
[1.0.2]: https://github.com/takuya-motoshima/express-sweet-generator/compare/v1.0.1...v1.0.2
|
|
268
|
-
[1.0.3]: https://github.com/takuya-motoshima/express-sweet-generator/compare/v1.0.2...v1.0.3
|
|
269
|
-
[1.0.4]: https://github.com/takuya-motoshima/express-sweet-generator/compare/v1.0.3...v1.0.4
|
|
270
|
-
[1.0.5]: https://github.com/takuya-motoshima/express-sweet-generator/compare/v1.0.4...v1.0.5
|
|
271
|
-
[1.0.6]: https://github.com/takuya-motoshima/express-sweet-generator/compare/v1.0.5...v1.0.6
|
|
272
|
-
[1.0.7]: https://github.com/takuya-motoshima/express-sweet-generator/compare/v1.0.6...v1.0.7
|
|
273
|
-
[1.0.8]: https://github.com/takuya-motoshima/express-sweet-generator/compare/v1.0.7...v1.0.8
|
|
274
|
-
[1.0.9]: https://github.com/takuya-motoshima/express-sweet-generator/compare/v1.0.8...v1.0.9
|
|
275
|
-
[1.0.10]: https://github.com/takuya-motoshima/express-sweet-generator/compare/v1.0.9...v1.0.10
|
|
276
|
-
[1.0.11]: https://github.com/takuya-motoshima/express-sweet-generator/compare/v1.0.10...v1.0.11
|
|
277
|
-
[1.0.12]: https://github.com/takuya-motoshima/express-sweet-generator/compare/v1.0.11...v1.0.12
|
|
278
|
-
[1.0.13]: https://github.com/takuya-motoshima/express-sweet-generator/compare/v1.0.12...v1.0.13
|
|
279
|
-
[1.0.14]: https://github.com/takuya-motoshima/express-sweet-generator/compare/v1.0.13...v1.0.14
|
|
280
|
-
[1.0.15]: https://github.com/takuya-motoshima/express-sweet-generator/compare/v1.0.14...v1.0.15
|
|
281
|
-
[1.0.16]: https://github.com/takuya-motoshima/express-sweet-generator/compare/v1.0.15...v1.0.16
|
|
282
|
-
[1.0.17]: https://github.com/takuya-motoshima/express-sweet-generator/compare/v1.0.16...v1.0.17
|
|
283
|
-
[1.0.18]: https://github.com/takuya-motoshima/express-sweet-generator/compare/v1.0.17...v1.0.18
|
|
284
|
-
[1.0.19]: https://github.com/takuya-motoshima/express-sweet-generator/compare/v1.0.18...v1.0.19
|
|
285
|
-
[1.0.20]: https://github.com/takuya-motoshima/express-sweet-generator/compare/v1.0.19...v1.0.20
|
|
286
|
-
[2.0.0]: https://github.com/takuya-motoshima/express-sweet-generator/compare/v1.0.20...v2.0.0
|