express-sweet-generator 2.0.12 → 2.0.14
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 +22 -0
- package/templates/client/src/api/UserApi.js +36 -4
- package/templates/client/src/login.js +16 -4
- package/templates/client/src/modals/UserModal.js +3 -3
- package/templates/client/src/{editPersonal.js → profile-edit.js} +21 -7
- package/templates/client/src/users.js +26 -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
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// import * as expressExtension from 'express-sweet';
|
|
2
|
+
import {Router} from 'express';
|
|
3
|
+
import {body} from 'express-validator';
|
|
4
|
+
import UserModel from '../../models/UserModel.js';
|
|
5
|
+
import NotFoundError from '../../errors/NotFoundError.js';
|
|
6
|
+
import isValidImageDataUrl from '../../validators/isValidImageDataUrl.js';
|
|
7
|
+
import checkValidationResult from '../../middlewares/checkValidationResult.js';
|
|
8
|
+
|
|
9
|
+
const router = Router();
|
|
10
|
+
|
|
11
|
+
router.put('/', [
|
|
12
|
+
body('user.email').trim().not().isEmpty().isEmail(),
|
|
13
|
+
body('user.name').trim().not().isEmpty().isLength({max: 30}),
|
|
14
|
+
body('user.password').trim().optional({nullable: true, checkFalsy: true}).isLength({max: 128}),
|
|
15
|
+
body('user.icon').not().isEmpty().custom(isValidImageDataUrl),
|
|
16
|
+
checkValidationResult,
|
|
17
|
+
], async (req, res, next) => {
|
|
18
|
+
try {
|
|
19
|
+
await UserModel.updateUser(req.user.id, req.body.user);
|
|
20
|
+
res.json(true);
|
|
21
|
+
} catch (error) {
|
|
22
|
+
if (error instanceof NotFoundError)
|
|
23
|
+
res.json({error: error.name});
|
|
24
|
+
else
|
|
25
|
+
next(error);
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
export default router;
|
|
@@ -84,22 +84,4 @@ router.delete('/:userId(\\d+)', async (req, res) => {
|
|
|
84
84
|
res.json(true);
|
|
85
85
|
});
|
|
86
86
|
|
|
87
|
-
router.put('/profile', [
|
|
88
|
-
body('user.email').trim().not().isEmpty().isEmail(),
|
|
89
|
-
body('user.name').trim().not().isEmpty().isLength({max: 30}),
|
|
90
|
-
body('user.password').trim().optional({nullable: true, checkFalsy: true}).isLength({max: 128}),
|
|
91
|
-
body('user.icon').not().isEmpty().custom(isValidImageDataUrl),
|
|
92
|
-
checkValidationResult,
|
|
93
|
-
], async (req, res, next) => {
|
|
94
|
-
try {
|
|
95
|
-
await UserModel.updateUser(req.user.id, req.body.user);
|
|
96
|
-
res.json(true);
|
|
97
|
-
} catch (error) {
|
|
98
|
-
if (error instanceof NotFoundError)
|
|
99
|
-
res.json({error: error.name});
|
|
100
|
-
else
|
|
101
|
-
next(error);
|
|
102
|
-
}
|
|
103
|
-
});
|
|
104
|
-
|
|
105
87
|
export default router;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import {Router} from 'express';
|
|
2
|
+
import UserModel from '../models/UserModel.js';
|
|
3
|
+
|
|
4
|
+
const router = Router();
|
|
5
|
+
|
|
6
|
+
router.get('/', async (req, res) => {
|
|
7
|
+
const user = await UserModel.getUser(req.user.id);
|
|
8
|
+
res.render('profile/show', {user: user.toJSON()});
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
router.get('/edit', async (req, res) => {
|
|
12
|
+
const user = await UserModel.getUser(req.user.id);
|
|
13
|
+
res.render('profile/edit', {user: user.toJSON()});
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
export default router;
|
|
@@ -1,20 +1,9 @@
|
|
|
1
1
|
import {Router} from 'express';
|
|
2
|
-
import UserModel from '../models/UserModel.js';
|
|
3
2
|
|
|
4
3
|
const router = Router();
|
|
5
4
|
|
|
6
5
|
router.get('/', (req, res) => {
|
|
7
|
-
res.render('users');
|
|
8
|
-
});
|
|
9
|
-
|
|
10
|
-
router.get('/personal', async (req, res) => {
|
|
11
|
-
const user = await UserModel.getUser(req.user.id);
|
|
12
|
-
res.render('personal', {user: user.toJSON()});
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
router.get('/edit-personal', async (req, res) => {
|
|
16
|
-
const user = await UserModel.getUser(req.user.id);
|
|
17
|
-
res.render('edit-personal', {user: user.toJSON()});
|
|
6
|
+
res.render('users/index');
|
|
18
7
|
});
|
|
19
8
|
|
|
20
9
|
export default router;
|
|
@@ -112,9 +112,9 @@
|
|
|
112
112
|
</div>
|
|
113
113
|
<!--end:Menu item-->
|
|
114
114
|
<!--begin:Menu item-->
|
|
115
|
-
<div class="menu-item menu-here-bg me-0 me-lg-2 {{#if (eq currentPath '/
|
|
115
|
+
<div class="menu-item menu-here-bg me-0 me-lg-2 {{#if (eq currentPath '/profile')}}here{{/if}}">
|
|
116
116
|
<!--begin:Menu link-->
|
|
117
|
-
<a class="menu-link" href="/
|
|
117
|
+
<a class="menu-link" href="/profile">
|
|
118
118
|
<span class="menu-title">Profile Settings</span>
|
|
119
119
|
</a>
|
|
120
120
|
<!--end:Menu link-->
|
|
@@ -233,7 +233,7 @@
|
|
|
233
233
|
<!--end::Menu separator-->
|
|
234
234
|
<!--begin::Menu item-->
|
|
235
235
|
<div class="menu-item px-5">
|
|
236
|
-
<a href="/
|
|
236
|
+
<a href="/profile" class="menu-link px-5">Profile Settings</a>
|
|
237
237
|
</div>
|
|
238
238
|
<!--end::Menu item-->
|
|
239
239
|
<!--begin::Menu item-->
|
|
@@ -337,7 +337,7 @@
|
|
|
337
337
|
<!--begin:Menu item-->
|
|
338
338
|
<div class="menu-item">
|
|
339
339
|
<!--begin:Menu link-->
|
|
340
|
-
<a class="menu-link {{#if (or (eq currentPath '/
|
|
340
|
+
<a class="menu-link {{#if (or (eq currentPath '/profile') (eq currentPath '/profile/edit'))}}active{{/if}}" href="/profile">
|
|
341
341
|
<span class="menu-icon">
|
|
342
342
|
<i class="ki-duotone ki-address-book fs-2">
|
|
343
343
|
<span class="path1"></span>
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{{!< default}}
|
|
2
2
|
{{#contentFor 'title'}}Edit personal settings{{/contentFor}}
|
|
3
|
-
{{#contentFor 'style'}}<link rel="stylesheet" type="text/css" href="{{cacheBusting '/build/
|
|
4
|
-
{{#contentFor 'script'}}<script src="{{cacheBusting '/build/
|
|
3
|
+
{{#contentFor 'style'}}<link rel="stylesheet" type="text/css" href="{{cacheBusting '/build/profile-edit.css' ''}}">{{/contentFor}}
|
|
4
|
+
{{#contentFor 'script'}}<script src="{{cacheBusting '/build/profile-edit.js' ''}}"></script>{{/contentFor}}
|
|
5
5
|
<input data-ref="user.iconPath" type="hidden" value="{{user.icon}}">
|
|
6
6
|
<input data-ref="user.modified" type="hidden" value="{{formatDate 'x' user.modified}}">
|
|
7
7
|
|
|
8
8
|
<!--begin::Basic info-->
|
|
9
9
|
<div class="card mb-5 mb-xl-10">
|
|
10
10
|
<!--begin::Form-->
|
|
11
|
-
<form data-ref="
|
|
11
|
+
<form data-ref="profileEditForm" class="form" novalidate="novalidate">
|
|
12
12
|
<!--begin::Card body-->
|
|
13
13
|
<div class="card-body p-9">
|
|
14
14
|
<!--begin::Input group-->
|
|
@@ -85,7 +85,7 @@
|
|
|
85
85
|
<!--end::Card body-->
|
|
86
86
|
<!--begin::Actions-->
|
|
87
87
|
<div class="card-footer d-flex justify-content-end py-6 px-9">
|
|
88
|
-
<a href="/
|
|
88
|
+
<a href="/profile" class="btn btn-light btn-active-light-primary me-2">Back to Profile</a>
|
|
89
89
|
<button type="submit" class="btn btn-primary">Update Profile</button>
|
|
90
90
|
</div>
|
|
91
91
|
<!--end::Actions-->
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
<!--begin::Card header-->
|
|
6
6
|
<div class="card-header cursor-pointer justify-content-end">
|
|
7
7
|
<!--begin::Action-->
|
|
8
|
-
<a href="/
|
|
8
|
+
<a href="/profile/edit" class="btn btn-primary align-self-center">Edit Profile</a>
|
|
9
9
|
<!--end::Action-->
|
|
10
10
|
</div>
|
|
11
11
|
<!--end::Card header-->
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|