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