express-sweet-generator 2.0.2 → 2.0.4

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 (77) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +170 -9
  3. package/package.json +2 -3
  4. package/screencaps/demonstration.webp +0 -0
  5. package/templates/cjs/app.js +2 -2
  6. package/templates/cjs/config/authentication.js +0 -1
  7. package/templates/cjs/config/config.js +1 -4
  8. package/templates/cjs/config/database.js +3 -3
  9. package/templates/cjs/config/view.js +0 -1
  10. package/templates/cjs/models/BookModel.js +2 -2
  11. package/templates/cjs/models/CommentModel.js +2 -2
  12. package/templates/cjs/models/ProfileModel.js +2 -2
  13. package/templates/cjs/models/UserModel.js +2 -2
  14. package/templates/cjs/package.json.ejs +1 -1
  15. package/templates/cjs/public/build/editPersonal.js +54 -2
  16. package/templates/cjs/public/build/login.js +54 -2
  17. package/templates/cjs/public/build/users.js +163 -4
  18. package/templates/cjs/routes/api/users.js +4 -4
  19. package/templates/cjs/routes/login.js +1 -1
  20. package/templates/cjs/routes/users.js +2 -2
  21. package/templates/client/src/api/UserApi.js +1 -1
  22. package/templates/client/src/{pages/editPersonal.js → editPersonal.js} +1 -1
  23. package/templates/client/src/{pages/login.js → login.js} +1 -1
  24. package/templates/client/src/shared/Api.js +51 -0
  25. package/templates/client/src/shared/Datatable.js +104 -0
  26. package/templates/client/src/{pages/users.js → users.js} +4 -3
  27. package/templates/client/webpack.config.js +3 -3
  28. package/templates/esm/app.js +2 -2
  29. package/templates/esm/bin/www.ejs +1 -1
  30. package/templates/esm/config/authentication.js +1 -2
  31. package/templates/esm/config/config.js +2 -5
  32. package/templates/esm/config/database.js +3 -3
  33. package/templates/esm/config/view.js +1 -2
  34. package/templates/esm/ecosystem.config.js.ejs +0 -2
  35. package/templates/esm/models/BookModel.js +2 -2
  36. package/templates/esm/models/CommentModel.js +2 -2
  37. package/templates/esm/models/ProfileModel.js +3 -3
  38. package/templates/esm/models/UserModel.js +6 -6
  39. package/templates/esm/package.json.ejs +4 -6
  40. package/templates/esm/public/build/editPersonal.js +54 -2
  41. package/templates/esm/public/build/login.js +54 -2
  42. package/templates/esm/public/build/users.js +163 -4
  43. package/templates/esm/routes/api/users.js +6 -7
  44. package/templates/esm/routes/login.js +1 -1
  45. package/templates/esm/routes/users.js +2 -2
  46. package/templates/esm/shared/CustomValidation.js +1 -1
  47. package/QUICK_START.md +0 -158
  48. package/screencaps/login.jpg +0 -0
  49. package/screencaps/personal.jpg +0 -0
  50. package/screencaps/user-editing.jpg +0 -0
  51. package/screencaps/users.jpg +0 -0
  52. package/templates/cjs/public/build/theme/js/custom/authentication/sign-in/two-steps.js +0 -140
  53. package/templates/cjs/public/build/theme/js/custom/pages/user-profile/followers.js +0 -97
  54. package/templates/cjs/public/build/theme/js/custom/utilities/modals/create-project.js +0 -0
  55. package/templates/cjs/public/build/theme/plugins/global/fonts/fonticon/fonticon.css +0 -1
  56. package/templates/cjs/public/build/theme/plugins/global/fonts/fonticon/fonticon.eot +0 -0
  57. package/templates/cjs/public/build/theme/plugins/global/fonts/fonticon/fonticon.html +0 -1253
  58. package/templates/cjs/public/build/theme/plugins/global/fonts/fonticon/fonticon.scss +0 -361
  59. package/templates/cjs/public/build/theme/plugins/global/fonts/fonticon/fonticon.svg +0 -264
  60. package/templates/cjs/public/build/theme/plugins/global/fonts/fonticon/fonticon.ttf +0 -0
  61. package/templates/cjs/public/build/theme/plugins/global/fonts/fonticon/fonticon.woff +0 -0
  62. package/templates/cjs/public/build/theme/plugins/global/fonts/fonticon/fonticon.woff2 +0 -0
  63. package/templates/esm/public/build/theme/js/custom/authentication/sign-in/two-steps.js +0 -140
  64. package/templates/esm/public/build/theme/js/custom/pages/user-profile/followers.js +0 -97
  65. package/templates/esm/public/build/theme/js/custom/utilities/modals/create-project.js +0 -0
  66. package/templates/esm/public/build/theme/plugins/global/fonts/fonticon/fonticon.css +0 -1
  67. package/templates/esm/public/build/theme/plugins/global/fonts/fonticon/fonticon.eot +0 -0
  68. package/templates/esm/public/build/theme/plugins/global/fonts/fonticon/fonticon.html +0 -1253
  69. package/templates/esm/public/build/theme/plugins/global/fonts/fonticon/fonticon.scss +0 -361
  70. package/templates/esm/public/build/theme/plugins/global/fonts/fonticon/fonticon.svg +0 -264
  71. package/templates/esm/public/build/theme/plugins/global/fonts/fonticon/fonticon.ttf +0 -0
  72. package/templates/esm/public/build/theme/plugins/global/fonts/fonticon/fonticon.woff +0 -0
  73. package/templates/esm/public/build/theme/plugins/global/fonts/fonticon/fonticon.woff2 +0 -0
  74. /package/templates/client/src/{pages/editPersonal.css → editPersonal.css} +0 -0
  75. /package/templates/client/src/{pages/login.css → login.css} +0 -0
  76. /package/templates/client/src/{pages → modals}/UserModal.js +0 -0
  77. /package/templates/client/src/{pages/users.css → users.css} +0 -0
@@ -156,10 +156,168 @@ var build = __webpack_require__(776);
156
156
  var build_default = /*#__PURE__*/__webpack_require__.n(build);
157
157
  // EXTERNAL MODULE: ./node_modules/metronic-extension/dist/build.js
158
158
  var dist_build = __webpack_require__(236);
159
+ ;// CONCATENATED MODULE: ./src/shared/Datatable.js
160
+
161
+
162
+ /**
163
+ * Custom DataTable class extending Metronic's Datatable component.
164
+ */
165
+ /* harmony default export */ const Datatable = (class extends dist_build.components.Datatable {
166
+ /**
167
+ * Initializes the DataTable with custom options.
168
+ * @param {string|HTMLTableElement|JQuery} table The table element selector, DOM element, or jQuery object.
169
+ * @param {object} options The DataTable options.
170
+ */
171
+ constructor(table, options) {
172
+ // Initialize options with default values.
173
+ options = Object.assign({
174
+ // Option to show the column visibility toggle button.
175
+ columnVisibility: false,
176
+
177
+ // Selector for columns to be visible by default.
178
+ visibleColumns: undefined,
179
+ }, options);
180
+
181
+ if (options.columnVisibility) {
182
+ // If column visibility option is enabled.
183
+ // Place the column visibility toggle button in the DOM.
184
+ options.dom = `<'row align-items-center'<'col dataTables_pager'p><'col-auto'B>><'row'<'col-12'tr>><'row'<'col-12 dataTables_pager'p>>`;
185
+
186
+ // Add the column visibility toggle button.
187
+ options.buttons = {
188
+ dom: {
189
+ button: {
190
+ className: null,
191
+ },
192
+ buttonLiner: {
193
+ tag: null,
194
+ },
195
+ },
196
+ buttons: [
197
+ {
198
+ extend: 'colvis',
199
+ columns: options.visibleColumns,
200
+ text: '<i class="ki-solid ki-gear fs-1"></i>',
201
+ // className: 'btn btn-sm btn-icon btn-color-primary btn-active-light-primary',
202
+ className: 'btn btn-icon btn-color-gray-500 btn-active-color-primary',
203
+ align: 'container',
204
+ },
205
+ ],
206
+ };
207
+
208
+ // Remove custom options as they are no longer needed.
209
+ delete options.columnVisibility;
210
+ delete options.visibleColumns;
211
+ }
212
+
213
+ /**
214
+ * Generates a unique state key for the DataTable.
215
+ * @param {object} settings DataTables settings object.
216
+ * @return {string} The generated state key.
217
+ */
218
+ const getStateKey = (settings) => {
219
+ let stateKey = settings.sTableId;
220
+ stateKey += '_';
221
+ stateKey += location.pathname;
222
+ if (settings.nTable.getAttribute('data-ref')) {
223
+ stateKey += '/_';
224
+ stateKey += settings.nTable.getAttribute('data-ref');
225
+ }
226
+ return stateKey;
227
+ };
228
+
229
+
230
+ // // Set locale to Japanese.
231
+ // options.locale = 'ja';
232
+
233
+ // Save sorting criteria.
234
+ options.stateSave = true;
235
+ options.stateSaveCallback = (settings, data) => {
236
+ // Save state with a name that doesn't conflict with other tables.
237
+ localStorage.setItem(getStateKey(settings), JSON.stringify(data));
238
+ };
239
+ options.stateLoadCallback = (settings) => {
240
+ // Return the saved state.
241
+ return JSON.parse(localStorage.getItem(getStateKey(settings)));
242
+ };
243
+ options.stateSaveParams = (settings, data) => {
244
+ // Don't save search criteria and offset.
245
+ delete data.search;
246
+ delete data.start;
247
+ };
248
+
249
+ super(table, options);
250
+ }
251
+
252
+ /**
253
+ * Handles AJAX errors.
254
+ * @param {number} code The HTTP status code of the error.
255
+ * @return {void}
256
+ */
257
+ ajaxErrorHook(code) {
258
+ if (code === 401) {
259
+ // Redirect to login page if authentication error occurs.
260
+ location.replace('/');
261
+ }
262
+ }
263
+ });
264
+
265
+ ;// CONCATENATED MODULE: ./src/shared/Api.js
266
+
267
+
268
+ /**
269
+ * Base API client class.
270
+ */
271
+ /* harmony default export */ const Api = (class extends dist_build.components.Api {
272
+ /**
273
+ * Initializes the API client.
274
+ * @param {string} path The base URL for requests.
275
+ */
276
+ constructor(path) {
277
+ super(path, null, {
278
+ headers: {
279
+ // Indicate an AJAX request to the server.
280
+ 'X-Requested-With': 'XMLHttpRequest',
281
+ },
282
+ });
283
+ }
284
+
285
+ // /**
286
+ // * Initializes the API client.
287
+ // * @param {string} path The base URL for requests.
288
+ // * @param {string} [origin] The origin for requests.
289
+ // * @param {import('axios').AxiosRequestConfig} [options] Additional options for the Axios instance.
290
+ // */
291
+ // constructor(path, origin, options) {
292
+ // super(path, origin, Object.assign({}, {
293
+ // headers: {
294
+ // // Indicate an AJAX request to the server.
295
+ // 'X-Requested-With': 'XMLHttpRequest',
296
+ // },
297
+ // }, options));
298
+ // }
299
+
300
+ /**
301
+ * Handles API errors.
302
+ * @param {number} code The HTTP status code.
303
+ * @param {Error} err The error object.
304
+ * @return {void}
305
+ */
306
+ errorHook(code, err) {
307
+ // Check if the error object and request properties exist to avoid runtime errors
308
+ if (err && err.request && err.request.responseURL) {
309
+ const {pathname} = new URL(err.request.responseURL);
310
+ if (pathname !== '/api/users/login' && code === 401) {
311
+ // Redirect to the login page if an authentication error occurs on a non-login request.
312
+ location.replace('/');
313
+ }
314
+ }
315
+ }
316
+ });
159
317
  ;// CONCATENATED MODULE: ./src/api/UserApi.js
160
318
 
161
319
 
162
- /* harmony default export */ const UserApi = (class extends dist_build.components.Api {
320
+ /* harmony default export */ const UserApi = (class extends components.Api {
163
321
  constructor() {
164
322
  super('/api/users');
165
323
  }
@@ -192,7 +350,7 @@ var dist_build = __webpack_require__(236);
192
350
  return this.client.put('/profile', formData);
193
351
  }
194
352
  });
195
- ;// CONCATENATED MODULE: ./src/pages/UserModal.js
353
+ ;// CONCATENATED MODULE: ./src/modals/UserModal.js
196
354
 
197
355
 
198
356
 
@@ -552,7 +710,8 @@ var dist_build = __webpack_require__(236);
552
710
  dist_build.components.Dialog.close();
553
711
  }
554
712
  });
555
- ;// CONCATENATED MODULE: ./src/pages/users.js
713
+ ;// CONCATENATED MODULE: ./src/users.js
714
+
556
715
 
557
716
 
558
717
 
@@ -560,7 +719,7 @@ var dist_build = __webpack_require__(236);
560
719
 
561
720
 
562
721
  function initTable() {
563
- userTable = new dist_build.components.Datatable(ref.userTable, {
722
+ userTable = new Datatable(ref.userTable, {
564
723
  ajax: {
565
724
  url: '/api/users',
566
725
  data: d => {
@@ -1,11 +1,11 @@
1
1
  const express = require('express');
2
- const Authentication = require('express-sweet').services.Authentication;
2
+ const expressExtension = require('express-sweet');
3
3
  const {query, body, validationResult} = require('express-validator');
4
- const router = express.Router();
5
4
  const UserModel = require('../../models/UserModel');
6
5
  const UserNotFound = require('../../exceptions/UserNotFound');
7
6
  const CustomValidation = require('../../shared/CustomValidation');
8
7
 
8
+ const router = express.Router();
9
9
  router.post('/login', [
10
10
  body('email').trim().not().isEmpty().isEmail(),
11
11
  body('password').trim().not().isEmpty()
@@ -13,12 +13,12 @@ router.post('/login', [
13
13
  const errs = validationResult(req);
14
14
  if (!errs.isEmpty())
15
15
  return void res.status(400).json({errors: errs.array()});
16
- const isAuthenticated = await Authentication.authenticate(req, res, next);
16
+ const isAuthenticated = await expressExtension.services.Authentication.authenticate(req, res, next);
17
17
  res.json(isAuthenticated);
18
18
  });
19
19
 
20
20
  router.get('/logout', (req, res) => {
21
- Authentication.logout(req);
21
+ expressExtension.services.Authentication.logout(req);
22
22
  res.redirect('/');
23
23
  });
24
24
 
@@ -1,6 +1,6 @@
1
1
  const express = require('express');
2
- const router = express.Router();
3
2
 
3
+ const router = express.Router();
4
4
  router.get('/', (req, res) => {
5
5
  res.render('login');
6
6
  });
@@ -1,8 +1,8 @@
1
1
  const express = require('express');
2
- const router = express.Router();
3
2
  const UserModel = require('../models/UserModel');
4
3
 
5
- router.get('/', async (req, res) => {
4
+ const router = express.Router();
5
+ router.get('/', (req, res) => {
6
6
  res.render('users');
7
7
  });
8
8
 
@@ -1,4 +1,4 @@
1
- import {components} from 'metronic-extension';
1
+ import Api from '~/shared/Api';
2
2
 
3
3
  export default class extends components.Api {
4
4
  constructor() {
@@ -1,4 +1,4 @@
1
- import '~/pages/editPersonal.css';
1
+ import '~/editPersonal.css';
2
2
  import {components, utils} from 'metronic-extension';
3
3
  import UserApi from '~/api/UserApi';
4
4
 
@@ -1,4 +1,4 @@
1
- import '~/pages/login.css';
1
+ import '~/login.css';
2
2
  import {components} from 'metronic-extension';
3
3
  import UserApi from '~/api/UserApi';
4
4
 
@@ -0,0 +1,51 @@
1
+ import {components} from 'metronic-extension';
2
+
3
+ /**
4
+ * Base API client class.
5
+ */
6
+ export default class extends components.Api {
7
+ /**
8
+ * Initializes the API client.
9
+ * @param {string} path The base URL for requests.
10
+ */
11
+ constructor(path) {
12
+ super(path, null, {
13
+ headers: {
14
+ // Indicate an AJAX request to the server.
15
+ 'X-Requested-With': 'XMLHttpRequest',
16
+ },
17
+ });
18
+ }
19
+
20
+ // /**
21
+ // * Initializes the API client.
22
+ // * @param {string} path The base URL for requests.
23
+ // * @param {string} [origin] The origin for requests.
24
+ // * @param {import('axios').AxiosRequestConfig} [options] Additional options for the Axios instance.
25
+ // */
26
+ // constructor(path, origin, options) {
27
+ // super(path, origin, Object.assign({}, {
28
+ // headers: {
29
+ // // Indicate an AJAX request to the server.
30
+ // 'X-Requested-With': 'XMLHttpRequest',
31
+ // },
32
+ // }, options));
33
+ // }
34
+
35
+ /**
36
+ * Handles API errors.
37
+ * @param {number} code The HTTP status code.
38
+ * @param {Error} err The error object.
39
+ * @return {void}
40
+ */
41
+ errorHook(code, err) {
42
+ // Check if the error object and request properties exist to avoid runtime errors
43
+ if (err && err.request && err.request.responseURL) {
44
+ const {pathname} = new URL(err.request.responseURL);
45
+ if (pathname !== '/api/users/login' && code === 401) {
46
+ // Redirect to the login page if an authentication error occurs on a non-login request.
47
+ location.replace('/');
48
+ }
49
+ }
50
+ }
51
+ }
@@ -0,0 +1,104 @@
1
+ import {components} from 'metronic-extension';
2
+
3
+ /**
4
+ * Custom DataTable class extending Metronic's Datatable component.
5
+ */
6
+ export default class extends components.Datatable {
7
+ /**
8
+ * Initializes the DataTable with custom options.
9
+ * @param {string|HTMLTableElement|JQuery} table The table element selector, DOM element, or jQuery object.
10
+ * @param {object} options The DataTable options.
11
+ */
12
+ constructor(table, options) {
13
+ // Initialize options with default values.
14
+ options = Object.assign({
15
+ // Option to show the column visibility toggle button.
16
+ columnVisibility: false,
17
+
18
+ // Selector for columns to be visible by default.
19
+ visibleColumns: undefined,
20
+ }, options);
21
+
22
+ if (options.columnVisibility) {
23
+ // If column visibility option is enabled.
24
+ // Place the column visibility toggle button in the DOM.
25
+ options.dom = `<'row align-items-center'<'col dataTables_pager'p><'col-auto'B>><'row'<'col-12'tr>><'row'<'col-12 dataTables_pager'p>>`;
26
+
27
+ // Add the column visibility toggle button.
28
+ options.buttons = {
29
+ dom: {
30
+ button: {
31
+ className: null,
32
+ },
33
+ buttonLiner: {
34
+ tag: null,
35
+ },
36
+ },
37
+ buttons: [
38
+ {
39
+ extend: 'colvis',
40
+ columns: options.visibleColumns,
41
+ text: '<i class="ki-solid ki-gear fs-1"></i>',
42
+ // className: 'btn btn-sm btn-icon btn-color-primary btn-active-light-primary',
43
+ className: 'btn btn-icon btn-color-gray-500 btn-active-color-primary',
44
+ align: 'container',
45
+ },
46
+ ],
47
+ };
48
+
49
+ // Remove custom options as they are no longer needed.
50
+ delete options.columnVisibility;
51
+ delete options.visibleColumns;
52
+ }
53
+
54
+ /**
55
+ * Generates a unique state key for the DataTable.
56
+ * @param {object} settings DataTables settings object.
57
+ * @return {string} The generated state key.
58
+ */
59
+ const getStateKey = (settings) => {
60
+ let stateKey = settings.sTableId;
61
+ stateKey += '_';
62
+ stateKey += location.pathname;
63
+ if (settings.nTable.getAttribute('data-ref')) {
64
+ stateKey += '/_';
65
+ stateKey += settings.nTable.getAttribute('data-ref');
66
+ }
67
+ return stateKey;
68
+ };
69
+
70
+
71
+ // // Set locale to Japanese.
72
+ // options.locale = 'ja';
73
+
74
+ // Save sorting criteria.
75
+ options.stateSave = true;
76
+ options.stateSaveCallback = (settings, data) => {
77
+ // Save state with a name that doesn't conflict with other tables.
78
+ localStorage.setItem(getStateKey(settings), JSON.stringify(data));
79
+ };
80
+ options.stateLoadCallback = (settings) => {
81
+ // Return the saved state.
82
+ return JSON.parse(localStorage.getItem(getStateKey(settings)));
83
+ };
84
+ options.stateSaveParams = (settings, data) => {
85
+ // Don't save search criteria and offset.
86
+ delete data.search;
87
+ delete data.start;
88
+ };
89
+
90
+ super(table, options);
91
+ }
92
+
93
+ /**
94
+ * Handles AJAX errors.
95
+ * @param {number} code The HTTP status code of the error.
96
+ * @return {void}
97
+ */
98
+ ajaxErrorHook(code) {
99
+ if (code === 401) {
100
+ // Redirect to login page if authentication error occurs.
101
+ location.replace('/');
102
+ }
103
+ }
104
+ }
@@ -1,11 +1,12 @@
1
- import '~/pages/users.css';
1
+ import '~/users.css';
2
2
  import hbs from 'handlebars-extd';
3
3
  import {components} from 'metronic-extension';
4
+ import Datatable from '~/shared/Datatable';
4
5
  import UserApi from '~/api/UserApi';
5
- import UserModal from '~/pages/UserModal';
6
+ import UserModal from '~/modals/UserModal';
6
7
 
7
8
  function initTable() {
8
- userTable = new components.Datatable(ref.userTable, {
9
+ userTable = new Datatable(ref.userTable, {
9
10
  ajax: {
10
11
  url: '/api/users',
11
12
  data: d => {
@@ -15,9 +15,9 @@ module.exports = {
15
15
  },
16
16
  entry: {
17
17
  app: './src/app.js',
18
- login: './src/pages/login.js',
19
- users: './src/pages/users.js',
20
- editPersonal: './src/pages/editPersonal.js'
18
+ login: './src/login.js',
19
+ users: './src/users.js',
20
+ editPersonal: './src/editPersonal.js'
21
21
  },
22
22
  output: {
23
23
  path: path.resolve(__dirname, '../public/build'),
@@ -1,10 +1,10 @@
1
1
  import express from 'express'
2
- import * as sweet from 'express-sweet';
2
+ import * as expressExtension from 'express-sweet';
3
3
 
4
4
  // Creates and configures an ExpressJS web server.
5
5
  const app = express();
6
6
 
7
7
  // Mount the extension.
8
- sweet.mount(app);
8
+ expressExtension.mount(app);
9
9
 
10
10
  export default app;
@@ -4,7 +4,7 @@
4
4
  */
5
5
  import Debug from 'debug';
6
6
  import http from 'http';
7
- import app from '../app';
7
+ import app from '../app.js';
8
8
 
9
9
  /**
10
10
  * Normalize a port into a number, string, or false.
@@ -1,4 +1,4 @@
1
- import UserModel from '../models/UserModel';
1
+ import UserModel from '../models/UserModel.js';
2
2
 
3
3
  /**
4
4
  * User authentication configuration interface.
@@ -66,7 +66,6 @@ export default {
66
66
 
67
67
  /**
68
68
  * URL to redirect after log off, defaults to `/login`.
69
- *
70
69
  * @example
71
70
  * // Set the URL to redirect to in case of login failure as a string.
72
71
  * failure_redirect: '/login',
@@ -1,7 +1,7 @@
1
- import path from 'path';
1
+ import path from 'node:path';
2
2
 
3
3
  /**
4
- * Express Sweet basic configuration interface.
4
+ * EXPRESS SWEET basic configuration interface.
5
5
  */
6
6
  export default {
7
7
  /**
@@ -38,7 +38,6 @@ export default {
38
38
  * This is a hook that rewrites the base URL.
39
39
  * If you want to rewrite the app.locals.baseUrl property and the view's baseUrl variable, use this hook to return a new base URL.
40
40
  * The default value is the referrer's origin (eg https://example.com).
41
- *
42
41
  * @example
43
42
  * rewrite_base_url: baseUrl => {
44
43
  * return `${baseUrl}/admin`;
@@ -54,7 +53,6 @@ export default {
54
53
  * How to determine if it is an ajax request.
55
54
  * The default is that if there is an XMLHttpRequest in the request header (req.xhr) returns true.
56
55
  * For example, if there is no XMLHttpRequest in req(express.Request) and the Ajax endpoint starts with /api, a custom Ajax decision can be made like "return /^\/api\//.test(req.path)".
57
- *
58
56
  * @type {(req: express.Request) => boolean}
59
57
  * @example
60
58
  * is_ajax: req => {
@@ -68,7 +66,6 @@ export default {
68
66
  /**
69
67
  * Hooks the default behavior on request errors.
70
68
  * If unset, simply returns an error HTTP status. (<code>res.status(err.status||500).end();</code>)
71
- *
72
69
  * @type {(err: any, req: express.Request, res: express.Response, next: express.NextFunction) => void}
73
70
  * @example
74
71
  * hook_handle_error: (err, req, res, next) => {
@@ -5,7 +5,7 @@ export default {
5
5
  development: {
6
6
  username: 'root',
7
7
  password: 'password',
8
- database: 'express_sweet_db',
8
+ database: 'sample_db',
9
9
  host: 'localhost',
10
10
  port: undefined,
11
11
  dialect: 'mariadb',
@@ -15,7 +15,7 @@ export default {
15
15
  test: {
16
16
  username: 'root',
17
17
  password: 'password',
18
- database: 'express_sweet_db',
18
+ database: 'sample_db',
19
19
  host: 'localhost',
20
20
  port: undefined,
21
21
  dialect: 'mariadb',
@@ -25,7 +25,7 @@ export default {
25
25
  production: {
26
26
  username: 'root',
27
27
  password: 'password',
28
- database: 'express_sweet_db',
28
+ database: 'sample_db',
29
29
  host: 'localhost',
30
30
  port: undefined,
31
31
  dialect: 'mariadb',
@@ -1,4 +1,4 @@
1
- import path from 'path';
1
+ import path from 'node:path';
2
2
 
3
3
  /**
4
4
  * View's configuration interface.
@@ -37,7 +37,6 @@ export default {
37
37
  /**
38
38
  * Hook function just before the view is rendered.
39
39
  * For example, you can set your own local variables that can be used within the view.
40
- *
41
40
  * @example
42
41
  * // The message set here can be referenced in the view as {{message}}.
43
42
  * beforeRender: (req, res) => {
@@ -5,8 +5,6 @@ module.exports = {
5
5
  {
6
6
  name: '<%- name %>',
7
7
  script: 'bin/www',
8
- node_args: '-r esm-wallaby',
9
- // node_args: '-r esm',
10
8
  exec_mode: 'cluster_mode',
11
9
  watch: '.',
12
10
  watch_delay: 3000,
@@ -1,6 +1,6 @@
1
- import * as sweet from 'express-sweet';
1
+ import * as expressExtension from 'express-sweet';
2
2
 
3
- export default class extends sweet.database.Model {
3
+ export default class extends expressExtension.database.Model {
4
4
  static get table() {
5
5
  return 'book';
6
6
  }
@@ -1,6 +1,6 @@
1
- import * as sweet from 'express-sweet';
1
+ import * as expressExtension from 'express-sweet';
2
2
 
3
- export default class extends sweet.database.Model {
3
+ export default class extends expressExtension.database.Model {
4
4
  static get table() {
5
5
  return 'comment';
6
6
  }
@@ -1,7 +1,7 @@
1
- import * as sweet from 'express-sweet';
2
- import UserModel from './UserModel';
1
+ import * as expressExtension from 'express-sweet';
2
+ import UserModel from './UserModel.js';
3
3
 
4
- export default class extends sweet.database.Model {
4
+ export default class extends expressExtension.database.Model {
5
5
  static get table() {
6
6
  return 'profile';
7
7
  }
@@ -1,11 +1,11 @@
1
+ import * as expressExtension from 'express-sweet';
1
2
  import {Media} from 'nodejs-shared';
2
- import * as sweet from 'express-sweet';
3
- import UserNotFound from '../exceptions/UserNotFound';
4
- import ProfileModel from './ProfileModel';
5
- import CommentModel from './CommentModel';
6
- import BookModel from './BookModel';
3
+ import UserNotFound from '../exceptions/UserNotFound.js';
4
+ import ProfileModel from './ProfileModel.js';
5
+ import CommentModel from './CommentModel.js';
6
+ import BookModel from './BookModel.js';
7
7
 
8
- export default class extends sweet.database.Model {
8
+ export default class extends expressExtension.database.Model {
9
9
  static get table() {
10
10
  return 'user';
11
11
  }
@@ -1,19 +1,17 @@
1
1
  {
2
2
  "name": "<%- name %>",
3
3
  "version": "1.0.0",
4
+ "type": "module",
4
5
  "scripts": {
5
- "start": "nodemon -r esm-wallaby --ignore client/ --ignore public/ --ignore views/ bin/www",
6
- "//start": "nodemon -r esm --ignore client/ --ignore public/ --ignore views/ bin/www",
7
- "////start": "pm2 start ecosystem.config.js",
6
+ "start": "nodemon --ignore client/ --ignore public/ --ignore views/ bin/www",
7
+ "//start": "pm2 start ecosystem.config.js",
8
8
  "//restart": "pm2 restart ecosystem.config.js",
9
9
  "//stop": "pm2 stop ecosystem.config.js"
10
10
  },
11
11
  "dependencies": {
12
12
  "debug": "~2.6.9",
13
- "esm": "^3.2.25",
14
- "esm-wallaby": "^3.2.26",
15
13
  "express": "^4.19.2",
16
- "express-sweet": "^2.0.2",
14
+ "express-sweet": "^2.0.3",
17
15
  "express-validator": "^6.14.2",
18
16
  "http-errors": "~1.6.3",
19
17
  "nodejs-shared": "^1.0.28"