express-sweet-generator 1.0.2 → 1.0.3

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.
Files changed (60) hide show
  1. package/CHANGELOG.md +6 -2
  2. package/README.md +14 -42
  3. package/bin/express-sweet-cli.js +220 -217
  4. package/package.json +1 -1
  5. package/templates/cjs/config/database.js +6 -12
  6. package/templates/cjs/ecosystem.config.js.ejs +5 -1
  7. package/templates/cjs/public/assets/home.css +0 -0
  8. package/templates/cjs/public/assets/home.js +0 -0
  9. package/templates/cjs/public/assets/{styles/login.css → login.css} +0 -2
  10. package/templates/cjs/public/assets/{scripts/login.js → login.js} +0 -3
  11. package/templates/cjs/public/assets/{images/logo.svg → logo.svg} +0 -0
  12. package/templates/cjs/public/assets/user.css +0 -0
  13. package/templates/cjs/public/assets/{scripts/user.js → user.js} +0 -3
  14. package/templates/cjs/public/assets/users.css +0 -0
  15. package/templates/cjs/public/assets/{scripts/users.js → users.js} +11 -9
  16. package/templates/cjs/routes/api/users.js +7 -33
  17. package/templates/cjs/routes/home.js +0 -3
  18. package/templates/cjs/routes/login.js +0 -3
  19. package/templates/cjs/routes/users.js +3 -9
  20. package/templates/cjs/views/error.hbs +1 -2
  21. package/templates/cjs/views/home.hbs +2 -8
  22. package/templates/cjs/views/layout/default.hbs +13 -18
  23. package/templates/cjs/views/login.hbs +4 -15
  24. package/templates/cjs/views/user.hbs +9 -16
  25. package/templates/cjs/views/users.hbs +5 -17
  26. package/templates/esm/config/database.js +6 -12
  27. package/templates/esm/ecosystem.config.js.ejs +5 -1
  28. package/templates/esm/public/assets/home.css +0 -0
  29. package/templates/esm/public/assets/home.js +0 -0
  30. package/templates/esm/public/assets/{styles/login.css → login.css} +0 -2
  31. package/templates/esm/public/assets/{scripts/login.js → login.js} +0 -3
  32. package/templates/esm/public/assets/{images/logo.svg → logo.svg} +0 -0
  33. package/templates/esm/public/assets/user.css +0 -0
  34. package/templates/esm/public/assets/{scripts/user.js → user.js} +0 -3
  35. package/templates/esm/public/assets/users.css +0 -0
  36. package/templates/esm/public/assets/{scripts/users.js → users.js} +11 -9
  37. package/templates/esm/routes/api/users.js +7 -33
  38. package/templates/esm/routes/home.js +0 -3
  39. package/templates/esm/routes/login.js +0 -3
  40. package/templates/esm/routes/users.js +3 -9
  41. package/templates/esm/views/error.hbs +1 -2
  42. package/templates/esm/views/home.hbs +2 -8
  43. package/templates/esm/views/layout/default.hbs +13 -18
  44. package/templates/esm/views/login.hbs +4 -15
  45. package/templates/esm/views/user.hbs +9 -16
  46. package/templates/esm/views/users.hbs +5 -17
  47. package/templates/cjs/public/assets/images/logo-dark.svg +0 -12
  48. package/templates/cjs/public/assets/scripts/docs.js +0 -1
  49. package/templates/cjs/public/assets/scripts/home.js +0 -3
  50. package/templates/cjs/public/assets/styles/docs.css +0 -2200
  51. package/templates/cjs/public/assets/styles/home.css +0 -1
  52. package/templates/cjs/public/assets/styles/user.css +0 -1
  53. package/templates/cjs/public/assets/styles/users.css +0 -1
  54. package/templates/esm/public/assets/images/logo-dark.svg +0 -12
  55. package/templates/esm/public/assets/scripts/docs.js +0 -1
  56. package/templates/esm/public/assets/scripts/home.js +0 -3
  57. package/templates/esm/public/assets/styles/docs.css +0 -2200
  58. package/templates/esm/public/assets/styles/home.css +0 -1
  59. package/templates/esm/public/assets/styles/user.css +0 -1
  60. package/templates/esm/public/assets/styles/users.css +0 -1
@@ -4,38 +4,32 @@
4
4
  module.exports = {
5
5
  development: {
6
6
  username: 'root',
7
- password: null,
8
- database: 'example',
7
+ password: 'password',
8
+ database: 'mydb',
9
9
  host: 'localhost',
10
10
  port: undefined,
11
11
  dialect: 'mariadb',
12
12
  timezone: '+09:00',
13
13
  logging: false
14
- //,timezone: 'Etc/GMT-9'
15
- //,dialectOptions: {useUTC: false, timezone: 'Etc/GMT-9'}
16
14
  },
17
15
  test: {
18
16
  username: 'root',
19
- password: null,
20
- database: 'example',
17
+ password: 'password',
18
+ database: 'mydb',
21
19
  host: 'localhost',
22
20
  port: undefined,
23
21
  dialect: 'mariadb',
24
22
  timezone: '+09:00',
25
23
  logging: false
26
- //,timezone: 'Etc/GMT-9'
27
- //,dialectOptions: {useUTC: false, timezone: 'Etc/GMT-9'}
28
24
  },
29
25
  production: {
30
26
  username: 'root',
31
- password: null,
32
- database: 'example',
27
+ password: 'password',
28
+ database: 'mydb',
33
29
  host: 'localhost',
34
30
  port: undefined,
35
31
  dialect: 'mariadb',
36
32
  timezone: '+09:00',
37
33
  logging: false
38
- //,timezone: 'Etc/GMT-9'
39
- //,dialectOptions: {useUTC: false, timezone: 'Etc/GMT-9'}
40
34
  }
41
35
  }
@@ -8,7 +8,11 @@ module.exports = {
8
8
  exec_mode: 'cluster_mode',
9
9
  watch: '.',
10
10
  watch_delay: 3000,
11
- ignore_watch : ['node_modules', 'public'],
11
+ ignore_watch : [
12
+ 'node_modules',
13
+ 'public',
14
+ 'views'
15
+ ],
12
16
  watch_options: {
13
17
  followSymlinks: false,
14
18
  usePolling: true
File without changes
File without changes
@@ -1,5 +1,3 @@
1
- /*Login page CSS*/
2
-
3
1
  html, body {
4
2
  height: 100%;
5
3
  }
@@ -1,6 +1,3 @@
1
- /*Login page script*/
2
-
3
- // Main processing.
4
1
  // Form validation.
5
2
  $('#form').validate({
6
3
  validClass: 'is-valid',
File without changes
@@ -1,6 +1,3 @@
1
- /*User add/edit page script*/
2
-
3
- // Main processing.
4
1
  // Edit flag. If it is 1, edit the user, if it is 0, add the user.
5
2
  const edit = $('#edit').val() == 1;
6
3
 
File without changes
@@ -1,6 +1,3 @@
1
- /*User list page script*/
2
-
3
- // Main processing.
4
1
  // Set up data table.
5
2
  const dt = $('#table')
6
3
  .on('draw.dt', () => {
@@ -14,23 +11,28 @@ const dt = $('#table')
14
11
  // URL to get list data.
15
12
  url: '/api/users',
16
13
  // Set action column elements.
17
- dataSrc: res => res.data.map(row => Object.assign(row, {actions: ''})),
14
+ dataSrc: res => {
15
+ return res.data.map(row => Object.assign(row, {actions: ''}));
16
+ },
18
17
  // For Ajax, send a cookie.
19
- xhrFields: {withCredentials: true}
18
+ xhrFields: {
19
+ withCredentials: true
20
+ }
20
21
  },
21
22
  columns: [
22
- {data: 'id', width: 30},
23
+ {data: 'id', width: 100},
23
24
  {data: 'email'},
24
25
  {data: 'name'},
25
26
  {data: 'modified', width: 200},
26
- {data: 'actions', width: 150}
27
+ {data: 'actions', width: 200}
27
28
  ],
28
29
  columnDefs: [
29
30
  {
30
31
  targets: -1,
31
32
  orderable: false,
32
- render: (data, type, row) => `<a href="/users/${row.id}" class="btn btn-success">Edit</a>
33
- <button on-delete data-id="${row.id}" type="button" class="btn btn-danger mx-2">Delete</button>`
33
+ render: (data, type, row) =>
34
+ `<a href="/users/${row.id}" class="btn btn-success">Edit</a>
35
+ <button on-delete data-id="${row.id}" type="button" class="btn btn-danger mx-2">Delete</button>`
34
36
  }
35
37
  ],
36
38
  dom: `<'row'<'col-12'f>><'row'<'col-12'tr>><'row'<'col-12 dataTables_pager'p>>`,
@@ -3,34 +3,19 @@ const router = express.Router();
3
3
  const UserModel = require('../../models/UserModel');
4
4
  const Authentication = require('express-sweet').services.Authentication;
5
5
 
6
- /**
7
- * Login.
8
- */
6
+ // Login.
9
7
  router.post('/login', async (req, res, next) => {
10
- // Authenticate with username and password.
11
8
  const isAuthenticated = await Authentication.authenticate(req, res, next);
12
-
13
- // For asynchronous requests.Returns the authentication result and executes subsequent processing on the front end.
14
9
  res.json(isAuthenticated);
15
-
16
- // // For sync request.If the authentication is successful, you will be redirected to the authentication success page, and if it is unsuccessful, you will be redirected to the login page.
17
- // if (isAuthenticated)
18
- // Authentication.successRedirect(res);
19
- // else
20
- // Authentication.failureRedirect(res);
21
10
  });
22
11
 
23
- /**
24
- * Logout.
25
- */
12
+ // Logout.
26
13
  router.get('/logout', (req, res) => {
27
14
  Authentication.logout(req);
28
15
  res.redirect('/');
29
16
  });
30
17
 
31
- /**
32
- * List Users.
33
- */
18
+ // Get a list of users.
34
19
  router.get('/', async (req, res) => {
35
20
  const data = await UserModel.paginate({
36
21
  offset: req.query.offset,
@@ -43,9 +28,7 @@ router.get('/', async (req, res) => {
43
28
  res.json(data);
44
29
  });
45
30
 
46
- /**
47
- * Create a User.
48
- */
31
+ // Create User.
49
32
  router.post('/', async (req, res) => {
50
33
  // Email duplication check.
51
34
  const emailExists = (await UserModel.count({
@@ -69,9 +52,7 @@ router.post('/', async (req, res) => {
69
52
  res.json({id: result.id});
70
53
  });
71
54
 
72
- /**
73
- * Update a User.
74
- */
55
+ // Update User.
75
56
  router.put('/:id(\\d+)', async (req, res) => {
76
57
  // Email duplication check.
77
58
  const emailExists = (await UserModel.count({
@@ -107,16 +88,9 @@ router.put('/:id(\\d+)', async (req, res) => {
107
88
  res.json(true);
108
89
  });
109
90
 
110
- /**
111
- * Delete a User.
112
- */
91
+ // Delete user.
113
92
  router.delete('/:id(\\d+)', async (req, res) => {
114
- // Delete user data that matches the ID.
115
- await UserModel.destroy({
116
- where: {
117
- id: req.params.id
118
- }
119
- });
93
+ await UserModel.destroy({where: {id: req.params.id}});
120
94
  res.json(true);
121
95
  });
122
96
 
@@ -1,9 +1,6 @@
1
1
  const express = require('express');
2
2
  const router = express.Router();
3
3
 
4
- /**
5
- * Home page.
6
- */
7
4
  router.get('/', (req, res) => {
8
5
  res.render('home');
9
6
  });
@@ -1,9 +1,6 @@
1
1
  const express = require('express');
2
2
  const router = express.Router();
3
3
 
4
- /**
5
- * Login page.
6
- */
7
4
  router.get('/', (req, res) => {
8
5
  res.render('login');
9
6
  });
@@ -2,9 +2,7 @@ const express = require('express');
2
2
  const router = express.Router();
3
3
  const UserModel = require('../models/UserModel');
4
4
 
5
- /**
6
- * User edit page.
7
- */
5
+ // Edit User.
8
6
  router.get('/:id(\\d+)', async (req, res) => {
9
7
  // Find a user that matches your ID.
10
8
  const user = await UserModel.findByPk(req.params.id, {
@@ -20,16 +18,12 @@ router.get('/:id(\\d+)', async (req, res) => {
20
18
  res.render('user', {user, edit: true});
21
19
  });
22
20
 
23
- /**
24
- * User addition page.
25
- */
21
+ // Create User.
26
22
  router.get('/new', async (req, res) => {
27
23
  res.render('user', {edit: false});
28
24
  });
29
25
 
30
- /**
31
- * Users page.
32
- */
26
+ // User List.
33
27
  router.get('/', async (req, res) => {
34
28
  res.render('users');
35
29
  });
@@ -1,5 +1,4 @@
1
1
  {{!< default}}
2
-
3
2
  <h1>{{message}}</h1>
4
3
  <h2>{{error.status}}</h2>
5
- <pre>{{error.stack}}</pre>
4
+ <pre>{{error.stack}}</pre>
@@ -1,11 +1,5 @@
1
1
  {{!< default}}
2
2
  {{#contentFor 'title'}}Home{{/contentFor}}
3
- {{#contentFor 'style'}}
4
- <link rel="stylesheet" type="text/css" href="{{cache_busting '/assets/styles/home.css' baseUrl}}">
5
- <!-- <link rel="stylesheet" type="text/css" href="{{baseUrl}}/assets/styles/home.css"> -->
6
- {{/contentFor}}
7
- {{#contentFor 'script'}}
8
- <script src="{{cache_busting '/assets/scripts/home.js' baseUrl}}"></script>
9
- <!-- <script src="{{baseUrl}}/assets/scripts/home.js"></script> -->
10
- {{/contentFor}}
3
+ {{#contentFor 'style'}}<link rel="stylesheet" type="text/css" href="{{cache_busting '/assets/home.css' baseUrl}}">{{/contentFor}}
4
+ {{#contentFor 'script'}}<script src="{{cache_busting '/assets/home.js' baseUrl}}"></script>{{/contentFor}}
11
5
  <h1 class="mt-5 text-center">Welcome to Express Sweet</h1>
@@ -3,27 +3,25 @@
3
3
  <head>
4
4
  <meta charset="UTF-8">
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1">
6
- <title>{{{block "title"}}} | Sample</title>
7
- <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-eOJMYsd53ii+scO/bJGFsiCZc+5NDVN2yr8+0RDqr0Ql0h+rP48ckxlpbzKgwra6" crossorigin="anonymous">
8
- <link rel="stylesheet" type="text/css" href="{{cache_busting '/assets/styles/docs.css' baseUrl}}">
9
- <!-- <link rel="stylesheet" type="text/css" href="{{baseUrl}}/assets/styles/docs.css"> -->
6
+ <title>{{{block "title"}}} | Exspress Sweet Template</title>
7
+ <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
8
+ <link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.24/css/dataTables.bootstrap5.min.css">
10
9
  {{{block "style"}}}
11
10
  </head>
12
11
  <body>
13
12
  {{#if session}}
14
- <header class="navbar navbar-expand-md navbar-dark bd-navbar">
15
- <!-- <header class="navbar navbar-expand-md navbar-light bg-light"> -->
13
+ <header class="navbar navbar-expand-md navbar-light">
16
14
  <nav class="container-xxl flex-wrap flex-md-nowrap" aria-label="Main navigation">
17
- <a class="navbar-brand p-0 me-2" href="{{baseUrl}}">
18
- <img src="{{baseUrl}}/assets/images/logo-dark.svg" height="50">
15
+ <a class="navbar-brand p-0 me-2" href="/">
16
+ <img src="{{baseUrl}}/assets/logo.svg" height="32">
19
17
  </a>
20
18
  <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#bdNavbar" aria-controls="bdNavbar" aria-expanded="false" aria-label="Toggle navigation">
21
19
  <svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" class="bi" fill="currentColor" viewBox="0 0 16 16">
22
- <path fill-rule="evenodd" d="M2.5 11.5A.5.5 0 0 1 3 11h10a.5.5 0 0 1 0 1H3a.5.5 0 0 1-.5-.5zm0-4A.5.5 0 0 1 3 7h10a.5.5 0 0 1 0 1H3a.5.5 0 0 1-.5-.5zm0-4A.5.5 0 0 1 3 3h10a.5.5 0 0 1 0 1H3a.5.5 0 0 1-.5-.5z"/>
20
+ <path fill-rule="evenodd" d="M2.5 11.5A.5.5 0 0 1 3 11h10a.5.5 0 0 1 0 1H3a.5.5 0 0 1-.5-.5zm0-4A.5.5 0 0 1 3 7h10a.5.5 0 0 1 0 1H3a.5.5 0 0 1-.5-.5zm0-4A.5.5 0 0 1 3 3h10a.5.5 0 0 1 0 1H3a.5.5 0 0 1-.5-.5z"></path>
23
21
  </svg>
24
22
  </button>
25
23
  <div class="collapse navbar-collapse" id="bdNavbar">
26
- <ul class="navbar-nav flex-row flex-wrap bd-navbar-nav pt-2 py-md-0">
24
+ <ul class="navbar-nav flex-row flex-wrap pt-2 py-md-0">
27
25
  <li class="nav-item col-6 col-md-auto">
28
26
  <a class="nav-link p-2 {{#if (eq currentPath '/')}}active{{/if}}" href="{{baseUrl}}">Home</a>
29
27
  </li>
@@ -31,7 +29,7 @@
31
29
  <a class="nav-link p-2 {{#if (eq currentPath '/users')}}active{{/if}}" href="{{baseUrl}}/users">Users</a>
32
30
  </li>
33
31
  </ul>
34
- <a class="btn btn-bd-primary d-lg-inline-block my-2 my-md-0 ms-md-auto" href="{{baseUrl}}/api/users/logout">Logout</a>
32
+ <a class="my-md-0 ms-md-auto" href="{{baseUrl}}/api/users/logout">Logout</a>
35
33
  </div>
36
34
  </nav>
37
35
  </header>
@@ -41,22 +39,19 @@
41
39
  {{else}}
42
40
  {{{body}}}
43
41
  {{/if}}
44
-
45
42
  <script>
46
43
  // Application base URL.
47
44
  globalThis.baseUrl = '{{baseUrl}}';
48
-
49
45
  // User session.
50
46
  {{#if session}}
51
47
  globalThis.$$session = {{{json_stringify session}}};
52
48
  {{/if}}
53
49
  </script>
54
-
55
50
  <script src="https://code.jquery.com/jquery-3.6.0.min.js" integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"></script>
56
- <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta3/dist/js/bootstrap.bundle.min.js" integrity="sha384-JEW9xMcG8R+pH31jmWH6WWP0WintQrMb4s7ZOdauHnUtxwoG2vI5DkLtS3qm9Ekf" crossorigin="anonymous"></script>
57
- <script src="{{cache_busting '/assets/scripts/docs.js' baseUrl}}"></script>
58
- <!-- <script src="{{baseUrl}}/assets/scripts/docs.js"></script> -->
59
-
51
+ <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM" crossorigin="anonymous"></script>
52
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-validate/1.19.2/jquery.validate.min.js" integrity="sha512-UdIMMlVx0HEynClOIFSyOrPggomfhBKJE28LKl8yR3ghkgugPnG6iLfRfHwushZl1MOPSY6TsuBDGPK2X4zYKg==" crossorigin="anonymous"></script>
53
+ <script src="https://cdn.datatables.net/1.10.24/js/jquery.dataTables.min.js"></script>
54
+ <script src="https://cdn.datatables.net/1.10.24/js/dataTables.bootstrap5.min.js"></script>
60
55
  {{{block "script"}}}
61
56
  </body>
62
57
  </html>
@@ -1,23 +1,12 @@
1
1
  {{!< default}}
2
2
  {{#contentFor 'title'}}Login{{/contentFor}}
3
- {{#contentFor 'style'}}
4
- <link rel="stylesheet" type="text/css" href="{{cache_busting '/assets/styles/login.css' baseUrl}}">
5
- <!-- <link rel="stylesheet" type="text/css" href="{{baseUrl}}/assets/styles/login.css"> -->
6
- {{/contentFor}}
7
- {{#contentFor 'script'}}
8
- <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-validate/1.19.2/jquery.validate.min.js" integrity="sha512-UdIMMlVx0HEynClOIFSyOrPggomfhBKJE28LKl8yR3ghkgugPnG6iLfRfHwushZl1MOPSY6TsuBDGPK2X4zYKg==" crossorigin="anonymous"></script>
9
- <script src="{{cache_busting '/assets/scripts/login.js' baseUrl}}"></script>
10
- <!-- <script src="{{baseUrl}}/assets/scripts/login.js"></script> -->
11
- {{/contentFor}}
12
- <form id="form" class="w-100 mx-auto my-0 login-form needs-validation">
13
- <!-- <form method="post" action="/api/users/login" class="w-100 mx-auto my-0 login-form needs-validation"> -->
14
- <div class="text-center">
15
- <img class="mb-4" src="{{baseUrl}}/assets/images/logo.svg" height="100">
16
- </div>
3
+ {{#contentFor 'style'}}<link rel="stylesheet" type="text/css" href="{{cache_busting '/assets/login.css' baseUrl}}">{{/contentFor}}
4
+ {{#contentFor 'script'}}<script src="{{cache_busting '/assets/login.js' baseUrl}}"></script>{{/contentFor}}
5
+ <form id="form" class="w-100 mx-auto my-0 login-form">
17
6
  <h1 class="h3 mb-3 font-weight-normal text-center">Please login</h1>
18
7
  <div class="mb-3">
19
8
  <label class="form-label">Email address</label>
20
- <input type="email" class="form-control" name="email" required autofocus value="robin@example.com" placeholder="name@example.com">
9
+ <input type="email" class="form-control" name="email" required autofocus value="robin@example.com">
21
10
  </div>
22
11
  <div class="mb-3">
23
12
  <label class="form-label">Password</label>
@@ -1,23 +1,16 @@
1
1
  {{!< default}}
2
- {{#contentFor 'title'}}Dashboard{{/contentFor}}
3
- {{#contentFor 'style'}}
4
- <link rel="stylesheet" type="text/css" href="{{cache_busting '/assets/styles/user.css' baseUrl}}">
5
- <!-- <link rel="stylesheet" type="text/css" href="{{baseUrl}}/assets/styles/user.css"> -->
6
- {{/contentFor}}
7
- {{#contentFor 'script'}}
8
- <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-validate/1.19.2/jquery.validate.min.js" integrity="sha512-UdIMMlVx0HEynClOIFSyOrPggomfhBKJE28LKl8yR3ghkgugPnG6iLfRfHwushZl1MOPSY6TsuBDGPK2X4zYKg==" crossorigin="anonymous"></script>
9
- <script src="{{cache_busting '/assets/scripts/user.js' baseUrl}}"></script>
10
- <!-- <script src="{{baseUrl}}/assets/scripts/user.js"></script> -->
11
- {{/contentFor}}
2
+ {{#contentFor 'title'}}User Information{{/contentFor}}
3
+ {{#contentFor 'style'}}<link rel="stylesheet" type="text/css" href="{{cache_busting '/assets/user.css' baseUrl}}">{{/contentFor}}
4
+ {{#contentFor 'script'}}<script src="{{cache_busting '/assets/user.js' baseUrl}}"></script>{{/contentFor}}
12
5
  <div class="row justify-content-center">
13
6
  <div class="col-12 col-md-7">
14
- <h3 class="font-weight-bold text-dark">
15
- {{ifx edit 'Edit user:' 'New user:'}}
7
+ <h3 class="font-weight-bold">
8
+ {{ifx edit 'Edit a user' 'Create a new user'}}
16
9
  </h3>
17
10
  <form id="form">
18
11
  <div class="mb-3">
19
- <label class="form-label">Email address</label>
20
- <input type="email" class="form-control" name="email" value="{{user.email}}" required autofocus placeholder="name@example.com">
12
+ <label class="form-label">Email</label>
13
+ <input type="email" class="form-control" name="email" value="{{user.email}}" required autofocus>
21
14
  </div>
22
15
  <div class="mb-3">
23
16
  <label class="form-label">Name</label>
@@ -31,8 +24,8 @@
31
24
  {{/if}}
32
25
  </div>
33
26
  <div class="d-flex justify-content-between mt-3">
34
- <a href="{{baseUrl}}/users" class="btn btn-secondary">Return to user list</a>
35
- <button type="submit" class="btn btn-primary">Save user data</button>
27
+ <a href="{{baseUrl}}/users" class="btn btn-secondary">Back to User List</a>
28
+ <button type="submit" class="btn btn-primary">Save user information</button>
36
29
  </div>
37
30
  </form>
38
31
  </div>
@@ -1,26 +1,14 @@
1
1
  {{!< default}}
2
- {{#contentFor 'title'}}Dashboard{{/contentFor}}
3
- {{#contentFor 'style'}}
4
- <link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.24/css/dataTables.bootstrap5.min.css">
5
- <link rel="stylesheet" type="text/css" href="{{cache_busting '/assets/styles/users.css' baseUrl}}">
6
- <!-- <link rel="stylesheet" type="text/css" href="{{baseUrl}}/assets/styles/users.css"> -->
7
- {{/contentFor}}
8
- {{#contentFor 'script'}}
9
- <script src="https://cdn.datatables.net/1.10.24/js/jquery.dataTables.min.js"></script>
10
- <script src="https://cdn.datatables.net/1.10.24/js/dataTables.bootstrap5.min.js"></script>
11
- <script src="{{cache_busting '/assets/scripts/users.js' baseUrl}}"></script>
12
- <!-- <script src="{{baseUrl}}/assets/scripts/users.js"></script> -->
13
- {{/contentFor}}
14
-
2
+ {{#contentFor 'title'}}User Management{{/contentFor}}
3
+ {{#contentFor 'style'}}<link rel="stylesheet" type="text/css" href="{{cache_busting '/assets/users.css' baseUrl}}">{{/contentFor}}
4
+ {{#contentFor 'script'}}<script src="{{cache_busting '/assets/users.js' baseUrl}}"></script>{{/contentFor}}
15
5
  <div class="d-flex mb-4">
16
- <h3 class="font-weight-bold text-dark">User list:</h3>
17
- <a href="/users/new" class="btn btn-primary" style="margin-left: auto;">Add New</a>
6
+ <a href="/users/new" class="btn btn-primary ms-auto">Create new user</a>
18
7
  </div>
19
-
20
8
  <table class="table w-100" id="table">
21
9
  <thead>
22
10
  <tr>
23
- <th scope="col">ID</th>
11
+ <th scope="col">User ID</th>
24
12
  <th scope="col">Email</th>
25
13
  <th scope="col">Name</th>
26
14
  <th scope="col">Modified</th>
@@ -4,38 +4,32 @@
4
4
  export default {
5
5
  development: {
6
6
  username: 'root',
7
- password: null,
8
- database: 'example',
7
+ password: 'password',
8
+ database: 'mydb',
9
9
  host: 'localhost',
10
10
  port: undefined,
11
11
  dialect: 'mariadb',
12
12
  timezone: '+09:00',
13
13
  logging: false
14
- //,timezone: 'Etc/GMT-9'
15
- //,dialectOptions: {useUTC: false, timezone: 'Etc/GMT-9'}
16
14
  },
17
15
  test: {
18
16
  username: 'root',
19
- password: null,
20
- database: 'example',
17
+ password: 'password',
18
+ database: 'mydb',
21
19
  host: 'localhost',
22
20
  port: undefined,
23
21
  dialect: 'mariadb',
24
22
  timezone: '+09:00',
25
23
  logging: false
26
- //,timezone: 'Etc/GMT-9'
27
- //,dialectOptions: {useUTC: false, timezone: 'Etc/GMT-9'}
28
24
  },
29
25
  production: {
30
26
  username: 'root',
31
- password: null,
32
- database: 'example',
27
+ password: 'password',
28
+ database: 'mydb',
33
29
  host: 'localhost',
34
30
  port: undefined,
35
31
  dialect: 'mariadb',
36
32
  timezone: '+09:00',
37
33
  logging: false
38
- //,timezone: 'Etc/GMT-9'
39
- //,dialectOptions: {useUTC: false, timezone: 'Etc/GMT-9'}
40
34
  }
41
35
  }
@@ -9,7 +9,11 @@ module.exports = {
9
9
  exec_mode: 'cluster_mode',
10
10
  watch: '.',
11
11
  watch_delay: 3000,
12
- ignore_watch : ['node_modules', 'public'],
12
+ ignore_watch : [
13
+ 'node_modules',
14
+ 'public',
15
+ 'views'
16
+ ],
13
17
  watch_options: {
14
18
  followSymlinks: false,
15
19
  usePolling: true
File without changes
File without changes
@@ -1,5 +1,3 @@
1
- /*Login page CSS*/
2
-
3
1
  html, body {
4
2
  height: 100%;
5
3
  }
@@ -1,6 +1,3 @@
1
- /*Login page script*/
2
-
3
- // Main processing.
4
1
  // Form validation.
5
2
  $('#form').validate({
6
3
  validClass: 'is-valid',
File without changes
@@ -1,6 +1,3 @@
1
- /*User add/edit page script*/
2
-
3
- // Main processing.
4
1
  // Edit flag. If it is 1, edit the user, if it is 0, add the user.
5
2
  const edit = $('#edit').val() == 1;
6
3
 
File without changes
@@ -1,6 +1,3 @@
1
- /*User list page script*/
2
-
3
- // Main processing.
4
1
  // Set up data table.
5
2
  const dt = $('#table')
6
3
  .on('draw.dt', () => {
@@ -14,23 +11,28 @@ const dt = $('#table')
14
11
  // URL to get list data.
15
12
  url: '/api/users',
16
13
  // Set action column elements.
17
- dataSrc: res => res.data.map(row => Object.assign(row, {actions: ''})),
14
+ dataSrc: res => {
15
+ return res.data.map(row => Object.assign(row, {actions: ''}));
16
+ },
18
17
  // For Ajax, send a cookie.
19
- xhrFields: {withCredentials: true}
18
+ xhrFields: {
19
+ withCredentials: true
20
+ }
20
21
  },
21
22
  columns: [
22
- {data: 'id', width: 30},
23
+ {data: 'id', width: 100},
23
24
  {data: 'email'},
24
25
  {data: 'name'},
25
26
  {data: 'modified', width: 200},
26
- {data: 'actions', width: 150}
27
+ {data: 'actions', width: 200}
27
28
  ],
28
29
  columnDefs: [
29
30
  {
30
31
  targets: -1,
31
32
  orderable: false,
32
- render: (data, type, row) => `<a href="/users/${row.id}" class="btn btn-success">Edit</a>
33
- <button on-delete data-id="${row.id}" type="button" class="btn btn-danger mx-2">Delete</button>`
33
+ render: (data, type, row) =>
34
+ `<a href="/users/${row.id}" class="btn btn-success">Edit</a>
35
+ <button on-delete data-id="${row.id}" type="button" class="btn btn-danger mx-2">Delete</button>`
34
36
  }
35
37
  ],
36
38
  dom: `<'row'<'col-12'f>><'row'<'col-12'tr>><'row'<'col-12 dataTables_pager'p>>`,