exisjs 0.4.2 → 0.4.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.
- package/dist/cli/commands/build.d.ts.map +1 -1
- package/dist/cli/commands/build.js +43 -55
- package/dist/cli/commands/build.js.map +1 -1
- package/dist/cli/manifest.d.ts +1 -0
- package/dist/cli/manifest.d.ts.map +1 -1
- package/dist/cli/manifest.js +76 -17
- package/dist/cli/manifest.js.map +1 -1
- package/dist/exports/sanitize.d.ts +2 -0
- package/dist/exports/sanitize.d.ts.map +1 -0
- package/dist/exports/sanitize.js +6 -0
- package/dist/exports/sanitize.js.map +1 -0
- package/dist/middleware/middleware.d.ts.map +1 -1
- package/dist/middleware/middleware.js +5 -0
- package/dist/middleware/middleware.js.map +1 -1
- package/dist/server/app.d.ts +51 -55
- package/dist/server/app.d.ts.map +1 -1
- package/dist/server/app.js +123 -2047
- package/dist/server/app.js.map +1 -1
- package/dist/server/bootstrapper.d.ts +24 -0
- package/dist/server/bootstrapper.d.ts.map +1 -0
- package/dist/server/bootstrapper.js +408 -0
- package/dist/server/bootstrapper.js.map +1 -0
- package/dist/server/controller-registrar.d.ts +8 -0
- package/dist/server/controller-registrar.d.ts.map +1 -0
- package/dist/server/controller-registrar.js +351 -0
- package/dist/server/controller-registrar.js.map +1 -0
- package/dist/server/plugin-manager.d.ts +26 -0
- package/dist/server/plugin-manager.d.ts.map +1 -0
- package/dist/server/plugin-manager.js +150 -0
- package/dist/server/plugin-manager.js.map +1 -0
- package/dist/server/queue-manager.d.ts +18 -0
- package/dist/server/queue-manager.d.ts.map +1 -0
- package/dist/server/queue-manager.js +54 -0
- package/dist/server/queue-manager.js.map +1 -0
- package/dist/server/request-handler.d.ts +25 -0
- package/dist/server/request-handler.d.ts.map +1 -0
- package/dist/server/request-handler.js +230 -0
- package/dist/server/request-handler.js.map +1 -0
- package/dist/server/route-scanner.d.ts +20 -0
- package/dist/server/route-scanner.d.ts.map +1 -0
- package/dist/server/route-scanner.js +892 -0
- package/dist/server/route-scanner.js.map +1 -0
- package/dist/server/ws-orchestrator.d.ts +15 -0
- package/dist/server/ws-orchestrator.d.ts.map +1 -0
- package/dist/server/ws-orchestrator.js +156 -0
- package/dist/server/ws-orchestrator.js.map +1 -0
- package/dist/utils/port.d.ts +2 -0
- package/dist/utils/port.d.ts.map +1 -0
- package/dist/utils/port.js +30 -0
- package/dist/utils/port.js.map +1 -0
- package/dist/utils/sanitize.d.ts +33 -0
- package/dist/utils/sanitize.d.ts.map +1 -0
- package/dist/utils/sanitize.js +95 -0
- package/dist/utils/sanitize.js.map +1 -0
- package/dist/utils/validator.d.ts +2 -0
- package/dist/utils/validator.d.ts.map +1 -1
- package/dist/utils/validator.js +55 -17
- package/dist/utils/validator.js.map +1 -1
- package/package.json +6 -1
|
@@ -0,0 +1,351 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ControllerRegistrar = void 0;
|
|
4
|
+
class ControllerRegistrar {
|
|
5
|
+
constructor(app) {
|
|
6
|
+
this.app = app;
|
|
7
|
+
}
|
|
8
|
+
// ─── Class-Based Controllers Registration ──────────────────────────────────
|
|
9
|
+
registerControllers(controllers, basePath = '', prefixMiddlewares = []) {
|
|
10
|
+
return this._registerControllers(controllers, basePath, prefixMiddlewares);
|
|
11
|
+
}
|
|
12
|
+
_registerControllers(controllers, basePath = '', prefixMiddlewares = []) {
|
|
13
|
+
const ROUTE_REGISTRY = Symbol.for('exisjs:routes');
|
|
14
|
+
const CONTROLLER_PREFIX = Symbol.for('exisjs:controller_prefix');
|
|
15
|
+
const CONTROLLER_HOST = Symbol.for('exisjs:controller_host');
|
|
16
|
+
const MIDDLEWARE_REGISTRY = Symbol.for('exisjs:middlewares');
|
|
17
|
+
const ROUTE_METADATA = Symbol.for('exisjs:route_metadata');
|
|
18
|
+
const LIFECYCLE_METADATA = Symbol.for('exisjs:lifecycle_metadata');
|
|
19
|
+
const PARAM_METADATA = Symbol.for('exisjs:param_metadata');
|
|
20
|
+
for (const ControllerClass of controllers) {
|
|
21
|
+
const prefix = ControllerClass.prototype[CONTROLLER_PREFIX] || '';
|
|
22
|
+
const host = ControllerClass.prototype[CONTROLLER_HOST];
|
|
23
|
+
const routes = ControllerClass.prototype[ROUTE_REGISTRY] || [];
|
|
24
|
+
const classMiddlewares = [
|
|
25
|
+
...(Array.isArray(ControllerClass.prototype[MIDDLEWARE_REGISTRY])
|
|
26
|
+
? ControllerClass.prototype[MIDDLEWARE_REGISTRY]
|
|
27
|
+
: ControllerClass.prototype[MIDDLEWARE_REGISTRY]?._classMiddlewares ||
|
|
28
|
+
[]),
|
|
29
|
+
];
|
|
30
|
+
const methodMiddlewares = (!Array.isArray(ControllerClass.prototype[MIDDLEWARE_REGISTRY])
|
|
31
|
+
? ControllerClass.prototype[MIDDLEWARE_REGISTRY]
|
|
32
|
+
: {}) || {};
|
|
33
|
+
const routeMetadataMap = ControllerClass.prototype[ROUTE_METADATA] || {};
|
|
34
|
+
const lifecycleMetadataMap = ControllerClass.prototype[LIFECYCLE_METADATA] || {};
|
|
35
|
+
const paramMetadataMap = ControllerClass.prototype[PARAM_METADATA] || {};
|
|
36
|
+
for (const route of routes) {
|
|
37
|
+
const method = route.method.toLowerCase();
|
|
38
|
+
const executeCore = async (req, res, next, streamOrSocket) => {
|
|
39
|
+
let instance = this.app.container.resolve(ControllerClass);
|
|
40
|
+
if (!instance) {
|
|
41
|
+
// Auto-instantiate if not provided via DI
|
|
42
|
+
instance = new ControllerClass();
|
|
43
|
+
this.app.container.provide(ControllerClass, { useValue: instance });
|
|
44
|
+
}
|
|
45
|
+
try {
|
|
46
|
+
// 0. Enforce Route Permissions (Role Authorization)
|
|
47
|
+
const routeMetadata = routeMetadataMap[route.handlerName] || {};
|
|
48
|
+
const permissions = routeMetadata.permissions;
|
|
49
|
+
if (permissions && permissions.length > 0) {
|
|
50
|
+
const userPerms = req.user?.permissions || (req.user?.role ? [req.user.role] : []);
|
|
51
|
+
const hasPermission = permissions.some((p) => userPerms.includes(p));
|
|
52
|
+
if (!hasPermission) {
|
|
53
|
+
if (res) {
|
|
54
|
+
res.status(403).json({
|
|
55
|
+
success: false,
|
|
56
|
+
error: {
|
|
57
|
+
code: 'FORBIDDEN',
|
|
58
|
+
message: 'Insufficient permissions to access this resource',
|
|
59
|
+
},
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
// 1. Run Guards
|
|
66
|
+
const routeLifecycle = lifecycleMetadataMap[route.handlerName] || {};
|
|
67
|
+
const guards = routeLifecycle.guards || [];
|
|
68
|
+
for (const guard of guards) {
|
|
69
|
+
let allowed = false;
|
|
70
|
+
if (typeof guard === 'function') {
|
|
71
|
+
if (guard.prototype &&
|
|
72
|
+
typeof guard.prototype.canActivate === 'function') {
|
|
73
|
+
let guardInstance = this.app.container.resolve(guard);
|
|
74
|
+
if (!guardInstance) {
|
|
75
|
+
guardInstance = new guard();
|
|
76
|
+
}
|
|
77
|
+
allowed = await guardInstance.canActivate(req);
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
allowed = await guard(req);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
if (!allowed) {
|
|
84
|
+
if (res) {
|
|
85
|
+
res.status(403).json({
|
|
86
|
+
success: false,
|
|
87
|
+
error: { code: 'FORBIDDEN', message: 'Forbidden by Guard' },
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
// 2. Resolve parameters
|
|
94
|
+
const paramMetadata = paramMetadataMap[route.handlerName] || [];
|
|
95
|
+
const args = [];
|
|
96
|
+
if (paramMetadata.length === 0) {
|
|
97
|
+
if (method === 'ws' || method === 'sse') {
|
|
98
|
+
args.push(req, streamOrSocket);
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
args.push(req, res, next);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
for (const param of paramMetadata) {
|
|
106
|
+
if (!param) {
|
|
107
|
+
args.push(undefined);
|
|
108
|
+
continue;
|
|
109
|
+
}
|
|
110
|
+
let rawArg;
|
|
111
|
+
switch (param.type) {
|
|
112
|
+
case 'req':
|
|
113
|
+
rawArg = req;
|
|
114
|
+
break;
|
|
115
|
+
case 'res':
|
|
116
|
+
rawArg = res;
|
|
117
|
+
break;
|
|
118
|
+
case 'body':
|
|
119
|
+
if (req.body === undefined &&
|
|
120
|
+
['POST', 'PUT', 'PATCH'].includes(req.method)) {
|
|
121
|
+
const contentType = req.headers['content-type'] || '';
|
|
122
|
+
if (contentType.includes('json')) {
|
|
123
|
+
await req.json().catch(() => {
|
|
124
|
+
/* noop */
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
else if (contentType.includes('form')) {
|
|
128
|
+
await req.formData().catch(() => {
|
|
129
|
+
/* noop */
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
rawArg = req.body;
|
|
134
|
+
break;
|
|
135
|
+
case 'param':
|
|
136
|
+
rawArg = param.name ? req.params[param.name] : req.params;
|
|
137
|
+
break;
|
|
138
|
+
case 'query':
|
|
139
|
+
rawArg = param.name ? req.query[param.name] : req.query;
|
|
140
|
+
break;
|
|
141
|
+
case 'header':
|
|
142
|
+
rawArg = param.name
|
|
143
|
+
? req.headers[param.name.toLowerCase()]
|
|
144
|
+
: req.headers;
|
|
145
|
+
break;
|
|
146
|
+
case 'session':
|
|
147
|
+
rawArg = req.session;
|
|
148
|
+
break;
|
|
149
|
+
case 'next':
|
|
150
|
+
rawArg = next;
|
|
151
|
+
break;
|
|
152
|
+
case 'host':
|
|
153
|
+
rawArg = param.name
|
|
154
|
+
? req.params[param.name]
|
|
155
|
+
: req.hostname;
|
|
156
|
+
break;
|
|
157
|
+
case 'socket':
|
|
158
|
+
case 'stream':
|
|
159
|
+
rawArg = streamOrSocket;
|
|
160
|
+
break;
|
|
161
|
+
case 'ip':
|
|
162
|
+
rawArg = req.ip;
|
|
163
|
+
break;
|
|
164
|
+
case 'uploadedFile':
|
|
165
|
+
case 'uploadedFiles':
|
|
166
|
+
if (req.body === undefined &&
|
|
167
|
+
['POST', 'PUT', 'PATCH'].includes(req.method)) {
|
|
168
|
+
await req.formData().catch(() => {
|
|
169
|
+
/* noop */
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
if (req.files) {
|
|
173
|
+
const isMulti = param.type === 'uploadedFiles';
|
|
174
|
+
let files = [];
|
|
175
|
+
if (param.name) {
|
|
176
|
+
files = req.files.filter((f) => f.fieldname === param.name);
|
|
177
|
+
}
|
|
178
|
+
else {
|
|
179
|
+
files = req.files;
|
|
180
|
+
}
|
|
181
|
+
rawArg = isMulti ? files : files[0];
|
|
182
|
+
}
|
|
183
|
+
break;
|
|
184
|
+
default:
|
|
185
|
+
rawArg = undefined;
|
|
186
|
+
}
|
|
187
|
+
if (param.pipes && param.pipes.length > 0) {
|
|
188
|
+
for (const pipe of param.pipes) {
|
|
189
|
+
if (typeof pipe === 'function' &&
|
|
190
|
+
pipe.prototype?.transform) {
|
|
191
|
+
let pipeInstance = this.app.container.resolve(pipe);
|
|
192
|
+
if (!pipeInstance)
|
|
193
|
+
pipeInstance = new pipe();
|
|
194
|
+
rawArg = await pipeInstance.transform(rawArg, {
|
|
195
|
+
type: param.type,
|
|
196
|
+
name: param.name,
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
else if (typeof pipe === 'object' &&
|
|
200
|
+
typeof pipe.parse === 'function') {
|
|
201
|
+
rawArg = await pipe.parse(rawArg);
|
|
202
|
+
}
|
|
203
|
+
else if (typeof pipe === 'object' &&
|
|
204
|
+
typeof pipe.transform === 'function') {
|
|
205
|
+
rawArg = await pipe.transform(rawArg, {
|
|
206
|
+
type: param.type,
|
|
207
|
+
name: param.name,
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
else if (typeof pipe === 'function') {
|
|
211
|
+
rawArg = await pipe(rawArg);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
args.push(rawArg);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
// 3. Execute Custom Interceptors
|
|
219
|
+
const interceptors = routeLifecycle.interceptors || [];
|
|
220
|
+
for (const interceptor of interceptors) {
|
|
221
|
+
if (typeof interceptor === 'function') {
|
|
222
|
+
if (interceptor.prototype &&
|
|
223
|
+
typeof interceptor.prototype.intercept === 'function') {
|
|
224
|
+
let interceptorInstance = this.app.container.resolve(interceptor);
|
|
225
|
+
if (!interceptorInstance) {
|
|
226
|
+
interceptorInstance = new interceptor();
|
|
227
|
+
}
|
|
228
|
+
await interceptorInstance.intercept(req, res);
|
|
229
|
+
}
|
|
230
|
+
else {
|
|
231
|
+
await interceptor(req, res);
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
// 4. Invoke the method
|
|
236
|
+
const result = await instance[route.handlerName](...args);
|
|
237
|
+
if (res && !res.headersSent) {
|
|
238
|
+
const routeMeta = routeMetadataMap[route.handlerName] || {};
|
|
239
|
+
if (routeMeta.redirect) {
|
|
240
|
+
res.redirect(routeMeta.redirect.url, routeMeta.redirect.statusCode);
|
|
241
|
+
return;
|
|
242
|
+
}
|
|
243
|
+
// Apply custom headers
|
|
244
|
+
if (routeMeta.headers) {
|
|
245
|
+
for (const [name, val] of Object.entries(routeMeta.headers)) {
|
|
246
|
+
res.setHeader(name, val);
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
// Apply custom HTTP Code
|
|
250
|
+
if (routeMeta.httpCode) {
|
|
251
|
+
res.status(routeMeta.httpCode);
|
|
252
|
+
}
|
|
253
|
+
if (result !== undefined) {
|
|
254
|
+
res.json(result);
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
catch (err) {
|
|
259
|
+
let handled = false;
|
|
260
|
+
const routeLifecycle = lifecycleMetadataMap[route.handlerName] || {};
|
|
261
|
+
const filters = routeLifecycle.filters || [];
|
|
262
|
+
for (const filter of filters) {
|
|
263
|
+
if (typeof filter === 'function' && filter.prototype?.catch) {
|
|
264
|
+
let filterInstance = this.app.container.resolve(filter);
|
|
265
|
+
if (!filterInstance)
|
|
266
|
+
filterInstance = new filter();
|
|
267
|
+
await filterInstance.catch(err, { req, res });
|
|
268
|
+
handled = true;
|
|
269
|
+
break;
|
|
270
|
+
}
|
|
271
|
+
else if (typeof filter === 'object' &&
|
|
272
|
+
typeof filter.catch === 'function') {
|
|
273
|
+
await filter.catch(err, { req, res });
|
|
274
|
+
handled = true;
|
|
275
|
+
break;
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
if (!handled) {
|
|
279
|
+
if (next)
|
|
280
|
+
next(err);
|
|
281
|
+
else
|
|
282
|
+
console.error(`[Exis ${method.toUpperCase()} Error]`, err);
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
};
|
|
286
|
+
let finalHandler;
|
|
287
|
+
if (method === 'ws' || method === 'sse') {
|
|
288
|
+
finalHandler = async (streamOrSocket, rawReq) => {
|
|
289
|
+
await executeCore(rawReq, undefined, undefined, streamOrSocket);
|
|
290
|
+
};
|
|
291
|
+
}
|
|
292
|
+
else {
|
|
293
|
+
finalHandler = async (req, res, next) => {
|
|
294
|
+
await executeCore(req, res, next);
|
|
295
|
+
};
|
|
296
|
+
}
|
|
297
|
+
const fullPath = (basePath + prefix + route.path).replace(/\/+/g, '/') || '/';
|
|
298
|
+
const routeSpecificMiddlewares = methodMiddlewares[route.handlerName] || [];
|
|
299
|
+
const allMiddlewares = [
|
|
300
|
+
...prefixMiddlewares,
|
|
301
|
+
...classMiddlewares,
|
|
302
|
+
...routeSpecificMiddlewares,
|
|
303
|
+
];
|
|
304
|
+
const routeMeta = routeMetadataMap[route.handlerName] || {};
|
|
305
|
+
const finalHost = routeMeta.hosts || host;
|
|
306
|
+
let schema = route.schema;
|
|
307
|
+
const paramMetadata = paramMetadataMap[route.handlerName] || [];
|
|
308
|
+
let extractedBodySchema = undefined;
|
|
309
|
+
let extractedQuerySchema = undefined;
|
|
310
|
+
for (const param of paramMetadata) {
|
|
311
|
+
if (!param)
|
|
312
|
+
continue;
|
|
313
|
+
if (param.type === 'body') {
|
|
314
|
+
const bodyPipe = param.pipes?.find((p) => p && typeof p.parse === 'function');
|
|
315
|
+
if (bodyPipe)
|
|
316
|
+
extractedBodySchema = bodyPipe;
|
|
317
|
+
}
|
|
318
|
+
if (param.type === 'query') {
|
|
319
|
+
const queryPipe = param.pipes?.find((p) => p && typeof p.parse === 'function');
|
|
320
|
+
if (queryPipe)
|
|
321
|
+
extractedQuerySchema = queryPipe;
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
const extractedResponseSchema = routeMeta.responseSchema;
|
|
325
|
+
if (schema ||
|
|
326
|
+
finalHost ||
|
|
327
|
+
extractedBodySchema ||
|
|
328
|
+
extractedQuerySchema ||
|
|
329
|
+
extractedResponseSchema) {
|
|
330
|
+
schema = schema || {};
|
|
331
|
+
if (finalHost)
|
|
332
|
+
schema.host = finalHost;
|
|
333
|
+
if (extractedBodySchema && !schema.body)
|
|
334
|
+
schema.body = extractedBodySchema;
|
|
335
|
+
if (extractedQuerySchema && !schema.query)
|
|
336
|
+
schema.query = extractedQuerySchema;
|
|
337
|
+
if (extractedResponseSchema && !schema.response)
|
|
338
|
+
schema.response = extractedResponseSchema;
|
|
339
|
+
this.app.router[method](fullPath, ...allMiddlewares, schema, finalHandler);
|
|
340
|
+
}
|
|
341
|
+
else {
|
|
342
|
+
;
|
|
343
|
+
this.app.router[method](fullPath, ...allMiddlewares, finalHandler);
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
return this.app;
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
exports.ControllerRegistrar = ControllerRegistrar;
|
|
351
|
+
//# sourceMappingURL=controller-registrar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gBACH,CAAC;gBAED,MAAM,uBAAuB,GAAG,SAAS,CAAC,cAAc,CAAA;gBAExD,IACE,MAAM;oBACN,SAAS;oBACT,mBAAmB;oBACnB,oBAAoB;oBACpB,uBAAuB,EACvB,CAAC;oBACD,MAAM,GAAG,MAAM,IAAI,EAAE,CAAA;oBACrB,IAAI,SAAS;wBAAE,MAAM,CAAC,IAAI,GAAG,SAAS,CAAA;oBACtC,IAAI,mBAAmB,IAAI,CAAC,MAAM,CAAC,IAAI;wBACrC,MAAM,CAAC,IAAI,GAAG,mBAAmB,CAAA;oBACnC,IAAI,oBAAoB,IAAI,CAAC,MAAM,CAAC,KAAK;wBACvC,MAAM,CAAC,KAAK,GAAG,oBAAoB,CAAA;oBACrC,IAAI,uBAAuB,IAAI,CAAC,MAAM,CAAC,QAAQ;wBAC7C,MAAM,CAAC,QAAQ,GAAG,uBAAuB,CAE1C;oBAAC,IAAI,CAAC,GAAG,CAAC,MAAc,CAAC,MAAM,CAAC,CAC/B,QAAQ,EACR,GAAG,cAAc,EACjB,MAAM,EACN,YAAY,CACb,CAAA;gBACH,CAAC;qBAAM,CAAC;oBACN,CAAC;oBAAC,IAAI,CAAC,GAAG,CAAC,MAAc,CAAC,MAAM,CAAC,CAC/B,QAAQ,EACR,GAAG,cAAc,EACjB,YAAY,CACb,CAAA;gBACH,CAAC;YACH,CAAC;QACH,CAAC;QACD,OAAO,IAAI,CAAC,GAAG,CAAA;IACjB,CAAC;CACF;AAhaD,kDAgaC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { App } from './app';
|
|
2
|
+
import type { ExisPlugin, ExisPluginInstance, HookReady, HookClose, HookRequest, HookResponse, HookError, HookRoute } from '../types';
|
|
3
|
+
export declare class PluginManager {
|
|
4
|
+
private app;
|
|
5
|
+
private registeredPlugins;
|
|
6
|
+
hooks: {
|
|
7
|
+
ready: HookReady[];
|
|
8
|
+
close: HookClose[];
|
|
9
|
+
request: HookRequest[];
|
|
10
|
+
response: HookResponse[];
|
|
11
|
+
error: HookError[];
|
|
12
|
+
route: HookRoute[];
|
|
13
|
+
};
|
|
14
|
+
onStartHook?: (app: App) => void | Promise<void>;
|
|
15
|
+
onCloseHook?: (app: App) => void | Promise<void>;
|
|
16
|
+
constructor(app: App);
|
|
17
|
+
onReady(cb: HookReady): App;
|
|
18
|
+
onClose(cb: HookClose): App;
|
|
19
|
+
onRequest(cb: HookRequest): App;
|
|
20
|
+
onResponse(cb: HookResponse): App;
|
|
21
|
+
onError(cb: HookError): App;
|
|
22
|
+
onRoute(cb: HookRoute): App;
|
|
23
|
+
hasPlugin(name: string): boolean;
|
|
24
|
+
register<TOptions = Record<string, unknown>>(pluginOrInstance: ExisPlugin<TOptions> | ExisPluginInstance, legacyOptions?: TOptions): Promise<App>;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=plugin-manager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin-manager.d.ts","sourceRoot":"","sources":["../../src/server/plugin-manager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,OAAO,CAAA;AAEhC,OAAO,KAAK,EACV,UAAU,EACV,kBAAkB,EAGlB,SAAS,EACT,SAAS,EACT,WAAW,EACX,YAAY,EACZ,SAAS,EACT,SAAS,EACV,MAAM,UAAU,CAAA;AAEjB,qBAAa,aAAa;IAeZ,OAAO,CAAC,GAAG;IAdvB,OAAO,CAAC,iBAAiB,CAAyC;IAE3D,KAAK;eACG,SAAS,EAAE;eACX,SAAS,EAAE;iBACT,WAAW,EAAE;kBACZ,YAAY,EAAE;eACjB,SAAS,EAAE;eACX,SAAS,EAAE;MACzB;IAEM,WAAW,CAAC,EAAE,CAAC,GAAG,EAAE,GAAG,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAChD,WAAW,CAAC,EAAE,CAAC,GAAG,EAAE,GAAG,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;gBAEnC,GAAG,EAAE,GAAG;IAG5B,OAAO,CAAC,EAAE,EAAE,SAAS,GAAG,GAAG;IAK3B,OAAO,CAAC,EAAE,EAAE,SAAS,GAAG,GAAG;IAK3B,SAAS,CAAC,EAAE,EAAE,WAAW,GAAG,GAAG;IAK/B,UAAU,CAAC,EAAE,EAAE,YAAY,GAAG,GAAG;IAKjC,OAAO,CAAC,EAAE,EAAE,SAAS,GAAG,GAAG;IAK3B,OAAO,CAAC,EAAE,EAAE,SAAS,GAAG,GAAG;IAOpB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAI1B,QAAQ,CAAC,QAAQ,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACtD,gBAAgB,EAAE,UAAU,CAAC,QAAQ,CAAC,GAAG,kBAAkB,EAC3D,aAAa,CAAC,EAAE,QAAQ,GACvB,OAAO,CAAC,GAAG,CAAC;CAqHhB"}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PluginManager = void 0;
|
|
4
|
+
const router_1 = require("../router/router");
|
|
5
|
+
class PluginManager {
|
|
6
|
+
constructor(app) {
|
|
7
|
+
this.app = app;
|
|
8
|
+
this.registeredPlugins = new Map();
|
|
9
|
+
this.hooks = {
|
|
10
|
+
ready: [],
|
|
11
|
+
close: [],
|
|
12
|
+
request: [],
|
|
13
|
+
response: [],
|
|
14
|
+
error: [],
|
|
15
|
+
route: [],
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
// ─── Lifecycle Hooks Registration ───────────────────────────────────────────
|
|
19
|
+
onReady(cb) {
|
|
20
|
+
this.hooks.ready.push(cb);
|
|
21
|
+
return this.app;
|
|
22
|
+
}
|
|
23
|
+
onClose(cb) {
|
|
24
|
+
this.hooks.close.push(cb);
|
|
25
|
+
return this.app;
|
|
26
|
+
}
|
|
27
|
+
onRequest(cb) {
|
|
28
|
+
this.hooks.request.push(cb);
|
|
29
|
+
return this.app;
|
|
30
|
+
}
|
|
31
|
+
onResponse(cb) {
|
|
32
|
+
this.hooks.response.push(cb);
|
|
33
|
+
return this.app;
|
|
34
|
+
}
|
|
35
|
+
onError(cb) {
|
|
36
|
+
this.hooks.error.push(cb);
|
|
37
|
+
return this.app;
|
|
38
|
+
}
|
|
39
|
+
onRoute(cb) {
|
|
40
|
+
this.hooks.route.push(cb);
|
|
41
|
+
return this.app;
|
|
42
|
+
}
|
|
43
|
+
// ─── Plugin System ──────────────────────────────────────────────────────────
|
|
44
|
+
hasPlugin(name) {
|
|
45
|
+
return this.registeredPlugins.has(name);
|
|
46
|
+
}
|
|
47
|
+
async register(pluginOrInstance, legacyOptions) {
|
|
48
|
+
let plugin;
|
|
49
|
+
let options;
|
|
50
|
+
if ('plugin' in pluginOrInstance && !('register' in pluginOrInstance)) {
|
|
51
|
+
plugin = pluginOrInstance.plugin;
|
|
52
|
+
options = pluginOrInstance.options;
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
plugin = pluginOrInstance;
|
|
56
|
+
options = legacyOptions;
|
|
57
|
+
}
|
|
58
|
+
if (this.registeredPlugins.has(plugin.name)) {
|
|
59
|
+
throw new Error(`Plugin '${plugin.name}' is already registered`);
|
|
60
|
+
}
|
|
61
|
+
if (plugin.dependencies) {
|
|
62
|
+
for (const dep of plugin.dependencies) {
|
|
63
|
+
if (!this.registeredPlugins.has(dep)) {
|
|
64
|
+
throw new Error(`Plugin '${plugin.name}' requires dependency '${dep}' which is not registered`);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
let targetApp = this.app;
|
|
69
|
+
let pluginRouter;
|
|
70
|
+
if (plugin.encapsulate !== false) {
|
|
71
|
+
pluginRouter = new router_1.Router();
|
|
72
|
+
// Create a proxy that intercepts route and middleware registrations
|
|
73
|
+
targetApp = new Proxy(this.app, {
|
|
74
|
+
get(target, prop, receiver) {
|
|
75
|
+
if ([
|
|
76
|
+
'get',
|
|
77
|
+
'post',
|
|
78
|
+
'put',
|
|
79
|
+
'patch',
|
|
80
|
+
'delete',
|
|
81
|
+
'httpOptions',
|
|
82
|
+
'head',
|
|
83
|
+
'all',
|
|
84
|
+
'ws',
|
|
85
|
+
'query',
|
|
86
|
+
'connect',
|
|
87
|
+
'trace',
|
|
88
|
+
].includes(prop)) {
|
|
89
|
+
return (path, ...handlers) => {
|
|
90
|
+
const routerMethod = prop === 'httpOptions' ? 'options' : prop;
|
|
91
|
+
pluginRouter[routerMethod](path, ...handlers);
|
|
92
|
+
return receiver;
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
if (prop === 'use') {
|
|
96
|
+
return (...handlers) => {
|
|
97
|
+
for (const h of handlers) {
|
|
98
|
+
if (h.length === 4) {
|
|
99
|
+
// error handlers stay global for now, or we could scope them
|
|
100
|
+
target.use(h);
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
pluginRouter.use(h);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
return receiver;
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
// Encapsulate lifecycle hooks by converting them to scoped middleware!
|
|
110
|
+
if (['onRequest', 'onResponse'].includes(prop)) {
|
|
111
|
+
return (cb) => {
|
|
112
|
+
if (prop === 'onRequest') {
|
|
113
|
+
pluginRouter.use(async (req, res, next) => {
|
|
114
|
+
try {
|
|
115
|
+
await cb(req, res);
|
|
116
|
+
next();
|
|
117
|
+
}
|
|
118
|
+
catch (err) {
|
|
119
|
+
next(err);
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
else if (prop === 'onResponse') {
|
|
124
|
+
pluginRouter.use((req, res, next) => {
|
|
125
|
+
res.raw.on('finish', () => {
|
|
126
|
+
cb(req, res).catch(() => {
|
|
127
|
+
/* ignore */
|
|
128
|
+
});
|
|
129
|
+
});
|
|
130
|
+
next();
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
return receiver;
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
const value = Reflect.get(target, prop, receiver);
|
|
137
|
+
return typeof value === 'function' ? value.bind(target) : value;
|
|
138
|
+
},
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
await plugin.register(targetApp, options);
|
|
142
|
+
if (pluginRouter) {
|
|
143
|
+
this.app.mount('/', pluginRouter);
|
|
144
|
+
}
|
|
145
|
+
this.registeredPlugins.set(plugin.name, plugin);
|
|
146
|
+
return this.app;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
exports.PluginManager = PluginManager;
|
|
150
|
+
//# sourceMappingURL=plugin-manager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin-manager.js","sourceRoot":"","sources":["../../src/server/plugin-manager.ts"],"names":[],"mappings":";;;AACA,6CAAyC;AAczC,MAAa,aAAa;IAexB,YAAoB,GAAQ;QAAR,QAAG,GAAH,GAAG,CAAK;QAdpB,sBAAiB,GAAG,IAAI,GAAG,EAA+B,CAAA;QAE3D,UAAK,GAAG;YACb,KAAK,EAAE,EAAiB;YACxB,KAAK,EAAE,EAAiB;YACxB,OAAO,EAAE,EAAmB;YAC5B,QAAQ,EAAE,EAAoB;YAC9B,KAAK,EAAE,EAAiB;YACxB,KAAK,EAAE,EAAiB;SACzB,CAAA;IAK8B,CAAC;IAEhC,+EAA+E;IAC/E,OAAO,CAAC,EAAa;QACnB,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;QACzB,OAAO,IAAI,CAAC,GAAG,CAAA;IACjB,CAAC;IAED,OAAO,CAAC,EAAa;QACnB,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;QACzB,OAAO,IAAI,CAAC,GAAG,CAAA;IACjB,CAAC;IAED,SAAS,CAAC,EAAe;QACvB,IAAI,CAAC,KAAK,CAAC,OAAO,CAA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C,MAAM,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAA;oBACjD,OAAO,OAAO,KAAK,KAAK,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK,CAAA;gBACjE,CAAC;aACF,CAAC,CAAA;QACJ,CAAC;QAED,MAAM,MAAM,CAAC,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC,CAAA;QAEzC,IAAI,YAAY,EAAE,CAAC;YACjB,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,EAAE,YAAY,CAAC,CAAA;QACnC,CAAC;QAED,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE,MAA6B,CAAC,CAAA;QACtE,OAAO,IAAI,CAAC,GAAG,CAAA;IACjB,CAAC;CACF;AA9KD,sCA8KC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { App } from './app';
|
|
2
|
+
import { ExisQueue } from '../queue/client';
|
|
3
|
+
import { ExisWorker } from '../queue/worker';
|
|
4
|
+
import { CronScheduler } from '../cron/scheduler';
|
|
5
|
+
import type { JobOptions } from '../queue/types';
|
|
6
|
+
import type { ExisConfig } from '../types';
|
|
7
|
+
export declare class QueueManager {
|
|
8
|
+
private app;
|
|
9
|
+
_queueClient: ExisQueue | null;
|
|
10
|
+
_queueWorker: ExisWorker | null;
|
|
11
|
+
_cronScheduler: CronScheduler | null;
|
|
12
|
+
_pendingQueueJobs: import('../queue/types').JobDefinition<unknown>[];
|
|
13
|
+
constructor(app: App);
|
|
14
|
+
queue<T = unknown>(name: string, handler: import('../queue/types').JobHandler<T>, options?: Omit<import('../queue/types').JobDefinition<T>, 'name' | 'handler'>): void;
|
|
15
|
+
enqueue<T = unknown>(name: string, payload: T, opts?: JobOptions): Promise<string>;
|
|
16
|
+
_initQueue(qConfig: NonNullable<ExisConfig['queue']>): void;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingUR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|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.QueueManager = void 0;
|
|
4
|
+
const client_1 = require("../queue/client");
|
|
5
|
+
const worker_1 = require("../queue/worker");
|
|
6
|
+
const scheduler_1 = require("../cron/scheduler");
|
|
7
|
+
class QueueManager {
|
|
8
|
+
constructor(app) {
|
|
9
|
+
this.app = app;
|
|
10
|
+
this._queueClient = null;
|
|
11
|
+
this._queueWorker = null;
|
|
12
|
+
this._cronScheduler = null;
|
|
13
|
+
this._pendingQueueJobs = [];
|
|
14
|
+
}
|
|
15
|
+
queue(name, handler, options) {
|
|
16
|
+
if (!this._queueWorker) {
|
|
17
|
+
if (this.app.options.queue?.enableWorkers === false) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
this._pendingQueueJobs.push({
|
|
21
|
+
name,
|
|
22
|
+
handler: handler,
|
|
23
|
+
...options,
|
|
24
|
+
});
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
this._queueWorker.registerJob({
|
|
28
|
+
name,
|
|
29
|
+
handler: handler,
|
|
30
|
+
...options,
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
async enqueue(name, payload, opts) {
|
|
34
|
+
if (!this._queueClient) {
|
|
35
|
+
throw new Error('Queue is not initialized. Please configure ExisConfig.queue first.');
|
|
36
|
+
}
|
|
37
|
+
return this._queueClient.enqueue(name, payload, opts);
|
|
38
|
+
}
|
|
39
|
+
_initQueue(qConfig) {
|
|
40
|
+
if (!this._queueClient) {
|
|
41
|
+
this._queueClient = new client_1.ExisQueue(qConfig);
|
|
42
|
+
}
|
|
43
|
+
const enableWorkers = qConfig.enableWorkers ?? true;
|
|
44
|
+
if (enableWorkers && !this._queueWorker) {
|
|
45
|
+
this._queueWorker = new worker_1.ExisWorker(qConfig, this.app.log, this._queueClient.getDriver());
|
|
46
|
+
this._queueWorker.start();
|
|
47
|
+
const redisClient = this._queueWorker.redis || null;
|
|
48
|
+
this._cronScheduler = new scheduler_1.CronScheduler(this._queueWorker, redisClient, this.app.log);
|
|
49
|
+
this._cronScheduler.start();
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
exports.QueueManager = QueueManager;
|
|
54
|
+
//# sourceMappingURL=queue-manager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"queue-manager.js","sourceRoot":"","sources":["../../src/server/queue-manager.ts"],"names":[],"mappings":";;;AACA,4CAA2C;AAC3C,4CAA4C;AAC5C,iDAAiD;AAIjD,MAAa,YAAY;IAOvB,YAAoB,GAAQ;QAAR,QAAG,GAAH,GAAG,CAAK;QANrB,iBAAY,GAAqB,IAAI,CAAA;QACrC,iBAAY,GAAsB,IAAI,CAAA;QACtC,mBAAc,GAAyB,IAAI,CAAA;QAC3C,sBAAiB,GACtB,EAAE,CAAA;IAE2B,CAAC;IAEzB,KAAK,CACV,IAAY,EACZ,OAA+C,EAC/C,OAGC;QAED,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,CAAC;YACvB,IAAI,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,KAAK,EAAE,aAAa,KAAK,KAAK,EAAE,CAAC;gBACpD,OAAM;YACR,CAAC;YACD,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC;gBAC1B,IAAI;gBACJ,OAAO,EAAE,OAAuD;gBAChE,GAAG,OAAO;aACJ,CAAC,CAAA;YACT,OAAM;QACR,CAAC;QACD,IAAI,CAAC,YAAY,CAAC,WAAW,CAAC;YAC5B,IAAI;YACJ,OAAO,EAAE,OAAuD;YAChE,GAAG,OAAO;SACJ,CAAC,CAAA;IACX,CAAC;IAEM,KAAK,CAAC,OAAO,CAClB,IAAY,EACZ,OAAU,EACV,IAAiB;QAEjB,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,CAAC;YACvB,MAAM,IAAI,KAAK,CACb,oEAAoE,CACrE,CAAA;QACH,CAAC;QACD,OAAO,IAAI,CAAC,YAAY,CAAC,O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