express-sweet-generator 2.0.6 → 2.0.7
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 +2 -2
- package/package.json +1 -1
- package/templates/cjs/errors/NotFoundError.js +14 -0
- package/templates/cjs/models/UserModel.js +2 -2
- package/templates/cjs/public/build/editPersonal.js +98 -98
- package/templates/cjs/public/build/users.js +174 -174
- package/templates/cjs/routes/api/users.js +3 -3
- package/templates/client/src/editPersonal.js +1 -1
- package/templates/client/src/modals/UserModal.js +1 -1
- package/templates/esm/errors/NotFoundError.js +14 -0
- package/templates/esm/models/UserModel.js +2 -2
- package/templates/esm/public/build/editPersonal.js +98 -98
- package/templates/esm/public/build/users.js +174 -174
- package/templates/esm/routes/api/users.js +3 -3
- package/templates/cjs/exceptions/UserNotFound.js +0 -6
- package/templates/esm/exceptions/UserNotFound.js +0 -6
package/README.md
CHANGED
|
@@ -143,8 +143,8 @@ Use the application generator tool, `express-sweet-generator`, to quickly create
|
|
|
143
143
|
│ ├── config.js
|
|
144
144
|
│ ├── database.js
|
|
145
145
|
│ └── view.js
|
|
146
|
-
├──
|
|
147
|
-
│ └──
|
|
146
|
+
├── errors
|
|
147
|
+
│ └── NotFoundError.js
|
|
148
148
|
├── models
|
|
149
149
|
│ ├── BookModel.js
|
|
150
150
|
│ ├── CommentModel.js
|
package/package.json
CHANGED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Custom error class for "Not Found" errors.
|
|
3
|
+
*/
|
|
4
|
+
module.exports = class extends Error {
|
|
5
|
+
/**
|
|
6
|
+
* Creates a new NotFoundError instance.
|
|
7
|
+
* @param {string} [message='The requested record could not be found.'] - The error message.
|
|
8
|
+
*/
|
|
9
|
+
constructor(message = 'The requested record could not be found.') {
|
|
10
|
+
super(message);
|
|
11
|
+
this.name = 'NotFoundError';
|
|
12
|
+
this.statusCode = 404; // HTTP status code for "Not Found"
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const expressExtension = require('express-sweet');
|
|
2
2
|
const {Media} = require('nodejs-shared');
|
|
3
|
-
const
|
|
3
|
+
const NotFoundError = require('../errors/NotFoundError');
|
|
4
4
|
|
|
5
5
|
module.exports = class extends expressExtension.database.Model {
|
|
6
6
|
static get table() {
|
|
@@ -123,7 +123,7 @@ module.exports = class extends expressExtension.database.Model {
|
|
|
123
123
|
}, set);
|
|
124
124
|
const user = await this.getUser(userId);
|
|
125
125
|
if (!user)
|
|
126
|
-
throw new
|
|
126
|
+
throw new NotFoundError();
|
|
127
127
|
transaction = await super.begin();
|
|
128
128
|
user.email = set.email;
|
|
129
129
|
user.name = set.name;
|