@vulkano/core 1.5.5 → 1.7.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.
- package/bootstrap/express.js +2 -0
- package/bootstrap/server.js +114 -31
- package/package.json +11 -11
package/bootstrap/express.js
CHANGED
|
@@ -41,7 +41,9 @@ module.exports = function getExpressConfiguration() {
|
|
|
41
41
|
port: ENV_NODE_PORT || ENV_PORT || expressUserPort || expressSettingsPort || 8000,
|
|
42
42
|
cors: {},
|
|
43
43
|
cookies: {},
|
|
44
|
+
csp: {},
|
|
44
45
|
jwt: {},
|
|
46
|
+
permissionPolicy: {},
|
|
45
47
|
sockets: {},
|
|
46
48
|
redis: {},
|
|
47
49
|
multer: {
|
package/bootstrap/server.js
CHANGED
|
@@ -232,6 +232,69 @@ module.exports = function loadServer() {
|
|
|
232
232
|
});
|
|
233
233
|
}
|
|
234
234
|
|
|
235
|
+
// ---------------
|
|
236
|
+
// Content Security Policy - File: app/config/express/csp.js
|
|
237
|
+
// ---------------
|
|
238
|
+
const {
|
|
239
|
+
enabled: cspEnabled,
|
|
240
|
+
report: cspReportTo,
|
|
241
|
+
rules: cspRules
|
|
242
|
+
} = expressConfig.csp || {};
|
|
243
|
+
|
|
244
|
+
if (cspEnabled) {
|
|
245
|
+
|
|
246
|
+
if (!Array.isArray(cspRules)) {
|
|
247
|
+
console.error('Vulkano Error: ', 'The Content Security Policy Rules must be an array');
|
|
248
|
+
return;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
if (cspRules.length > 0) {
|
|
252
|
+
|
|
253
|
+
vulkano.use( (req, res, next) => {
|
|
254
|
+
|
|
255
|
+
if (cspReportTo) {
|
|
256
|
+
res.setHeader('Report-To', JSON.stringify(cspReportTo));
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
res.setHeader('Content-Security-Policy', cspRules.join('; '));
|
|
260
|
+
|
|
261
|
+
next();
|
|
262
|
+
|
|
263
|
+
});
|
|
264
|
+
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
// ---------------
|
|
270
|
+
// Permission Policy - File: app/config/express/permissionPolicy.js
|
|
271
|
+
// ---------------
|
|
272
|
+
const {
|
|
273
|
+
enabled: ppEnabled,
|
|
274
|
+
permissions: ppPermissions
|
|
275
|
+
} = expressConfig.permissionPolicy || {};
|
|
276
|
+
|
|
277
|
+
if (ppEnabled) {
|
|
278
|
+
|
|
279
|
+
if (!Array.isArray(ppPermissions)) {
|
|
280
|
+
console.error('Vulkano Error: ', 'The Permission Policy values must be an array');
|
|
281
|
+
return;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
if (ppPermissions.length > 0) {
|
|
285
|
+
|
|
286
|
+
vulkano.use( (req, res, next) => {
|
|
287
|
+
|
|
288
|
+
res.setHeader('Permissions-Policy', ppPermissions.join(', '));
|
|
289
|
+
|
|
290
|
+
next();
|
|
291
|
+
|
|
292
|
+
});
|
|
293
|
+
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
}
|
|
297
|
+
|
|
235
298
|
// ---------------
|
|
236
299
|
// VIEWS
|
|
237
300
|
// ---------------
|
|
@@ -333,6 +396,7 @@ module.exports = function loadServer() {
|
|
|
333
396
|
let pathToRoute;
|
|
334
397
|
let handler;
|
|
335
398
|
|
|
399
|
+
// Routes from convention (controller name & method = route)
|
|
336
400
|
Object.keys(routes).forEach((route) => {
|
|
337
401
|
|
|
338
402
|
const parts = route.split(' ');
|
|
@@ -358,45 +422,66 @@ module.exports = function loadServer() {
|
|
|
358
422
|
|
|
359
423
|
});
|
|
360
424
|
|
|
425
|
+
// Routes from config/routes.js
|
|
361
426
|
Object.keys(this.routes || {}).forEach((i) => {
|
|
362
427
|
|
|
363
|
-
const
|
|
428
|
+
const current = this.routes[i];
|
|
429
|
+
const parts = i.split(' ');
|
|
430
|
+
let pathToRun = parts.pop();
|
|
364
431
|
|
|
365
|
-
|
|
366
|
-
|
|
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
|
-
}
|
|
432
|
+
// Capture the HTTP Method
|
|
433
|
+
let option = (parts[0] !== undefined) ? String(parts[0]).toLowerCase() : 'get';
|
|
384
434
|
|
|
385
|
-
const parts = i.split(' ');
|
|
386
|
-
const pathToRun = parts.pop();
|
|
387
|
-
let option = (parts[0] !== undefined) ? parts[0].toLowerCase() : 'get';
|
|
388
435
|
if (option !== 'get' && option !== 'post' && option !== 'put' && option !== 'delete') {
|
|
389
436
|
option = 'get';
|
|
390
437
|
}
|
|
391
438
|
|
|
439
|
+
if (!String(pathToRun).startsWith('/')) {
|
|
440
|
+
pathToRun = `/${pathToRun}`;
|
|
441
|
+
}
|
|
442
|
+
|
|
392
443
|
let toExecute = null;
|
|
393
444
|
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
}
|
|
399
|
-
|
|
445
|
+
if (typeof current === 'function') {
|
|
446
|
+
|
|
447
|
+
toExecute = current;
|
|
448
|
+
|
|
449
|
+
} else {
|
|
450
|
+
|
|
451
|
+
const fullPath = this.routes[i].split('.');
|
|
452
|
+
|
|
453
|
+
const [
|
|
454
|
+
moduleToRun,
|
|
455
|
+
controllerToRun,
|
|
456
|
+
actionToRun
|
|
457
|
+
] = fullPath;
|
|
458
|
+
|
|
459
|
+
let module;
|
|
460
|
+
let controller;
|
|
461
|
+
let action;
|
|
462
|
+
|
|
463
|
+
if (actionToRun) { // Has folder
|
|
464
|
+
module = moduleToRun;
|
|
465
|
+
controller = controllerToRun;
|
|
466
|
+
action = actionToRun;
|
|
467
|
+
} else {
|
|
468
|
+
module = null;
|
|
469
|
+
controller = moduleToRun;
|
|
470
|
+
action = controllerToRun;
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
try {
|
|
474
|
+
toExecute = module
|
|
475
|
+
? (AllControllers[module][controller][action])
|
|
476
|
+
: AllControllers[controller][action];
|
|
477
|
+
} catch (e) {
|
|
478
|
+
toExecute = null;
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
if (!toExecute) {
|
|
482
|
+
console.error('\x1b[31mError:', 'Controller not found in', (module) ? `${module}.${controller}.${action}` : `${controller}.${action}`, '\x1b[0m');
|
|
483
|
+
}
|
|
484
|
+
|
|
400
485
|
}
|
|
401
486
|
|
|
402
487
|
if (toExecute) {
|
|
@@ -405,8 +490,6 @@ module.exports = function loadServer() {
|
|
|
405
490
|
} else {
|
|
406
491
|
vulkano[option](pathToRun || '/', middleware, toExecute);
|
|
407
492
|
}
|
|
408
|
-
} else {
|
|
409
|
-
console.error('\x1b[31mError:', 'Controller not found in', (module) ? `${module}.${controller}.${action}` : `${controller}.${action}`, '\x1b[0m');
|
|
410
493
|
}
|
|
411
494
|
|
|
412
495
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vulkano/core",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.0",
|
|
4
4
|
"description": "A MVC framework using Express 4",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Vulkano Team",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@socket.io/mongo-adapter": "^0.3.2",
|
|
32
32
|
"@socket.io/redis-adapter": "^8.3.0",
|
|
33
|
-
"axios": "^1.
|
|
33
|
+
"axios": "^1.7.2",
|
|
34
34
|
"bluebird": "^3.7.2",
|
|
35
35
|
"body-parser": "^1.20.2",
|
|
36
36
|
"compression": "^1.7.4",
|
|
@@ -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.11.
|
|
49
|
+
"i18next": "^23.11.5",
|
|
50
50
|
"include-all": "^4.0.3",
|
|
51
51
|
"jwt-simple": "^0.5.6",
|
|
52
52
|
"moment": "^2.30.1",
|
|
@@ -55,11 +55,11 @@
|
|
|
55
55
|
"mongoose-paginate": "^5.0.3",
|
|
56
56
|
"morgan": "^1.10.0",
|
|
57
57
|
"multer": "^1.4.5-lts.1",
|
|
58
|
-
"nodemon": "^3.1.
|
|
58
|
+
"nodemon": "^3.1.3",
|
|
59
59
|
"nunjucks": "^3.2.4",
|
|
60
60
|
"path": "^0.12.7",
|
|
61
61
|
"promise.prototype.finally": "^3.1.8",
|
|
62
|
-
"redis": "^4.6.
|
|
62
|
+
"redis": "^4.6.14",
|
|
63
63
|
"socket.io": "^4.7.5",
|
|
64
64
|
"socket.io-adapter": "^2.5.4",
|
|
65
65
|
"socket.io-client": "4.7.5",
|
|
@@ -67,18 +67,18 @@
|
|
|
67
67
|
"yargs": "^17.7.2"
|
|
68
68
|
},
|
|
69
69
|
"devDependencies": {
|
|
70
|
-
"@babel/core": "^7.24.
|
|
71
|
-
"@babel/eslint-parser": "^7.24.
|
|
70
|
+
"@babel/core": "^7.24.7",
|
|
71
|
+
"@babel/eslint-parser": "^7.24.7",
|
|
72
72
|
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
|
|
73
|
-
"@babel/plugin-syntax-jsx": "^7.24.
|
|
74
|
-
"@babel/preset-env": "^7.24.
|
|
75
|
-
"@babel/preset-react": "^7.24.
|
|
73
|
+
"@babel/plugin-syntax-jsx": "^7.24.7",
|
|
74
|
+
"@babel/preset-env": "^7.24.7",
|
|
75
|
+
"@babel/preset-react": "^7.24.7",
|
|
76
76
|
"@babel/preset-stage-1": "^7.8.3",
|
|
77
77
|
"eslint": "^8.57.0",
|
|
78
78
|
"eslint-config-airbnb": "^19.0.4",
|
|
79
79
|
"eslint-plugin-import": "^2.29.1",
|
|
80
80
|
"eslint-plugin-jsx-a11y": "^6.8.0",
|
|
81
|
-
"eslint-plugin-react": "^7.34.
|
|
81
|
+
"eslint-plugin-react": "^7.34.2",
|
|
82
82
|
"eslint-plugin-react-hooks": "^4.6.2"
|
|
83
83
|
}
|
|
84
84
|
}
|