@lolyjs/core 0.2.0-alpha.24 → 0.2.0-alpha.26
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.cjs +21 -21
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +21 -21
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +21 -23
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +1 -6
- package/dist/index.d.ts +1 -6
- package/dist/index.js +21 -23
- package/dist/index.js.map +1 -1
- package/dist/react/sockets.cjs +0 -8
- package/dist/react/sockets.cjs.map +1 -1
- package/dist/react/sockets.js +0 -8
- package/dist/react/sockets.js.map +1 -1
- package/dist/runtime.cjs +0 -2
- package/dist/runtime.cjs.map +1 -1
- package/dist/runtime.js +0 -2
- package/dist/runtime.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.cjs
CHANGED
|
@@ -13637,7 +13637,7 @@ var DEFAULT_REALTIME_CONFIG = {
|
|
|
13637
13637
|
burst: 60
|
|
13638
13638
|
},
|
|
13639
13639
|
logging: {
|
|
13640
|
-
level: "info",
|
|
13640
|
+
level: process.env.NODE_ENV === "production" ? "warn" : "info",
|
|
13641
13641
|
pretty: process.env.NODE_ENV !== "production"
|
|
13642
13642
|
}
|
|
13643
13643
|
};
|
|
@@ -17073,7 +17073,6 @@ async function executeGuard(guardFn, ctx) {
|
|
|
17073
17073
|
const guardCtx = {
|
|
17074
17074
|
user: ctx.user,
|
|
17075
17075
|
req: ctx.req,
|
|
17076
|
-
socket: ctx.socket,
|
|
17077
17076
|
namespace: ctx.pathname
|
|
17078
17077
|
};
|
|
17079
17078
|
const result = await guardFn(guardCtx);
|
|
@@ -17108,13 +17107,24 @@ function validateSchema(schema, data) {
|
|
|
17108
17107
|
}
|
|
17109
17108
|
|
|
17110
17109
|
// modules/realtime/logging/index.ts
|
|
17111
|
-
|
|
17110
|
+
var LOG_LEVELS = {
|
|
17111
|
+
debug: 0,
|
|
17112
|
+
info: 1,
|
|
17113
|
+
warn: 2,
|
|
17114
|
+
error: 3
|
|
17115
|
+
};
|
|
17116
|
+
function createWssLogger(namespace, socket, baseLogger, minLevel = "info") {
|
|
17112
17117
|
const context = {
|
|
17113
17118
|
namespace,
|
|
17114
17119
|
socketId: socket.id,
|
|
17115
17120
|
userId: socket.data?.user?.id || null
|
|
17116
17121
|
};
|
|
17122
|
+
const minLevelNum = LOG_LEVELS[minLevel] ?? LOG_LEVELS.info;
|
|
17117
17123
|
const log = (level, message, meta) => {
|
|
17124
|
+
const levelNum = LOG_LEVELS[level] ?? LOG_LEVELS.info;
|
|
17125
|
+
if (levelNum < minLevelNum) {
|
|
17126
|
+
return;
|
|
17127
|
+
}
|
|
17118
17128
|
const fullMeta = {
|
|
17119
17129
|
...context,
|
|
17120
17130
|
...meta,
|
|
@@ -17180,9 +17190,6 @@ var generateActions = (socket, namespace, presence) => {
|
|
|
17180
17190
|
return {
|
|
17181
17191
|
emit: async (event, payload) => {
|
|
17182
17192
|
if (!presence) {
|
|
17183
|
-
console.warn(
|
|
17184
|
-
"[loly:realtime] toUser() requires presence manager. Make sure realtime is properly configured."
|
|
17185
|
-
);
|
|
17186
17193
|
return;
|
|
17187
17194
|
}
|
|
17188
17195
|
const socketIds = await presence.getSocketsForUser(userId);
|
|
@@ -17285,19 +17292,12 @@ async function setupWssEvents(options) {
|
|
|
17285
17292
|
const subClient = pubClient.duplicate();
|
|
17286
17293
|
io.adapter(createAdapter(pubClient, subClient));
|
|
17287
17294
|
} catch (error) {
|
|
17288
|
-
console.error(
|
|
17289
|
-
"[loly:realtime] Failed to setup Redis adapter:",
|
|
17290
|
-
error instanceof Error ? error.message : String(error)
|
|
17291
|
-
);
|
|
17292
17295
|
throw error;
|
|
17293
17296
|
}
|
|
17294
17297
|
}
|
|
17295
17298
|
for (const wssRoute of wssRoutes) {
|
|
17296
17299
|
const normalized = wssRoute.normalized;
|
|
17297
17300
|
if (!normalized) {
|
|
17298
|
-
console.warn(
|
|
17299
|
-
`[loly:realtime] Skipping route ${wssRoute.pattern}: No normalized route definition`
|
|
17300
|
-
);
|
|
17301
17301
|
continue;
|
|
17302
17302
|
}
|
|
17303
17303
|
let namespacePath = normalized.namespace || wssRoute.pattern.replace(/^\/wss/, "");
|
|
@@ -17308,12 +17308,11 @@ async function setupWssEvents(options) {
|
|
|
17308
17308
|
namespacePath = "/";
|
|
17309
17309
|
}
|
|
17310
17310
|
const namespace = io.of(namespacePath);
|
|
17311
|
-
console.log(`[loly:realtime] Registered namespace: ${namespacePath} (from pattern: ${wssRoute.pattern})`);
|
|
17312
17311
|
namespace.on("connection", async (socket) => {
|
|
17313
|
-
console.log(`[loly:realtime] Client connected to namespace ${namespacePath}, socket: ${socket.id}`);
|
|
17314
17312
|
const requestId = generateRequestId();
|
|
17315
17313
|
socket.requestId = requestId;
|
|
17316
|
-
const
|
|
17314
|
+
const logLevel = realtimeConfig.logging?.level || (process.env.NODE_ENV === "production" ? "warn" : "info");
|
|
17315
|
+
const log = createWssLogger(namespacePath, socket, void 0, logLevel);
|
|
17317
17316
|
try {
|
|
17318
17317
|
const user = await executeAuth(normalized.auth, socket, namespacePath);
|
|
17319
17318
|
socket.data = socket.data || {};
|
|
@@ -17322,8 +17321,6 @@ async function setupWssEvents(options) {
|
|
|
17322
17321
|
await presence.addSocketForUser(String(user.id), socket.id);
|
|
17323
17322
|
}
|
|
17324
17323
|
const baseCtx = {
|
|
17325
|
-
socket,
|
|
17326
|
-
io: namespace.server,
|
|
17327
17324
|
req: {
|
|
17328
17325
|
headers: socket.handshake.headers,
|
|
17329
17326
|
ip: socket.handshake.address,
|
|
@@ -17350,7 +17347,8 @@ async function setupWssEvents(options) {
|
|
|
17350
17347
|
socket.on(eventName, async (data) => {
|
|
17351
17348
|
const eventRequestId = generateRequestId();
|
|
17352
17349
|
socket.requestId = eventRequestId;
|
|
17353
|
-
const
|
|
17350
|
+
const eventLogLevel = realtimeConfig.logging?.level || (process.env.NODE_ENV === "production" ? "warn" : "info");
|
|
17351
|
+
const eventLog = createWssLogger(namespacePath, socket, void 0, eventLogLevel);
|
|
17354
17352
|
eventLog.debug(`Event received: ${eventName}`, { data });
|
|
17355
17353
|
try {
|
|
17356
17354
|
const ctx = {
|
|
@@ -17408,7 +17406,8 @@ async function setupWssEvents(options) {
|
|
|
17408
17406
|
await eventDef.handler(ctx);
|
|
17409
17407
|
eventLog.debug(`Event handled: ${eventName}`);
|
|
17410
17408
|
} catch (error) {
|
|
17411
|
-
const
|
|
17409
|
+
const errorLogLevel = realtimeConfig.logging?.level || (process.env.NODE_ENV === "production" ? "warn" : "info");
|
|
17410
|
+
const errorLog = createWssLogger(namespacePath, socket, void 0, errorLogLevel);
|
|
17412
17411
|
errorLog.error(`Error handling event ${eventName}`, {
|
|
17413
17412
|
error: error instanceof Error ? error.message : String(error),
|
|
17414
17413
|
stack: error instanceof Error ? error.stack : void 0
|
|
@@ -17428,9 +17427,10 @@ async function setupWssEvents(options) {
|
|
|
17428
17427
|
}
|
|
17429
17428
|
if (normalized.onDisconnect) {
|
|
17430
17429
|
try {
|
|
17430
|
+
const disconnectLogLevel = realtimeConfig.logging?.level || (process.env.NODE_ENV === "production" ? "warn" : "info");
|
|
17431
17431
|
const disconnectCtx = {
|
|
17432
17432
|
...baseCtx,
|
|
17433
|
-
log: createWssLogger(namespacePath, socket)
|
|
17433
|
+
log: createWssLogger(namespacePath, socket, void 0, disconnectLogLevel)
|
|
17434
17434
|
};
|
|
17435
17435
|
await normalized.onDisconnect(disconnectCtx, reason);
|
|
17436
17436
|
} catch (error) {
|