@scpxl/nodejs-framework 1.0.22 → 1.0.24
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/README.md +199 -9
- package/dist/api-requester/api-requester.d.ts +32 -0
- package/dist/api-requester/api-requester.d.ts.map +1 -0
- package/dist/api-requester/index.d.ts +3 -0
- package/dist/api-requester/index.d.ts.map +1 -0
- package/dist/application/base-application.d.ts +106 -0
- package/dist/application/base-application.d.ts.map +1 -0
- package/dist/application/base-application.interface.d.ts +162 -0
- package/dist/application/base-application.interface.d.ts.map +1 -0
- package/dist/application/base-application.js +3 -0
- package/dist/application/base-application.js.map +2 -2
- package/dist/application/command-application.d.ts +18 -0
- package/dist/application/command-application.d.ts.map +1 -0
- package/dist/application/command-application.interface.d.ts +26 -0
- package/dist/application/command-application.interface.d.ts.map +1 -0
- package/dist/application/index.d.ts +5 -0
- package/dist/application/index.d.ts.map +1 -0
- package/dist/application/web-application.d.ts +43 -0
- package/dist/application/web-application.d.ts.map +1 -0
- package/dist/application/web-application.interface.d.ts +21 -0
- package/dist/application/web-application.interface.d.ts.map +1 -0
- package/dist/application/web-application.js +1 -0
- package/dist/application/web-application.js.map +2 -2
- package/dist/auth/index.d.ts +2 -0
- package/dist/auth/index.d.ts.map +1 -0
- package/dist/auth/jwt.d.ts +25 -0
- package/dist/auth/jwt.d.ts.map +1 -0
- package/dist/cache/index.d.ts +2 -0
- package/dist/cache/index.d.ts.map +1 -0
- package/dist/cache/manager.d.ts +107 -0
- package/dist/cache/manager.d.ts.map +1 -0
- package/dist/cli/index.d.ts +2 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +5655 -0
- package/dist/cli/index.js.map +7 -0
- package/dist/cluster/cluster-manager.d.ts +15 -0
- package/dist/cluster/cluster-manager.d.ts.map +1 -0
- package/dist/cluster/cluster-manager.interface.d.ts +23 -0
- package/dist/cluster/cluster-manager.interface.d.ts.map +1 -0
- package/dist/cluster/index.d.ts +2 -0
- package/dist/cluster/index.d.ts.map +1 -0
- package/dist/command/command-manager.d.ts +19 -0
- package/dist/command/command-manager.d.ts.map +1 -0
- package/dist/command/command.d.ts +27 -0
- package/dist/command/command.d.ts.map +1 -0
- package/dist/command/command.interface.d.ts +11 -0
- package/dist/command/command.interface.d.ts.map +1 -0
- package/dist/command/index.d.ts +3 -0
- package/dist/command/index.d.ts.map +1 -0
- package/dist/config/env.d.ts +11 -0
- package/dist/config/env.d.ts.map +1 -0
- package/dist/config/index.d.ts +3 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/schema.d.ts +432 -0
- package/dist/config/schema.d.ts.map +1 -0
- package/dist/database/dynamic-entity-form-decorators.d.ts +31 -0
- package/dist/database/dynamic-entity-form-decorators.d.ts.map +1 -0
- package/dist/database/dynamic-entity.d.ts +15 -0
- package/dist/database/dynamic-entity.d.ts.map +1 -0
- package/dist/database/index.d.ts +5 -0
- package/dist/database/index.d.ts.map +1 -0
- package/dist/database/instance.d.ts +36 -0
- package/dist/database/instance.d.ts.map +1 -0
- package/dist/database/instance.interface.d.ts +5 -0
- package/dist/database/instance.interface.d.ts.map +1 -0
- package/dist/database/manager.d.ts +27 -0
- package/dist/database/manager.d.ts.map +1 -0
- package/dist/database/manager.interface.d.ts +18 -0
- package/dist/database/manager.interface.d.ts.map +1 -0
- package/dist/error/error-reporter.d.ts +96 -0
- package/dist/error/error-reporter.d.ts.map +1 -0
- package/dist/error/error.interface.d.ts +126 -0
- package/dist/error/error.interface.d.ts.map +1 -0
- package/dist/error/framework-errors.d.ts +113 -0
- package/dist/error/framework-errors.d.ts.map +1 -0
- package/dist/error/index.d.ts +6 -0
- package/dist/error/index.d.ts.map +1 -0
- package/dist/event/controller/base.d.ts +23 -0
- package/dist/event/controller/base.d.ts.map +1 -0
- package/dist/event/controller/base.interface.d.ts +11 -0
- package/dist/event/controller/base.interface.d.ts.map +1 -0
- package/dist/event/index.d.ts +5 -0
- package/dist/event/index.d.ts.map +1 -0
- package/dist/event/manager.d.ts +21 -0
- package/dist/event/manager.d.ts.map +1 -0
- package/dist/event/manager.interface.d.ts +137 -0
- package/dist/event/manager.interface.d.ts.map +1 -0
- package/dist/index.d.ts +22 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/lifecycle/exit.d.ts +11 -0
- package/dist/lifecycle/exit.d.ts.map +1 -0
- package/dist/lifecycle/index.d.ts +7 -0
- package/dist/lifecycle/index.d.ts.map +1 -0
- package/dist/lifecycle/lifecycle-manager.d.ts +66 -0
- package/dist/lifecycle/lifecycle-manager.d.ts.map +1 -0
- package/dist/lifecycle/lifecycle-manager.js +6 -11
- package/dist/lifecycle/lifecycle-manager.js.map +2 -2
- package/dist/lifecycle/shutdown-controller.d.ts +15 -0
- package/dist/lifecycle/shutdown-controller.d.ts.map +1 -0
- package/dist/lifecycle/types.d.ts +28 -0
- package/dist/lifecycle/types.d.ts.map +1 -0
- package/dist/logger/index.d.ts +2 -0
- package/dist/logger/index.d.ts.map +1 -0
- package/dist/logger/logger.d.ts +59 -0
- package/dist/logger/logger.d.ts.map +1 -0
- package/dist/logger/logger.interface.d.ts +2 -0
- package/dist/logger/logger.interface.d.ts.map +1 -0
- package/dist/logger/logger.js +8 -1
- package/dist/logger/logger.js.map +2 -2
- package/dist/performance/cache-performance.d.ts +64 -0
- package/dist/performance/cache-performance.d.ts.map +1 -0
- package/dist/performance/database-performance.d.ts +40 -0
- package/dist/performance/database-performance.d.ts.map +1 -0
- package/dist/performance/index.d.ts +8 -0
- package/dist/performance/index.d.ts.map +1 -0
- package/dist/performance/performance-monitor.d.ts +68 -0
- package/dist/performance/performance-monitor.d.ts.map +1 -0
- package/dist/performance/performance-monitor.plugin.d.ts +24 -0
- package/dist/performance/performance-monitor.plugin.d.ts.map +1 -0
- package/dist/performance/queue-performance.d.ts +46 -0
- package/dist/performance/queue-performance.d.ts.map +1 -0
- package/dist/performance/webserver-performance.d.ts +69 -0
- package/dist/performance/webserver-performance.d.ts.map +1 -0
- package/dist/performance/websocket-performance.d.ts +44 -0
- package/dist/performance/websocket-performance.d.ts.map +1 -0
- package/dist/queue/index.d.ts +6 -0
- package/dist/queue/index.d.ts.map +1 -0
- package/dist/queue/index.interface.d.ts +10 -0
- package/dist/queue/index.interface.d.ts.map +1 -0
- package/dist/queue/job.interface.d.ts +43 -0
- package/dist/queue/job.interface.d.ts.map +1 -0
- package/dist/queue/manager.d.ts +44 -0
- package/dist/queue/manager.d.ts.map +1 -0
- package/dist/queue/manager.interface.d.ts +18 -0
- package/dist/queue/manager.interface.d.ts.map +1 -0
- package/dist/queue/processor/base.d.ts +29 -0
- package/dist/queue/processor/base.d.ts.map +1 -0
- package/dist/queue/processor/processor.interface.d.ts +16 -0
- package/dist/queue/processor/processor.interface.d.ts.map +1 -0
- package/dist/queue/worker.d.ts +14 -0
- package/dist/queue/worker.d.ts.map +1 -0
- package/dist/queue/worker.interface.d.ts +13 -0
- package/dist/queue/worker.interface.d.ts.map +1 -0
- package/dist/redis/index.d.ts +3 -0
- package/dist/redis/index.d.ts.map +1 -0
- package/dist/redis/instance.d.ts +32 -0
- package/dist/redis/instance.d.ts.map +1 -0
- package/dist/redis/instance.interface.d.ts +9 -0
- package/dist/redis/instance.interface.d.ts.map +1 -0
- package/dist/redis/manager.d.ts +15 -0
- package/dist/redis/manager.d.ts.map +1 -0
- package/dist/redis/manager.interface.d.ts +8 -0
- package/dist/redis/manager.interface.d.ts.map +1 -0
- package/dist/redis/manager.js +13 -14
- package/dist/redis/manager.js.map +2 -2
- package/dist/request-context/index.d.ts +3 -0
- package/dist/request-context/index.d.ts.map +1 -0
- package/dist/request-context/request-context.d.ts +108 -0
- package/dist/request-context/request-context.d.ts.map +1 -0
- package/dist/request-context/request-context.interface.d.ts +46 -0
- package/dist/request-context/request-context.interface.d.ts.map +1 -0
- package/dist/services/aws/index.d.ts +2 -0
- package/dist/services/aws/index.d.ts.map +1 -0
- package/dist/services/aws/s3.d.ts +54 -0
- package/dist/services/aws/s3.d.ts.map +1 -0
- package/dist/services/aws/s3.interface.d.ts +14 -0
- package/dist/services/aws/s3.interface.d.ts.map +1 -0
- package/dist/services/index.d.ts +2 -0
- package/dist/services/index.d.ts.map +1 -0
- package/dist/util/file.d.ts +58 -0
- package/dist/util/file.d.ts.map +1 -0
- package/dist/util/helper.d.ts +51 -0
- package/dist/util/helper.d.ts.map +1 -0
- package/dist/util/helper.js +72 -10
- package/dist/util/helper.js.map +2 -2
- package/dist/util/image.d.ts +12 -0
- package/dist/util/image.d.ts.map +1 -0
- package/dist/util/index.d.ts +11 -0
- package/dist/util/index.d.ts.map +1 -0
- package/dist/util/loader.d.ts +21 -0
- package/dist/util/loader.d.ts.map +1 -0
- package/dist/util/loader.js +5 -2
- package/dist/util/loader.js.map +2 -2
- package/dist/util/num.d.ts +13 -0
- package/dist/util/num.d.ts.map +1 -0
- package/dist/util/os.d.ts +6 -0
- package/dist/util/os.d.ts.map +1 -0
- package/dist/util/str.d.ts +39 -0
- package/dist/util/str.d.ts.map +1 -0
- package/dist/util/time.d.ts +19 -0
- package/dist/util/time.d.ts.map +1 -0
- package/dist/util/time.interface.d.ts +12 -0
- package/dist/util/time.interface.d.ts.map +1 -0
- package/dist/util/timing.d.ts +36 -0
- package/dist/util/timing.d.ts.map +1 -0
- package/dist/util/timing.interface.d.ts +47 -0
- package/dist/util/timing.interface.d.ts.map +1 -0
- package/dist/util/url.d.ts +7 -0
- package/dist/util/url.d.ts.map +1 -0
- package/dist/webserver/controller/auth-middleware.d.ts +21 -0
- package/dist/webserver/controller/auth-middleware.d.ts.map +1 -0
- package/dist/webserver/controller/base.d.ts +41 -0
- package/dist/webserver/controller/base.d.ts.map +1 -0
- package/dist/webserver/controller/base.interface.d.ts +50 -0
- package/dist/webserver/controller/base.interface.d.ts.map +1 -0
- package/dist/webserver/controller/entity.d.ts +94 -0
- package/dist/webserver/controller/entity.d.ts.map +1 -0
- package/dist/webserver/controller/example-auth.d.ts +12 -0
- package/dist/webserver/controller/example-auth.d.ts.map +1 -0
- package/dist/webserver/controller/health.d.ts +15 -0
- package/dist/webserver/controller/health.d.ts.map +1 -0
- package/dist/webserver/define-action.d.ts +26 -0
- package/dist/webserver/define-action.d.ts.map +1 -0
- package/dist/webserver/define-action.js +16 -0
- package/dist/webserver/define-action.js.map +7 -0
- package/dist/webserver/define-route.d.ts +53 -0
- package/dist/webserver/define-route.d.ts.map +1 -0
- package/dist/webserver/define-route.js +11 -6
- package/dist/webserver/define-route.js.map +2 -2
- package/dist/webserver/index.d.ts +14 -0
- package/dist/webserver/index.d.ts.map +1 -0
- package/dist/webserver/index.js +2 -0
- package/dist/webserver/index.js.map +2 -2
- package/dist/webserver/util.d.ts +10 -0
- package/dist/webserver/util.d.ts.map +1 -0
- package/dist/webserver/util.js +5 -2
- package/dist/webserver/util.js.map +2 -2
- package/dist/webserver/webserver.d.ts +93 -0
- package/dist/webserver/webserver.d.ts.map +1 -0
- package/dist/webserver/webserver.interface.d.ts +181 -0
- package/dist/webserver/webserver.interface.d.ts.map +1 -0
- package/dist/webserver/webserver.interface.js.map +1 -1
- package/dist/webserver/webserver.js +28 -31
- package/dist/webserver/webserver.js.map +2 -2
- package/dist/websocket/controller/client/base.d.ts +12 -0
- package/dist/websocket/controller/client/base.d.ts.map +1 -0
- package/dist/websocket/controller/client/base.interface.d.ts +12 -0
- package/dist/websocket/controller/client/base.interface.d.ts.map +1 -0
- package/dist/websocket/controller/server/base.d.ts +13 -0
- package/dist/websocket/controller/server/base.d.ts.map +1 -0
- package/dist/websocket/controller/server/base.interface.d.ts +13 -0
- package/dist/websocket/controller/server/base.interface.d.ts.map +1 -0
- package/dist/websocket/controllers/client/system.d.ts +6 -0
- package/dist/websocket/controllers/client/system.d.ts.map +1 -0
- package/dist/websocket/controllers/server/system.d.ts +7 -0
- package/dist/websocket/controllers/server/system.d.ts.map +1 -0
- package/dist/websocket/index.d.ts +7 -0
- package/dist/websocket/index.d.ts.map +1 -0
- package/dist/websocket/routes/client/system.d.ts +3 -0
- package/dist/websocket/routes/client/system.d.ts.map +1 -0
- package/dist/websocket/routes/server/system.d.ts +3 -0
- package/dist/websocket/routes/server/system.d.ts.map +1 -0
- package/dist/websocket/utils.d.ts +9 -0
- package/dist/websocket/utils.d.ts.map +1 -0
- package/dist/websocket/websocket-base.d.ts +19 -0
- package/dist/websocket/websocket-base.d.ts.map +1 -0
- package/dist/websocket/websocket-client-manager.d.ts +53 -0
- package/dist/websocket/websocket-client-manager.d.ts.map +1 -0
- package/dist/websocket/websocket-client-manager.interface.d.ts +8 -0
- package/dist/websocket/websocket-client-manager.interface.d.ts.map +1 -0
- package/dist/websocket/websocket-client.d.ts +35 -0
- package/dist/websocket/websocket-client.d.ts.map +1 -0
- package/dist/websocket/websocket-client.interface.d.ts +14 -0
- package/dist/websocket/websocket-client.interface.d.ts.map +1 -0
- package/dist/websocket/websocket-room-manager.d.ts +32 -0
- package/dist/websocket/websocket-room-manager.d.ts.map +1 -0
- package/dist/websocket/websocket-server.d.ts +92 -0
- package/dist/websocket/websocket-server.d.ts.map +1 -0
- package/dist/websocket/websocket-server.interface.d.ts +16 -0
- package/dist/websocket/websocket-server.interface.d.ts.map +1 -0
- package/dist/websocket/websocket-server.js +33 -9
- package/dist/websocket/websocket-server.js.map +2 -2
- package/dist/websocket/websocket-service.d.ts +44 -0
- package/dist/websocket/websocket-service.d.ts.map +1 -0
- package/dist/websocket/websocket.interface.d.ts +124 -0
- package/dist/websocket/websocket.interface.d.ts.map +1 -0
- package/package.json +13 -13
- package/pxl.js +0 -4
package/README.md
CHANGED
|
@@ -152,33 +152,146 @@ await app.queue.manager.addJobToQueue({
|
|
|
152
152
|
});
|
|
153
153
|
```
|
|
154
154
|
|
|
155
|
+
### Simple Load Test
|
|
156
|
+
|
|
157
|
+
Run lightweight load against any endpoint while iterating locally:
|
|
158
|
+
|
|
159
|
+
```bash
|
|
160
|
+
npm run load:test -- --url http://localhost:3000/health --requests 200 --concurrency 10
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
Switch to a time-based stream for soak-style checks:
|
|
164
|
+
|
|
165
|
+
```bash
|
|
166
|
+
npm run load:test -- --url http://localhost:3000/api/users --duration 30 --concurrency 8 --method POST --body '{"name":"Test"}' --header 'Content-Type: application/json'
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
The script reports latency percentiles, status code counts, and a few failure samples for quick feedback.
|
|
170
|
+
|
|
155
171
|
### WebSocket Server
|
|
156
172
|
|
|
173
|
+
Real-time bidirectional communication with room support and authentication:
|
|
174
|
+
|
|
157
175
|
```typescript
|
|
158
176
|
import { WebApplication } from '@scpxl/nodejs-framework';
|
|
177
|
+
import { WebSocketServerBaseController } from '@scpxl/nodejs-framework/websocket';
|
|
178
|
+
import type { WebSocket } from 'ws';
|
|
179
|
+
|
|
180
|
+
// Create WebSocket controller
|
|
181
|
+
class ChatController extends WebSocketServerBaseController {
|
|
182
|
+
public send = (ws: WebSocket, clientId: string, data: any) => {
|
|
183
|
+
// Broadcast to all clients
|
|
184
|
+
this.webSocketServer.sendMessageToAll({
|
|
185
|
+
data: {
|
|
186
|
+
type: 'chat',
|
|
187
|
+
action: 'message',
|
|
188
|
+
data: {
|
|
189
|
+
clientId,
|
|
190
|
+
text: data.text,
|
|
191
|
+
timestamp: new Date().toISOString(),
|
|
192
|
+
},
|
|
193
|
+
},
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
return { success: true };
|
|
197
|
+
};
|
|
198
|
+
}
|
|
159
199
|
|
|
160
200
|
const app = new WebApplication({
|
|
161
201
|
name: 'chat-app',
|
|
162
202
|
webserver: { port: 3000 },
|
|
163
|
-
websocket: {
|
|
203
|
+
websocket: {
|
|
204
|
+
enabled: true,
|
|
205
|
+
type: 'server',
|
|
206
|
+
url: 'ws://localhost:3000/ws',
|
|
207
|
+
controllersDirectory: './controllers',
|
|
208
|
+
routes: [
|
|
209
|
+
{
|
|
210
|
+
type: 'chat',
|
|
211
|
+
action: 'send',
|
|
212
|
+
controllerName: 'chat',
|
|
213
|
+
controller: ChatController,
|
|
214
|
+
},
|
|
215
|
+
],
|
|
216
|
+
// Optional: JWT authentication
|
|
217
|
+
// Clients connect with: ws://localhost:3000/ws?token=<jwt>
|
|
218
|
+
events: {
|
|
219
|
+
onConnected: ({ ws, clientId }) => {
|
|
220
|
+
console.log('Client connected:', clientId);
|
|
221
|
+
ws.send(
|
|
222
|
+
JSON.stringify({
|
|
223
|
+
type: 'system',
|
|
224
|
+
action: 'connected',
|
|
225
|
+
data: { clientId, message: 'Welcome!' },
|
|
226
|
+
}),
|
|
227
|
+
);
|
|
228
|
+
},
|
|
229
|
+
},
|
|
230
|
+
},
|
|
164
231
|
redis: { host: '127.0.0.1', port: 6379 },
|
|
232
|
+
auth: {
|
|
233
|
+
jwtSecretKey: process.env.JWT_SECRET || 'your-secret-key',
|
|
234
|
+
},
|
|
165
235
|
});
|
|
166
236
|
|
|
167
237
|
await app.start();
|
|
238
|
+
console.log('WebSocket server running at ws://localhost:3000/ws');
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
#### Using Rooms
|
|
242
|
+
|
|
243
|
+
```typescript
|
|
244
|
+
// Client joins a room (built-in system controller)
|
|
245
|
+
// Send from client: { type: 'system', action: 'joinRoom', data: { roomName: 'general', username: 'Alice' } }
|
|
246
|
+
|
|
247
|
+
// Server-side: Broadcast to room members
|
|
248
|
+
const roomClients = app.websocket.server.rooms.get('general');
|
|
249
|
+
roomClients?.forEach(clientId => {
|
|
250
|
+
const client = app.websocket.server.clientManager.getClient({ clientId });
|
|
251
|
+
if (client?.ws) {
|
|
252
|
+
app.websocket.server.sendClientMessage(client.ws, {
|
|
253
|
+
type: 'room',
|
|
254
|
+
action: 'message',
|
|
255
|
+
data: { text: 'Room-specific announcement' },
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
});
|
|
259
|
+
```
|
|
168
260
|
|
|
169
|
-
|
|
170
|
-
app.websocket.server.onConnection(client => {
|
|
171
|
-
console.log('Client connected:', client.id);
|
|
261
|
+
#### Using WebSocket Service
|
|
172
262
|
|
|
173
|
-
|
|
263
|
+
Simplified API for common operations:
|
|
174
264
|
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
265
|
+
```typescript
|
|
266
|
+
import { WebSocketService } from '@scpxl/nodejs-framework/websocket';
|
|
267
|
+
|
|
268
|
+
const wsService = new WebSocketService({
|
|
269
|
+
webSocketServer: app.websocket.server,
|
|
270
|
+
redisInstance: app.redis.instance,
|
|
271
|
+
workerId: String(process.pid),
|
|
179
272
|
});
|
|
273
|
+
|
|
274
|
+
// Broadcast to all clients
|
|
275
|
+
await wsService.broadcast({
|
|
276
|
+
type: 'notification',
|
|
277
|
+
action: 'alert',
|
|
278
|
+
data: { message: 'New features available!' },
|
|
279
|
+
});
|
|
280
|
+
|
|
281
|
+
// Send to specific rooms
|
|
282
|
+
await wsService.sendToRooms(['vip', 'premium'], {
|
|
283
|
+
type: 'offer',
|
|
284
|
+
action: 'new',
|
|
285
|
+
data: { discount: 20 },
|
|
286
|
+
});
|
|
287
|
+
|
|
288
|
+
// Convenience methods
|
|
289
|
+
await wsService.sendUserMessage('profileUpdated', { userId: 123 });
|
|
290
|
+
await wsService.sendSystemMessage('maintenance', { minutes: 5 });
|
|
180
291
|
```
|
|
181
292
|
|
|
293
|
+
See the [WebSocket Guide](./docs/guides/websocket.md) for complete documentation.
|
|
294
|
+
|
|
182
295
|
---
|
|
183
296
|
|
|
184
297
|
## 📚 Documentation
|
|
@@ -336,6 +449,51 @@ See [examples/README.md](examples/README.md) for more details.
|
|
|
336
449
|
|
|
337
450
|
## 🛠️ Development
|
|
338
451
|
|
|
452
|
+
### CLI (`pxl`)
|
|
453
|
+
|
|
454
|
+
The framework now ships with a bundled CLI executable exposed as `pxl` when the package is installed.
|
|
455
|
+
|
|
456
|
+
Current capabilities:
|
|
457
|
+
|
|
458
|
+
- `pxl --version` / `pxl -v` / `pxl version` – Print framework version
|
|
459
|
+
- `pxl info` (or just `pxl`) – Display banner + roadmap
|
|
460
|
+
|
|
461
|
+
Planned subcommands (roadmap):
|
|
462
|
+
|
|
463
|
+
- `pxl doctor` – Environment diagnostics (Node version, dependency checks, Redis/Postgres availability)
|
|
464
|
+
- `pxl generate` – Scaffolding for applications, routes, commands, processors
|
|
465
|
+
- `pxl analyze` – Project inspection (unused files, dependency graph summary)
|
|
466
|
+
|
|
467
|
+
Usage examples:
|
|
468
|
+
|
|
469
|
+
```bash
|
|
470
|
+
# Show version
|
|
471
|
+
pxl --version
|
|
472
|
+
|
|
473
|
+
# Show framework banner and roadmap
|
|
474
|
+
pxl info
|
|
475
|
+
|
|
476
|
+
# (Future) Run doctor diagnostics
|
|
477
|
+
pxl doctor
|
|
478
|
+
```
|
|
479
|
+
|
|
480
|
+
Development Note:
|
|
481
|
+
|
|
482
|
+
When iterating locally, rebuild after CLI changes:
|
|
483
|
+
|
|
484
|
+
```bash
|
|
485
|
+
npm run build && pxl info
|
|
486
|
+
```
|
|
487
|
+
|
|
488
|
+
To test unpublished changes in another project via yalc:
|
|
489
|
+
|
|
490
|
+
```bash
|
|
491
|
+
npm run build:local
|
|
492
|
+
yalc add @scpxl/nodejs-framework
|
|
493
|
+
```
|
|
494
|
+
|
|
495
|
+
For contributions adding new subcommands, implement them in `src/cli/` and register via the yargs builder in `src/cli/index.ts`.
|
|
496
|
+
|
|
339
497
|
### Build Commands
|
|
340
498
|
|
|
341
499
|
```bash
|
|
@@ -380,6 +538,38 @@ npm run test:ui
|
|
|
380
538
|
|
|
381
539
|
The framework maintains **80% code coverage** across all metrics (lines, branches, functions, statements) as enforced by Vitest thresholds.
|
|
382
540
|
|
|
541
|
+
### Framework Status Report
|
|
542
|
+
|
|
543
|
+
Generate a cross-platform project health snapshot (dependency counts, git status, directory sizes, large packages, outdated/age metrics):
|
|
544
|
+
|
|
545
|
+
```bash
|
|
546
|
+
npm run status
|
|
547
|
+
```
|
|
548
|
+
|
|
549
|
+
Optional flags:
|
|
550
|
+
|
|
551
|
+
```bash
|
|
552
|
+
npm run status -- --include-cache # Include .turbo/ and .next/cache directories
|
|
553
|
+
npm run status -- --exclude "coverage,fixtures,**/*.snap" # Additional exclude globs (comma-separated)
|
|
554
|
+
```
|
|
555
|
+
|
|
556
|
+
What it does:
|
|
557
|
+
|
|
558
|
+
- Collects repo & package metadata (version, scripts, dependency counts)
|
|
559
|
+
- Summarizes current git branch, last commit, and pending change counts
|
|
560
|
+
- Computes sizes for `src`, `dist`, and `node_modules` using fast native traversal (`fast-folder-size`) with a JS fallback, filtering via `.gitignore` / `.npmignore` plus exclusions
|
|
561
|
+
- Lists the largest packages in `node_modules` (top 8 by size)
|
|
562
|
+
- Ranks outdated dependencies by publish age and major version lag (uses `npm outdated` / `npm view`)
|
|
563
|
+
- Provides age distribution stats for installed top-level packages
|
|
564
|
+
|
|
565
|
+
Exclusions & Ignore Behavior:
|
|
566
|
+
|
|
567
|
+
- Always respects patterns found in `.gitignore` and `.npmignore` (except always keeps top-level `dist` & `node_modules`)
|
|
568
|
+
- Built-in default excludes: `coverage/`, `fixtures/`, and `**/*.snap`
|
|
569
|
+
- Skips heavy build caches (`.turbo`, `.next/cache`) unless `--include-cache` is passed
|
|
570
|
+
|
|
571
|
+
Return codes: exits with non-zero only on unexpected internal errors; missing npm or network failures simply degrade sections gracefully.
|
|
572
|
+
|
|
383
573
|
### Local Development with Yalc
|
|
384
574
|
|
|
385
575
|
For testing changes in consuming applications:
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export interface ApiRequestConfig extends Omit<RequestInit, 'method' | 'body' | 'headers'> {
|
|
2
|
+
headers?: Record<string, string | undefined>;
|
|
3
|
+
params?: Record<string, string | number | boolean | null | undefined>;
|
|
4
|
+
responseType?: 'json' | 'text';
|
|
5
|
+
}
|
|
6
|
+
export interface ApiResponse<T> {
|
|
7
|
+
data: T;
|
|
8
|
+
status: number;
|
|
9
|
+
statusText: string;
|
|
10
|
+
headers: Record<string, string>;
|
|
11
|
+
}
|
|
12
|
+
export default class ApiRequester {
|
|
13
|
+
private readonly baseURL;
|
|
14
|
+
private readonly defaultHeaders;
|
|
15
|
+
constructor(baseURL: string, headers?: Record<string, string>);
|
|
16
|
+
get<T>(url: string, config?: ApiRequestConfig): Promise<ApiResponse<T> | undefined>;
|
|
17
|
+
post<T, R>(url: string, data: T, config?: ApiRequestConfig): Promise<ApiResponse<R> | undefined>;
|
|
18
|
+
put<T, R>(url: string, data: T, config?: ApiRequestConfig): Promise<ApiResponse<R> | undefined>;
|
|
19
|
+
delete<T>(url: string, config?: ApiRequestConfig): Promise<ApiResponse<T> | undefined>;
|
|
20
|
+
private request;
|
|
21
|
+
private mergeHeaders;
|
|
22
|
+
private prepareBody;
|
|
23
|
+
private shouldSerializeAsJson;
|
|
24
|
+
private headersToRecord;
|
|
25
|
+
private buildUrl;
|
|
26
|
+
private isAbsoluteUrl;
|
|
27
|
+
private combineWithBase;
|
|
28
|
+
private parseResponse;
|
|
29
|
+
private createHttpError;
|
|
30
|
+
private handleError;
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=api-requester.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api-requester.d.ts","sourceRoot":"","sources":["../../src/api-requester/api-requester.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,gBAAiB,SAAQ,IAAI,CAAC,WAAW,EAAE,QAAQ,GAAG,MAAM,GAAG,SAAS,CAAC;IACxF,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;IAC7C,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,SAAS,CAAC,CAAC;IACtE,YAAY,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;CAChC;AAED,MAAM,WAAW,WAAW,CAAC,CAAC;IAC5B,IAAI,EAAE,CAAC,CAAC;IACR,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;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Root":"","sources":["../../src/api-requester/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAC7D,YAAY,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { type DatabaseInstance, DatabaseManager } from '../database/index.js';
|
|
2
|
+
import QueueManager from '../queue/manager.js';
|
|
3
|
+
import RedisManager from '../redis/manager.js';
|
|
4
|
+
import type { ApplicationConfig, ApplicationStopInstanceOptions } from './base-application.interface.js';
|
|
5
|
+
import type RedisInstance from '../redis/instance.js';
|
|
6
|
+
import CacheManager from '../cache/manager.js';
|
|
7
|
+
import EventManager from '../event/manager.js';
|
|
8
|
+
import type { PerformanceMonitor } from '../performance/performance-monitor.js';
|
|
9
|
+
import { LifecycleManager, ShutdownController } from '../lifecycle/index.js';
|
|
10
|
+
export type { ApplicationConfig } from './base-application.interface.js';
|
|
11
|
+
export default abstract class BaseApplication {
|
|
12
|
+
/** Unique instance ID */
|
|
13
|
+
uniqueInstanceId: string;
|
|
14
|
+
/** Application start time */
|
|
15
|
+
protected startTime: number;
|
|
16
|
+
/** Shutdown timeout (30 seconds) */
|
|
17
|
+
protected shutdownTimeout: number;
|
|
18
|
+
/** Cache for application version to avoid repeated imports */
|
|
19
|
+
private static applicationVersionCache;
|
|
20
|
+
/** Cluster worker ID */
|
|
21
|
+
protected workerId: number | null;
|
|
22
|
+
/** Application config */
|
|
23
|
+
protected config: ApplicationConfig;
|
|
24
|
+
/** Application version */
|
|
25
|
+
protected applicationVersion?: string;
|
|
26
|
+
/** Redis manager */
|
|
27
|
+
redisManager: RedisManager;
|
|
28
|
+
/** Cache manager */
|
|
29
|
+
cacheManager: CacheManager;
|
|
30
|
+
/** Database manager */
|
|
31
|
+
databaseManager?: DatabaseManager;
|
|
32
|
+
/** Queue manager */
|
|
33
|
+
queueManager?: QueueManager;
|
|
34
|
+
/** Event manager */
|
|
35
|
+
eventManager?: EventManager;
|
|
36
|
+
/** Performance monitor */
|
|
37
|
+
performanceMonitor?: PerformanceMonitor;
|
|
38
|
+
/** Lifecycle manager */
|
|
39
|
+
lifecycle: LifecycleManager;
|
|
40
|
+
/** Shutdown controller */
|
|
41
|
+
shutdownController: ShutdownController;
|
|
42
|
+
get Name(): string;
|
|
43
|
+
/**
|
|
44
|
+
* Application constructor
|
|
45
|
+
*/
|
|
46
|
+
constructor(config: ApplicationConfig);
|
|
47
|
+
/**
|
|
48
|
+
* Get application version
|
|
49
|
+
*/
|
|
50
|
+
getApplicationVersion(): Promise<string>;
|
|
51
|
+
/**
|
|
52
|
+
* Start application
|
|
53
|
+
*/
|
|
54
|
+
start(): Promise<void>;
|
|
55
|
+
/**
|
|
56
|
+
* Before application start
|
|
57
|
+
*/
|
|
58
|
+
private onBeforeStart;
|
|
59
|
+
/**
|
|
60
|
+
* Application started event
|
|
61
|
+
*/
|
|
62
|
+
protected onStarted({ startupTime: _startupTime }: {
|
|
63
|
+
startupTime: number;
|
|
64
|
+
}): void;
|
|
65
|
+
/**
|
|
66
|
+
* Application stopped event
|
|
67
|
+
*/
|
|
68
|
+
protected onStopped({ runtime: _runtime }: {
|
|
69
|
+
runtime: number;
|
|
70
|
+
}): void;
|
|
71
|
+
/**
|
|
72
|
+
* Start application instance
|
|
73
|
+
*/
|
|
74
|
+
private startInstance;
|
|
75
|
+
protected abstract startHandler({ redisInstance, databaseInstance, queueManager, eventManager, }: {
|
|
76
|
+
redisInstance: RedisInstance;
|
|
77
|
+
databaseInstance?: DatabaseInstance | null;
|
|
78
|
+
queueManager: QueueManager;
|
|
79
|
+
eventManager?: EventManager | null;
|
|
80
|
+
}): Promise<void>;
|
|
81
|
+
protected abstract stopCallback(): void;
|
|
82
|
+
/**
|
|
83
|
+
* Set up global error handlers
|
|
84
|
+
*/
|
|
85
|
+
/**
|
|
86
|
+
* Initialize performance monitor
|
|
87
|
+
*/
|
|
88
|
+
private setupGlobalErrorHandlers;
|
|
89
|
+
/**
|
|
90
|
+
* Register shutdown hooks for proper cleanup
|
|
91
|
+
*/
|
|
92
|
+
private registerShutdownHooks;
|
|
93
|
+
/**
|
|
94
|
+
* Initiate graceful shutdown
|
|
95
|
+
*/
|
|
96
|
+
private initiateGracefulShutdown;
|
|
97
|
+
/**
|
|
98
|
+
* Stop application using lifecycle manager
|
|
99
|
+
*/
|
|
100
|
+
stop({ onStopped }?: ApplicationStopInstanceOptions): Promise<void>;
|
|
101
|
+
/**
|
|
102
|
+
* Finalize exit: during tests, suppress actual process exit to avoid failing vitest runs.
|
|
103
|
+
*/
|
|
104
|
+
private finalizeExit;
|
|
105
|
+
}
|
|
106
|
+
//# sourceMappingURL=base-application.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base-application.d.ts","sourceRoot":"","sources":["../../src/application/base-application.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,gBAAgB,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAC9E,OAAO,YAAY,MAAM,qBAAqB,CAAC;AAC/C,OAAO,YAAY,MAAM,qBAAqB,CAAC;AAC/C,OAAO,KAAK,EACV,iBAAiB,EAEjB,8BAA8B,EAC/B,MAAM,iCAAiC,CAAC;AAEzC,OAAO,KAAK,aAAa,MAAM,sBAAsB,CAAC;AAEtD,OAAO,YAAY,MAAM,qBAAqB,CAAC;AAE/C,OAAO,YAAY,MAAM,qBAAqB,CAAC;AAE/C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,uCAAuC,CAAC;AAGhF,OAAO,EAAwB,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAKnG,YAAY,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AAEzE,MAAM,CAAC,OAAO,CAAC,QAAQ,OAAO,eAAe;IAC3C,yBAAyB;IAClB,gBAAgB,EAAE,MAAM,CAAC;IAEhC,6BAA6B;IAC7B,SAAS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AAY,CAAC,EAC9B,aAAa,EACb,gBAAgB,EAChB,YAAY,EACZ,YAAY,GACb,EAAE;QACD,aAAa,EAAE,aAAa,CAAC;QAC7B,gBAAgB,CAAC,EAAE,gBAAgB,GAAG,IAAI,CAAC;QAC3C,YAAY,EAAE,YAAY,CAAC;QAC3B,YAAY,CAAC,EAAE,YAAY,GAAG,IAAI,CAAC;KACpC,GAAG,OAAO,CAAC,IAAI,CAAC;IAEjB,SAAS,CAAC,QAAQ,CAAC,YAAY,IAAI,IAAI;IAEvC;;OAEG;IACH;;OAEG;IAIH,OAAO,CAAC,wBAAwB;IAkBhC;;OAEG;IACH,OAAO,CAAC,qBAAqB;IAwB7B;;OAEG;YACW,wBAAwB;IA6BtC;;OAEG;IACU,IAAI,CAAC,EAAE,SAAS,EAAE,GAAE,8BAAmC,GAAG,OAAO,CAAC,IAAI,CAAC;IAoCpF;;OAEG;IACH,OAAO,CAAC,YAAY;CAerB"}
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import type { ClusterManagerConfig } from '../cluster/cluster-manager.interface.js';
|
|
2
|
+
import type DatabaseInstance from '../database/instance.js';
|
|
3
|
+
import type { EventDefinition } from '../event/manager.interface.js';
|
|
4
|
+
import type { PerformanceMonitorOptions, PerformanceThresholds } from '../performance/performance-monitor.js';
|
|
5
|
+
import type { QueueItem } from '../queue/index.interface.js';
|
|
6
|
+
import type { WebServerDebugOptions, WebServerLogConfig, WebServerOptions, WebServerRoute } from '../webserver/webserver.interface.js';
|
|
7
|
+
import type WebSocketServer from '../websocket/websocket-server.js';
|
|
8
|
+
import type { WebSocketOptions, WebSocketRoute, WebSocketType } from '../websocket/websocket.interface.js';
|
|
9
|
+
export type OnStartedEvent = ({ startupTime }: {
|
|
10
|
+
startupTime: number;
|
|
11
|
+
}) => void;
|
|
12
|
+
export type OnStoppedEvent = ({ runtime }: {
|
|
13
|
+
runtime: number;
|
|
14
|
+
}) => void;
|
|
15
|
+
export interface ApplicationStartInstanceOptions {
|
|
16
|
+
/** On started event */
|
|
17
|
+
onStarted?: OnStartedEvent;
|
|
18
|
+
}
|
|
19
|
+
export interface ApplicationStopInstanceOptions {
|
|
20
|
+
/** On stopped event */
|
|
21
|
+
onStopped?: OnStoppedEvent;
|
|
22
|
+
}
|
|
23
|
+
export interface ApplicationRedisConfig {
|
|
24
|
+
/** Redis host */
|
|
25
|
+
host: string;
|
|
26
|
+
/** Redis port */
|
|
27
|
+
port: number;
|
|
28
|
+
/** Redis password */
|
|
29
|
+
password?: string;
|
|
30
|
+
}
|
|
31
|
+
export interface ApplicationCacheConfig {
|
|
32
|
+
}
|
|
33
|
+
export interface ApplicationDatabaseConfig {
|
|
34
|
+
/** Whether to enable database */
|
|
35
|
+
enabled: boolean;
|
|
36
|
+
/** Database host */
|
|
37
|
+
host: string;
|
|
38
|
+
/** Database port */
|
|
39
|
+
port: number;
|
|
40
|
+
/** Database username */
|
|
41
|
+
username: string;
|
|
42
|
+
/** Database password */
|
|
43
|
+
password: string;
|
|
44
|
+
/** Database name */
|
|
45
|
+
databaseName: string;
|
|
46
|
+
/** Entities directory */
|
|
47
|
+
entitiesDirectory: string;
|
|
48
|
+
}
|
|
49
|
+
export interface ApplicationQueueConfig {
|
|
50
|
+
/** Initial queues */
|
|
51
|
+
queues: QueueItem[];
|
|
52
|
+
/** Queue processors directory */
|
|
53
|
+
processorsDirectory: string;
|
|
54
|
+
log?: {
|
|
55
|
+
jobRegistered?: boolean;
|
|
56
|
+
jobAdded?: boolean;
|
|
57
|
+
jobCompleted?: boolean;
|
|
58
|
+
queueRegistered?: boolean;
|
|
59
|
+
queuesRegistered?: boolean;
|
|
60
|
+
queueWaiting?: boolean;
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
export interface ApplicationEventConfig {
|
|
64
|
+
/** Whether to enable event system */
|
|
65
|
+
enabled: boolean;
|
|
66
|
+
/** Event controllers directory */
|
|
67
|
+
controllersDirectory: string;
|
|
68
|
+
/** Event definitions */
|
|
69
|
+
events: EventDefinition[];
|
|
70
|
+
}
|
|
71
|
+
export interface ApplicationEmailConfig {
|
|
72
|
+
}
|
|
73
|
+
export interface ApplicationAuthConfig {
|
|
74
|
+
/** JWT secret key for token verification */
|
|
75
|
+
jwtSecretKey: string;
|
|
76
|
+
}
|
|
77
|
+
export interface ApplicationWebSocketConfig extends WebSocketOptions {
|
|
78
|
+
/** WebSocket type */
|
|
79
|
+
type: WebSocketType;
|
|
80
|
+
/** Whether to enable WebSocket */
|
|
81
|
+
enabled: boolean;
|
|
82
|
+
/** WebSocket routes */
|
|
83
|
+
routes: WebSocketRoute[];
|
|
84
|
+
/** WebSocket server message handler */
|
|
85
|
+
serverMessageHandler?: (options: {
|
|
86
|
+
ws: WebSocket;
|
|
87
|
+
clientId: string;
|
|
88
|
+
parsedMessage: any;
|
|
89
|
+
}) => void;
|
|
90
|
+
/** WebSocket subscriber event handler */
|
|
91
|
+
subscriberEventHandler?: (options: {
|
|
92
|
+
channel: string;
|
|
93
|
+
message: any;
|
|
94
|
+
webSocketServer: WebSocketServer;
|
|
95
|
+
databaseInstance: DatabaseInstance;
|
|
96
|
+
}) => void;
|
|
97
|
+
}
|
|
98
|
+
export interface ApplicationWebServerConfig extends WebServerOptions {
|
|
99
|
+
/** Whether to enable web server */
|
|
100
|
+
enabled: boolean;
|
|
101
|
+
/** Web server routes */
|
|
102
|
+
routes: WebServerRoute[];
|
|
103
|
+
log?: WebServerLogConfig;
|
|
104
|
+
debug: WebServerDebugOptions;
|
|
105
|
+
}
|
|
106
|
+
export interface ApplicationCommandsConfig {
|
|
107
|
+
commandsDirectory: string;
|
|
108
|
+
}
|
|
109
|
+
export interface ApplicationLogConfig {
|
|
110
|
+
startUp?: boolean;
|
|
111
|
+
shutdown?: boolean;
|
|
112
|
+
showRequestIdInConsole?: boolean;
|
|
113
|
+
}
|
|
114
|
+
export interface ApplicationPerformanceConfig extends PerformanceMonitorOptions {
|
|
115
|
+
/** Whether to enable performance monitoring */
|
|
116
|
+
enabled?: boolean;
|
|
117
|
+
/** Performance thresholds for different operations */
|
|
118
|
+
thresholds?: Partial<PerformanceThresholds>;
|
|
119
|
+
/** Whether to monitor HTTP requests */
|
|
120
|
+
monitorHttpRequests?: boolean;
|
|
121
|
+
/** Whether to monitor database operations */
|
|
122
|
+
monitorDatabaseOperations?: boolean;
|
|
123
|
+
/** Whether to monitor WebSocket operations */
|
|
124
|
+
monitorWebSocketOperations?: boolean;
|
|
125
|
+
/** Whether to monitor queue operations */
|
|
126
|
+
monitorQueueOperations?: boolean;
|
|
127
|
+
/** Whether to monitor cache operations */
|
|
128
|
+
monitorCacheOperations?: boolean;
|
|
129
|
+
/** Performance report generation interval in milliseconds */
|
|
130
|
+
reportInterval?: number;
|
|
131
|
+
/** Performance report format: 'simple' for one-line, 'detailed' for multi-line */
|
|
132
|
+
reportFormat?: 'simple' | 'detailed';
|
|
133
|
+
}
|
|
134
|
+
export interface ApplicationConfig {
|
|
135
|
+
/** Application name */
|
|
136
|
+
name: string;
|
|
137
|
+
/** Application instance ID */
|
|
138
|
+
instanceId: string;
|
|
139
|
+
/** Root directory */
|
|
140
|
+
rootDirectory: string;
|
|
141
|
+
/** Cluster configuration */
|
|
142
|
+
cluster?: ClusterManagerConfig;
|
|
143
|
+
/** Redis configuration */
|
|
144
|
+
redis: ApplicationRedisConfig;
|
|
145
|
+
/** Cache configuration */
|
|
146
|
+
cache?: ApplicationCacheConfig;
|
|
147
|
+
/** Database configuration */
|
|
148
|
+
database?: ApplicationDatabaseConfig;
|
|
149
|
+
/** Queue configuration */
|
|
150
|
+
queue: ApplicationQueueConfig;
|
|
151
|
+
/** Event configuration */
|
|
152
|
+
event?: ApplicationEventConfig;
|
|
153
|
+
/** Log configuration */
|
|
154
|
+
log?: ApplicationLogConfig;
|
|
155
|
+
/** Performance monitoring configuration */
|
|
156
|
+
performanceMonitoring?: ApplicationPerformanceConfig;
|
|
157
|
+
/** Email configuration */
|
|
158
|
+
email?: ApplicationEmailConfig;
|
|
159
|
+
/** Authentication configuration */
|
|
160
|
+
auth?: ApplicationAuthConfig;
|
|
161
|
+
}
|
|
162
|
+
//# sourceMappingURL=base-application.interface.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base-application.interface.d.ts","sourceRoot":"","sources":["../../src/application/base-application.interface.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,yCAAyC,CAAC;AACpF,OAAO,KAAK,gBAAgB,MAAM,yBAAyB,CAAC;AAC5D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AACrE,OAAO,KAAK,EAAE,yBAAyB,EAAE,qBAAqB,EAAE,MAAM,uCAAuC,CAAC;AAC9G,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,KAAK,EACV,qBAAqB,EACrB,kBAAkB,EAClB,gBAAgB,EAChB,cAAc,EACf,MAAM,qCAAqC,CAAC;AAC7C,OAAO,KAAK,eAAe,MAAM,kCAAkC,CAAC;AACpE,OAAO,KAAK,EAAE,gBAAgB,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,qCAAqC,CAAC;AAE3G,MAAM,MAAM,cAAc,GAAG,CAAC,EAAE,WAAW,EAAE,EAAE;IAAE,WAAW,EAAE,MAAM,CAAA;CAAE,KAAK,IAAI,CAAC;AAChF,MAAM,MAAM,cAAc,GAAG,CAAC,EAAE,OAAO,EAAE,EAAE;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,KAAK,IAAI,CAAC;AAExE,MAAM,WAAW,+BAA+B;IAC9C,uBAAuB;IACvB,SAAS,CAAC,EAAE,cAAc,CAAC;CAC5B;AACD,MAAM,WAAW,8BAA8B;IAC7C,uBAAuB;IACvB,SAAS,CAAC,EAAE,cAAc,CAAC;CAC5B;AAED,MAAM,WAAW,sBAAsB;IACrC,iBAAiB;IACjB,IAAI,EAAE,MAAM,CAAC;IAEb,iBAAiB;IACjB,IAAI,EAA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AErC,0CAA0C;IAC1C,sBAAsB,CAAC,EAAE,OAAO,CAAC;IAEjC,0CAA0C;IAC1C,sBAAsB,CAAC,EAAE,OAAO,CAAC;IAEjC,6DAA6D;IAC7D,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB,kFAAkF;IAClF,YAAY,CAAC,EAAE,QAAQ,GAAG,UAAU,CAAC;CACtC;AAED,MAAM,WAAW,iBAAiB;IAChC,uBAAuB;IACvB,IAAI,EAAE,MAAM,CAAC;IAEb,8BAA8B;IAC9B,UAAU,EAAE,MAAM,CAAC;IAEnB,qBAAqB;IACrB,aAAa,EAAE,MAAM,CAAC;IAEtB,4BAA4B;IAC5B,OAAO,CAAC,EAAE,oBAAoB,CAAC;IAE/B,0BAA0B;IAC1B,KAAK,EAAE,sBAAsB,CAAC;IAE9B,0BAA0B;IAC1B,KAAK,CAAC,EAAE,sBAAsB,CAAC;IAE/B,6BAA6B;IAC7B,QAAQ,CAAC,EAAE,yBAAyB,CAAC;IAErC,0BAA0B;IAC1B,KAAK,EAAE,sBAAsB,CAAC;IAE9B,0BAA0B;IAC1B,KAAK,CAAC,EAAE,sBAAsB,CAAC;IAE/B,wBAAwB;IACxB,GAAG,CAAC,EAAE,oBAAoB,CAAC;IAE3B,2CAA2C;IAC3C,qBAAqB,CAAC,EAAE,4BAA4B,CAAC;IAErD,0BAA0B;IAC1B,KAAK,CAAC,EAAE,sBAAsB,CAAC;IAE/B,mCAAmC;IACnC,IAAI,CAAC,EAAE,qBAAqB,CAAC;CAC9B"}
|
|
@@ -72,6 +72,9 @@ ${formatted}`);
|
|
|
72
72
|
const computerName = os.hostname();
|
|
73
73
|
this.uniqueInstanceId = `${config.instanceId}-${computerName}-${OS.getUniqueComputerId()}`;
|
|
74
74
|
this.config = config;
|
|
75
|
+
if (this.config.log?.showRequestIdInConsole !== void 0) {
|
|
76
|
+
Logger.configure({ showRequestIdInConsole: this.config.log.showRequestIdInConsole });
|
|
77
|
+
}
|
|
75
78
|
const lifecycleConfig = {
|
|
76
79
|
gracefulShutdown: {
|
|
77
80
|
timeoutMs: this.shutdownTimeout
|