express-sweet-generator 2.0.12 → 2.0.13
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 +8 -4
- package/package.json +1 -1
- package/templates/cjs/bin/www.ejs +3 -3
- package/templates/cjs/models/UserModel.js +9 -1
- package/templates/cjs/public/build/login.js +3 -7
- package/templates/{esm/public/build/editPersonal.js → cjs/public/build/profile-edit.js} +115 -105
- package/templates/cjs/public/build/users.js +185 -185
- package/templates/cjs/routes/api/profile.js +29 -0
- package/templates/cjs/routes/api/users.js +0 -18
- package/templates/cjs/routes/profile.js +16 -0
- package/templates/cjs/routes/users.js +1 -12
- package/templates/cjs/views/layout/default.hbs +4 -4
- package/templates/{esm/views/edit-personal.hbs → cjs/views/profile/edit.hbs} +4 -4
- package/templates/{esm/views/personal.hbs → cjs/views/profile/show.hbs} +1 -1
- package/templates/client/src/api/ProfileApi.js +11 -0
- package/templates/client/src/api/UserApi.js +0 -4
- package/templates/client/src/login.js +4 -4
- package/templates/client/src/{editPersonal.js → profile-edit.js} +9 -7
- package/templates/client/src/users.js +14 -10
- package/templates/client/webpack.config.js +1 -1
- package/templates/esm/bin/www.ejs +3 -3
- package/templates/esm/models/UserModel.js +9 -1
- package/templates/esm/public/build/login.js +3 -7
- package/templates/{cjs/public/build/editPersonal.js → esm/public/build/profile-edit.js} +115 -105
- package/templates/esm/public/build/users.js +185 -185
- package/templates/esm/routes/api/profile.js +29 -0
- package/templates/esm/routes/api/users.js +0 -18
- package/templates/esm/routes/profile.js +16 -0
- package/templates/esm/routes/users.js +1 -12
- package/templates/esm/views/layout/default.hbs +4 -4
- package/templates/{cjs/views/edit-personal.hbs → esm/views/profile/edit.hbs} +4 -4
- package/templates/{cjs/views/personal.hbs → esm/views/profile/show.hbs} +1 -1
- /package/templates/cjs/public/build/{editPersonal.css → profile-edit.css} +0 -0
- /package/templates/cjs/views/{users.hbs → users/index.hbs} +0 -0
- /package/templates/client/src/{editPersonal.css → profile-edit.css} +0 -0
- /package/templates/esm/public/build/{editPersonal.css → profile-edit.css} +0 -0
- /package/templates/esm/views/{users.hbs → users/index.hbs} +0 -0
package/README.md
CHANGED
|
@@ -157,23 +157,27 @@ Use the application generator tool, `express-sweet-generator`, to quickly create
|
|
|
157
157
|
│ └── upload
|
|
158
158
|
├── routes
|
|
159
159
|
│ ├── login.js
|
|
160
|
+
│ ├── profile.js
|
|
160
161
|
│ ├── users.js
|
|
161
162
|
│ └── api
|
|
163
|
+
│ ├── profile.js
|
|
162
164
|
│ └── users.js
|
|
163
165
|
├── shared
|
|
164
166
|
│ └── isEmpty.js
|
|
165
167
|
├── validators
|
|
166
168
|
│ └── isValidImageDataUrl.js
|
|
167
169
|
└── views
|
|
168
|
-
├── edit-personal.hbs
|
|
169
170
|
├── error.hbs
|
|
170
171
|
├── login.hbs
|
|
171
|
-
├── personal.hbs
|
|
172
|
-
├── users.hbs
|
|
173
172
|
├── layout
|
|
174
173
|
│ └── default.hbs
|
|
175
|
-
|
|
174
|
+
├── partials
|
|
176
175
|
│ └── .gitkeep
|
|
176
|
+
├── users
|
|
177
|
+
│ └── index.hbs
|
|
178
|
+
├── profile
|
|
179
|
+
│ ├── show.hbs
|
|
180
|
+
│ └── edit.hbs
|
|
177
181
|
└── errors
|
|
178
182
|
├── 404.hbs
|
|
179
183
|
└── 500.hbs
|
package/package.json
CHANGED
|
@@ -9,7 +9,7 @@ const app = require('../app');
|
|
|
9
9
|
/**
|
|
10
10
|
* Normalize a port into a number, string, or false.
|
|
11
11
|
*/
|
|
12
|
-
|
|
12
|
+
const normalizePort = val => {
|
|
13
13
|
var port = parseInt(val, 10);
|
|
14
14
|
// named pipe
|
|
15
15
|
if (isNaN(port)) return val;
|
|
@@ -22,7 +22,7 @@ function normalizePort(val) {
|
|
|
22
22
|
/**
|
|
23
23
|
* Event listener for HTTP server "error" event.
|
|
24
24
|
*/
|
|
25
|
-
|
|
25
|
+
const onError = error => {
|
|
26
26
|
if (error.syscall !== 'listen')
|
|
27
27
|
throw error;
|
|
28
28
|
const bind = typeof port === 'string' ? `Pipe ${port}` : `Port ${port}`;
|
|
@@ -45,7 +45,7 @@ function onError(error) {
|
|
|
45
45
|
/**
|
|
46
46
|
* Event listener for HTTP server "listening" event.
|
|
47
47
|
*/
|
|
48
|
-
|
|
48
|
+
const onListening = () => {
|
|
49
49
|
const addr = server.address();
|
|
50
50
|
const bind = typeof addr === 'string' ? `pipe ${addr}` : `port ${addr.port}`;
|
|
51
51
|
debug(`Listening on ${bind}`);
|
|
@@ -68,8 +68,10 @@ module.exports = class extends expressExtension.database.Model {
|
|
|
68
68
|
search: null,
|
|
69
69
|
}, paginationOptions);
|
|
70
70
|
|
|
71
|
+
// Calculate total records.
|
|
71
72
|
const recordsTotal = await super.count();
|
|
72
73
|
|
|
74
|
+
// Where clause for filtering data.
|
|
73
75
|
const whereClause = {};
|
|
74
76
|
if (paginationOptions.search)
|
|
75
77
|
whereClause[super.Op.or] = [
|
|
@@ -77,12 +79,16 @@ module.exports = class extends expressExtension.database.Model {
|
|
|
77
79
|
{name: {[super.Op.like]: `%${paginationOptions.search}%`}}
|
|
78
80
|
];
|
|
79
81
|
|
|
82
|
+
// Calculate filtered records.
|
|
80
83
|
const recordsFiltered = await super.count({where: whereClause});
|
|
81
84
|
|
|
85
|
+
// Fetch paginated data.
|
|
82
86
|
const data = await super.findAll({
|
|
83
87
|
attributes: ['id', 'name', 'email', 'icon', 'modified'],
|
|
84
88
|
where: whereClause,
|
|
85
|
-
order: [
|
|
89
|
+
order: [
|
|
90
|
+
[super.col(paginationOptions.order), paginationOptions.dir],
|
|
91
|
+
],
|
|
86
92
|
offset: parseInt(paginationOptions.start, 10),
|
|
87
93
|
limit: parseInt(paginationOptions.length),
|
|
88
94
|
raw: true
|
|
@@ -163,6 +169,7 @@ module.exports = class extends expressExtension.database.Model {
|
|
|
163
169
|
}
|
|
164
170
|
|
|
165
171
|
static async emailExists(email, excludeUserId = null) {
|
|
172
|
+
// Where clause for filtering data.
|
|
166
173
|
const whereClause = {email};
|
|
167
174
|
if (excludeUserId)
|
|
168
175
|
whereClause.id = {[super.Op.ne]: excludeUserId};
|
|
@@ -170,6 +177,7 @@ module.exports = class extends expressExtension.database.Model {
|
|
|
170
177
|
}
|
|
171
178
|
|
|
172
179
|
static async userIdExists(userId) {
|
|
180
|
+
// Where clause for filtering data.
|
|
173
181
|
const whereClause = {email};
|
|
174
182
|
if (excludeUserId)
|
|
175
183
|
whereClause.id = {[super.Op.ne]: excludeUserId};
|
|
@@ -169,17 +169,13 @@ var build = __webpack_require__(236);
|
|
|
169
169
|
async deleteUser(userId) {
|
|
170
170
|
return this.client.delete(`/${userId}`);
|
|
171
171
|
}
|
|
172
|
-
|
|
173
|
-
async updateProfile(formData) {
|
|
174
|
-
return this.client.put('/profile', formData);
|
|
175
|
-
}
|
|
176
172
|
});
|
|
177
173
|
;// CONCATENATED MODULE: ./src/login.js
|
|
178
174
|
|
|
179
175
|
|
|
180
176
|
|
|
181
177
|
|
|
182
|
-
|
|
178
|
+
const initValidation = () => {
|
|
183
179
|
validation = new build.components.Validation(ref.loginForm.get(0), {
|
|
184
180
|
email: {
|
|
185
181
|
validators: {
|
|
@@ -196,7 +192,7 @@ function initValidation() {
|
|
|
196
192
|
});
|
|
197
193
|
}
|
|
198
194
|
|
|
199
|
-
|
|
195
|
+
const handleForm = () => {
|
|
200
196
|
validation.onValid(async () => {
|
|
201
197
|
try {
|
|
202
198
|
validation.onIndicator();
|
|
@@ -217,7 +213,7 @@ const userApi = new UserApi();
|
|
|
217
213
|
const ref = build.components.selectRef();
|
|
218
214
|
let validation;
|
|
219
215
|
initValidation();
|
|
220
|
-
|
|
216
|
+
handleForm();
|
|
221
217
|
})();
|
|
222
218
|
|
|
223
219
|
/******/ })()
|