@vulkano/core 1.5.4 → 1.6.0

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.
@@ -333,6 +333,7 @@ module.exports = function loadServer() {
333
333
  let pathToRoute;
334
334
  let handler;
335
335
 
336
+ // Routes from convention (controller name & method = route)
336
337
  Object.keys(routes).forEach((route) => {
337
338
 
338
339
  const parts = route.split(' ');
@@ -358,45 +359,66 @@ module.exports = function loadServer() {
358
359
 
359
360
  });
360
361
 
362
+ // Routes from config/routes.js
361
363
  Object.keys(this.routes || {}).forEach((i) => {
362
364
 
363
- const fullPath = this.routes[i].split('.');
365
+ const current = this.routes[i];
366
+ const parts = i.split(' ');
367
+ let pathToRun = parts.pop();
364
368
 
365
- const [
366
- moduleToRun,
367
- controllerToRun,
368
- actionToRun
369
- ] = fullPath;
370
-
371
- let module;
372
- let controller;
373
- let action;
374
-
375
- if (actionToRun) { // Has folder
376
- module = moduleToRun;
377
- controller = controllerToRun;
378
- action = actionToRun;
379
- } else {
380
- module = null;
381
- controller = moduleToRun;
382
- action = controllerToRun;
383
- }
369
+ // Capture the HTTP Method
370
+ let option = (parts[0] !== undefined) ? String(parts[0]).toLowerCase() : 'get';
384
371
 
385
- const parts = i.split(' ');
386
- const pathToRun = parts.pop();
387
- let option = (parts[0] !== undefined) ? parts[0].toLowerCase() : 'get';
388
372
  if (option !== 'get' && option !== 'post' && option !== 'put' && option !== 'delete') {
389
373
  option = 'get';
390
374
  }
391
375
 
376
+ if (!String(pathToRun).startsWith('/')) {
377
+ pathToRun = `/${pathToRun}`;
378
+ }
379
+
392
380
  let toExecute = null;
393
381
 
394
- try {
395
- toExecute = module
396
- ? (AllControllers[module][controller][action])
397
- : AllControllers[controller][action];
398
- } catch (e) {
399
- toExecute = null;
382
+ if (typeof current === 'function') {
383
+
384
+ toExecute = current;
385
+
386
+ } else {
387
+
388
+ const fullPath = this.routes[i].split('.');
389
+
390
+ const [
391
+ moduleToRun,
392
+ controllerToRun,
393
+ actionToRun
394
+ ] = fullPath;
395
+
396
+ let module;
397
+ let controller;
398
+ let action;
399
+
400
+ if (actionToRun) { // Has folder
401
+ module = moduleToRun;
402
+ controller = controllerToRun;
403
+ action = actionToRun;
404
+ } else {
405
+ module = null;
406
+ controller = moduleToRun;
407
+ action = controllerToRun;
408
+ }
409
+
410
+ try {
411
+ toExecute = module
412
+ ? (AllControllers[module][controller][action])
413
+ : AllControllers[controller][action];
414
+ } catch (e) {
415
+ toExecute = null;
416
+ }
417
+
418
+ if (!toExecute) {
419
+ console.error('\x1b[31mError:', 'Controller not found in', (module) ? `${module}.${controller}.${action}` : `${controller}.${action}`, '\x1b[0m');
420
+ }
421
+
400
422
  }
401
423
 
402
424
  if (toExecute) {
@@ -405,8 +427,6 @@ module.exports = function loadServer() {
405
427
  } else {
406
428
  vulkano[option](pathToRun || '/', middleware, toExecute);
407
429
  }
408
- } else {
409
- console.error('\x1b[31mError:', 'Controller not found in', (module) ? `${module}.${controller}.${action}` : `${controller}.${action}`, '\x1b[0m');
410
430
  }
411
431
 
412
432
  });
package/libs/Paginate.js CHANGED
@@ -2,6 +2,39 @@ const _ = require('underscore');
2
2
 
3
3
  module.exports = {
4
4
 
5
+ accentToRegex(_text) {
6
+
7
+ const ACCENT_STRINGS = 'ŠŒŽšœžŸ¥µÀÁÂÃÄÅÆÇÈÉÊËẼÌÍÎÏĨÐÑÒÓÔÕÖØÙÚÛÜÝßàáâãäåæçèéêëẽìíîïĩðñòóôõöøùúûüýÿ';
8
+ const NO_ACCENT_STRINGS = 'SOZsozYYuAAAAAAACEEEEEIIIIIDNOOOOOOUUUUYsaaaaaaaceeeeeiiiiionoooooouuuuyy';
9
+
10
+ const from = ACCENT_STRINGS.split('');
11
+ const to = NO_ACCENT_STRINGS.split('');
12
+ const result = [];
13
+ let text = _text;
14
+
15
+ to.forEach( (letter, key) => {
16
+ const exist = result.indexOf(letter);
17
+ if (exist >= 0) {
18
+ result[exist] += from[key];
19
+ } else {
20
+ result.push(letter);
21
+ }
22
+ });
23
+
24
+ result.forEach( (rg, key) => {
25
+ const regex = new RegExp(`[${rg}]`);
26
+ text = text.replace(regex, `_${key}_`);
27
+ });
28
+
29
+ result.forEach( (rg, key) => {
30
+ const regex = new RegExp(`_${key}_`);
31
+ text = text.replace(regex, `[${rg}]`);
32
+ });
33
+
34
+ return text;
35
+
36
+ },
37
+
5
38
  serializeQuery(_props, _query) {
6
39
 
7
40
  const props = typeof _props === 'object'
@@ -45,11 +78,11 @@ module.exports = {
45
78
  if (type === String) {
46
79
 
47
80
  if (searchType === 'startwith' || searchType === 'start') {
48
- row[item] = new RegExp(['^', Utils.accentToRegex(search), '*.'].join(''), 'i');
81
+ row[item] = new RegExp(['^', this.accentToRegex(search), '*.'].join(''), 'i');
49
82
  } else if (searchType === 'endwith' || searchType === 'end') {
50
- row[item] = new RegExp(['.*', Utils.accentToRegex(search)].join(''), 'i');
83
+ row[item] = new RegExp(['.*', this.accentToRegex(search)].join(''), 'i');
51
84
  } else {
52
- row[item] = new RegExp(['.*', Utils.accentToRegex(search), '*.'].join(''), 'i');
85
+ row[item] = new RegExp(['.*', this.accentToRegex(search), '*.'].join(''), 'i');
53
86
  }
54
87
 
55
88
  } else if (type === Number) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vulkano/core",
3
- "version": "1.5.4",
3
+ "version": "1.6.0",
4
4
  "description": "A MVC framework using Express 4",
5
5
  "license": "MIT",
6
6
  "author": "Vulkano Team",
@@ -36,7 +36,7 @@
36
36
  "compression": "^1.7.4",
37
37
  "connect-timeout": "^1.9.0",
38
38
  "cookie-parser": "^1.4.6",
39
- "cron": "^3.1.6",
39
+ "cron": "^3.1.7",
40
40
  "deepmerge": "^4.3.1",
41
41
  "dotenv": "^16.4.5",
42
42
  "express": "^4.19.2",
@@ -46,7 +46,7 @@
46
46
  "fs": "^0.0.1-security",
47
47
  "fs-extra": "^11.2.0",
48
48
  "helmet": "^7.1.0",
49
- "i18next": "^23.10.1",
49
+ "i18next": "^23.11.4",
50
50
  "include-all": "^4.0.3",
51
51
  "jwt-simple": "^0.5.6",
52
52
  "moment": "^2.30.1",
@@ -67,11 +67,11 @@
67
67
  "yargs": "^17.7.2"
68
68
  },
69
69
  "devDependencies": {
70
- "@babel/core": "^7.24.4",
71
- "@babel/eslint-parser": "^7.24.1",
70
+ "@babel/core": "^7.24.5",
71
+ "@babel/eslint-parser": "^7.24.5",
72
72
  "@babel/plugin-syntax-dynamic-import": "^7.8.3",
73
73
  "@babel/plugin-syntax-jsx": "^7.24.1",
74
- "@babel/preset-env": "^7.24.4",
74
+ "@babel/preset-env": "^7.24.5",
75
75
  "@babel/preset-react": "^7.24.1",
76
76
  "@babel/preset-stage-1": "^7.8.3",
77
77
  "eslint": "^8.57.0",
@@ -79,6 +79,6 @@
79
79
  "eslint-plugin-import": "^2.29.1",
80
80
  "eslint-plugin-jsx-a11y": "^6.8.0",
81
81
  "eslint-plugin-react": "^7.34.1",
82
- "eslint-plugin-react-hooks": "^4.6.0"
82
+ "eslint-plugin-react-hooks": "^4.6.2"
83
83
  }
84
84
  }
package/responses/vsr.js CHANGED
@@ -16,7 +16,7 @@ module.exports = function VSRPromise(promiseToRun, httpStatusCode) {
16
16
  } = req;
17
17
 
18
18
  let code = httpStatusCode || 200;
19
- let output = {
19
+ const output = {
20
20
  success: true,
21
21
  statusCode: code
22
22
  };