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
|
@@ -2,7 +2,7 @@ import * as expressExtension from 'express-sweet';
|
|
|
2
2
|
import {Router} from 'express';
|
|
3
3
|
import {query, body, validationResult} from 'express-validator';
|
|
4
4
|
import UserModel from '../../models/UserModel.js';
|
|
5
|
-
import
|
|
5
|
+
import NotFoundError from '../../errors/NotFoundError.js';
|
|
6
6
|
import * as CustomValidation from '../../shared/CustomValidation.js';
|
|
7
7
|
|
|
8
8
|
const router = Router();
|
|
@@ -81,7 +81,7 @@ router.put('/:userId(\\d+)', [
|
|
|
81
81
|
await UserModel.updateUser(req.params.userId, req.body.user);
|
|
82
82
|
res.json(true);
|
|
83
83
|
} catch (error) {
|
|
84
|
-
if (error instanceof
|
|
84
|
+
if (error instanceof NotFoundError)
|
|
85
85
|
res.json({error: error.name});
|
|
86
86
|
else
|
|
87
87
|
next(error);
|
|
@@ -106,7 +106,7 @@ router.put('/profile', [
|
|
|
106
106
|
await UserModel.updateUser(req.user.id, req.body.user);
|
|
107
107
|
res.json(true);
|
|
108
108
|
} catch (error) {
|
|
109
|
-
if (error instanceof
|
|
109
|
+
if (error instanceof NotFoundError)
|
|
110
110
|
res.json({error: error.name});
|
|
111
111
|
else
|
|
112
112
|
next(error);
|