jerkjs 2.5.6 → 2.6.1
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/CHANGELOG.md +167 -79
- package/README.md +134 -146
- package/RESULTADOS_WAF.md +63 -0
- package/doc-2.5/ADMIN_EXTENSION_COMMANDS_MANUAL.md +261 -0
- package/doc-2.5/ADMIN_EXTENSION_HOOK_EXAMPLE.md +28 -0
- package/doc-2.5/ADMIN_EXTENSION_INTEGRATION_MANUAL.md +232 -0
- package/doc-2.5/CACHE_SYSTEM_MAP.md +206 -0
- package/doc-2.5/MANUAL_MODULOS_ADMIN.md +287 -0
- package/doc-2.5/QUEUE_CLI_MODULE_MANUAL.md +289 -0
- package/doc-2.5/QUEUE_SYSTEM_MANUAL.md +320 -0
- package/doc-2.5/ROUTE_CACHE_MODULE_MANUAL.md +205 -0
- package/doc-2.5/WAF_MODULE_MANUAL.md +229 -0
- package/index.js +19 -4
- package/jerk-admin-client/README.md +69 -0
- package/jerk-admin-client/package.json +23 -0
- package/jerk-admin-client.js +257 -0
- package/lib/admin/AdminExtension.js +491 -0
- package/lib/admin/ModuleLoader.js +77 -0
- package/lib/admin/config.js +21 -0
- package/lib/admin/modules/CacheModule.js +145 -0
- package/lib/admin/modules/ControllerGeneratorModule.js +414 -0
- package/lib/admin/modules/QueueManagementModule.js +265 -0
- package/lib/admin/modules/RouteCacheModule.js +227 -0
- package/lib/admin/modules/RouteManagerModule.js +468 -0
- package/lib/admin/modules/STATS_MODULE_README.md +113 -0
- package/lib/admin/modules/StatsModule.js +140 -0
- package/lib/admin/modules/SystemModule.js +140 -0
- package/lib/admin/modules/TimeModule.js +95 -0
- package/lib/admin/modules/ViewCacheStatsModule.js +92 -0
- package/lib/admin/modules/WAFModule.js +737 -0
- package/lib/cache/CacheHooks.js +141 -0
- package/lib/core/server.js +223 -77
- package/lib/middleware/firewall.js +112 -17
- package/lib/mvc/viewEngine.js +89 -5
- package/lib/queue/GlobalQueueStorage.js +38 -0
- package/lib/queue/QueueSystem.js +451 -0
- package/lib/queue/admin_example.js +114 -0
- package/lib/queue/example.js +268 -0
- package/lib/queue/integration.js +109 -0
- package/lib/router/RouteMatcher.js +242 -54
- package/lib/utils/globalStats.js +16 -0
- package/lib/utils/globalViewCacheInfo.js +16 -0
- package/lib/utils/globalWAFStats.js +54 -0
- package/package.json +2 -2
- package/test-colors.js +46 -0
- package/test-help-alias.js +31 -0
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sistema de Hooks y Filters para el Manejo de Caché en JERK Framework
|
|
3
|
+
* Implementación del componente cache/cacheHooks.js
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
class CacheHooks {
|
|
7
|
+
/**
|
|
8
|
+
* Constructor del sistema de hooks de caché
|
|
9
|
+
* @param {Object} hooksSystem - Instancia del sistema de hooks principal
|
|
10
|
+
*/
|
|
11
|
+
constructor(hooksSystem) {
|
|
12
|
+
this.hooks = hooksSystem;
|
|
13
|
+
this.initializeCacheHooks();
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Inicializa los hooks relacionados con el sistema de caché
|
|
18
|
+
*/
|
|
19
|
+
initializeCacheHooks() {
|
|
20
|
+
// Hook para cuando se añade una entrada al caché de rutas
|
|
21
|
+
this.hooks.addAction('route_regex_cached', (path, regex) => {
|
|
22
|
+
console.log(`[CACHE] Expresión regular cacheada para ruta: ${path}`);
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
// Hook para cuando se añade una vista al caché
|
|
26
|
+
this.hooks.addAction('view_cached', (viewPath, content) => {
|
|
27
|
+
console.log(`[CACHE] Vista cacheada: ${viewPath}`);
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
// Hook para cuando se limpia el caché de rutas
|
|
31
|
+
this.hooks.addAction('route_cache_cleared', () => {
|
|
32
|
+
console.log('[CACHE] Caché de rutas limpiado');
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
// Hook para cuando se limpia el caché de vistas
|
|
36
|
+
this.hooks.addAction('view_cache_cleared', () => {
|
|
37
|
+
console.log('[CACHE] Caché de vistas limpiado');
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
// Filter para permitir modificar el contenido antes de ser cacheado
|
|
41
|
+
this.hooks.addFilter('before_view_cache', (content, viewPath) => {
|
|
42
|
+
// Permitir a otros módulos modificar el contenido antes de cachear
|
|
43
|
+
return content;
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
// Filter para permitir modificar la decisión de si se debe cachear una vista
|
|
47
|
+
this.hooks.addFilter('should_cache_view', (shouldCache, viewPath, content) => {
|
|
48
|
+
// Por defecto, se cachea si está habilitado globalmente
|
|
49
|
+
return shouldCache;
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
// Filter para permitir modificar la decisión de si se debe cachear una expresión regular
|
|
53
|
+
this.hooks.addFilter('should_cache_route_regex', (shouldCache, path, regex) => {
|
|
54
|
+
// Por defecto, se cachea si está habilitado globalmente
|
|
55
|
+
return shouldCache;
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Dispara el hook cuando se añade una entrada al caché de rutas
|
|
61
|
+
* @param {string} path - Ruta que se está cacheando
|
|
62
|
+
* @param {RegExp} regex - Expresión regular que se está cacheando
|
|
63
|
+
*/
|
|
64
|
+
triggerRouteRegexCached(path, regex) {
|
|
65
|
+
if (this.hooks) {
|
|
66
|
+
this.hooks.doAction('route_regex_cached', path, regex);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Dispara el hook cuando se añade una vista al caché
|
|
72
|
+
* @param {string} viewPath - Ruta de la vista que se está cacheando
|
|
73
|
+
* @param {string} content - Contenido de la vista que se está cacheando
|
|
74
|
+
*/
|
|
75
|
+
triggerViewCached(viewPath, content) {
|
|
76
|
+
if (this.hooks) {
|
|
77
|
+
this.hooks.doAction('view_cached', viewPath, content);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Dispara el hook cuando se limpia el caché de rutas
|
|
83
|
+
*/
|
|
84
|
+
triggerRouteCacheCleared() {
|
|
85
|
+
if (this.hooks) {
|
|
86
|
+
this.hooks.doAction('route_cache_cleared');
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Dispara el hook cuando se limpia el caché de vistas
|
|
92
|
+
*/
|
|
93
|
+
triggerViewCacheCleared() {
|
|
94
|
+
if (this.hooks) {
|
|
95
|
+
this.hooks.doAction('view_cache_cleared');
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Aplica el filter antes de cachear una vista
|
|
101
|
+
* @param {string} content - Contenido de la vista
|
|
102
|
+
* @param {string} viewPath - Ruta de la vista
|
|
103
|
+
* @returns {string} - Contenido procesado por los filters
|
|
104
|
+
*/
|
|
105
|
+
applyBeforeViewCacheFilter(content, viewPath) {
|
|
106
|
+
if (this.hooks) {
|
|
107
|
+
return this.hooks.applyFilters('before_view_cache', content, viewPath);
|
|
108
|
+
}
|
|
109
|
+
return content;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Aplica el filter para decidir si se debe cachear una vista
|
|
114
|
+
* @param {boolean} shouldCache - Valor por defecto
|
|
115
|
+
* @param {string} viewPath - Ruta de la vista
|
|
116
|
+
* @param {string} content - Contenido de la vista
|
|
117
|
+
* @returns {boolean} - Decisión final de si se debe cachear
|
|
118
|
+
*/
|
|
119
|
+
applyShouldCacheViewFilter(shouldCache, viewPath, content) {
|
|
120
|
+
if (this.hooks) {
|
|
121
|
+
return this.hooks.applyFilters('should_cache_view', shouldCache, viewPath, content);
|
|
122
|
+
}
|
|
123
|
+
return shouldCache;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Aplica el filter para decidir si se debe cachear una expresión regular
|
|
128
|
+
* @param {boolean} shouldCache - Valor por defecto
|
|
129
|
+
* @param {string} path - Ruta para la que se va a cachear la expresión regular
|
|
130
|
+
* @param {RegExp} regex - Expresión regular a cachear
|
|
131
|
+
* @returns {boolean} - Decisión final de si se debe cachear
|
|
132
|
+
*/
|
|
133
|
+
applyShouldCacheRouteRegexFilter(shouldCache, path, regex) {
|
|
134
|
+
if (this.hooks) {
|
|
135
|
+
return this.hooks.applyFilters('should_cache_route_regex', shouldCache, path, regex);
|
|
136
|
+
}
|
|
137
|
+
return shouldCache;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
module.exports = CacheHooks;
|