@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/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import http from 'http';
|
|
2
2
|
export { a as ApiContext, A as ApiMiddleware, G as GenerateStaticParams, L as LoaderResult, M as MetadataLoader, R as RouteMiddleware, S as ServerContext, b as ServerLoader, W as WssActions } from './index.types-DMOO-uvF.mjs';
|
|
3
|
-
import {
|
|
3
|
+
import { Socket } from 'socket.io';
|
|
4
4
|
export { c as bootstrapClient } from './bootstrap-BfGTMUkj.mjs';
|
|
5
5
|
import { ZodSchema, z } from 'zod';
|
|
6
6
|
import * as express_rate_limit from 'express-rate-limit';
|
|
@@ -153,7 +153,6 @@ interface RateLimitCfg {
|
|
|
153
153
|
type GuardFn<TUser = any> = (ctx: {
|
|
154
154
|
user: TUser | null;
|
|
155
155
|
req: AuthContext["req"];
|
|
156
|
-
socket: Socket;
|
|
157
156
|
namespace: string;
|
|
158
157
|
}) => boolean | Promise<boolean>;
|
|
159
158
|
/**
|
|
@@ -279,10 +278,6 @@ interface WssActions {
|
|
|
279
278
|
* Extended WssContext with full RFC support.
|
|
280
279
|
*/
|
|
281
280
|
interface WssContext<TData = any, TUser = any> {
|
|
282
|
-
/** Socket.IO server instance */
|
|
283
|
-
io: Server;
|
|
284
|
-
/** Socket.IO socket instance */
|
|
285
|
-
socket: Socket;
|
|
286
281
|
/** Request metadata */
|
|
287
282
|
req: {
|
|
288
283
|
headers: Record<string, string | string[] | undefined>;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import http from 'http';
|
|
2
2
|
export { a as ApiContext, A as ApiMiddleware, G as GenerateStaticParams, L as LoaderResult, M as MetadataLoader, R as RouteMiddleware, S as ServerContext, b as ServerLoader, W as WssActions } from './index.types-DMOO-uvF.js';
|
|
3
|
-
import {
|
|
3
|
+
import { Socket } from 'socket.io';
|
|
4
4
|
export { c as bootstrapClient } from './bootstrap-BfGTMUkj.js';
|
|
5
5
|
import { ZodSchema, z } from 'zod';
|
|
6
6
|
import * as express_rate_limit from 'express-rate-limit';
|
|
@@ -153,7 +153,6 @@ interface RateLimitCfg {
|
|
|
153
153
|
type GuardFn<TUser = any> = (ctx: {
|
|
154
154
|
user: TUser | null;
|
|
155
155
|
req: AuthContext["req"];
|
|
156
|
-
socket: Socket;
|
|
157
156
|
namespace: string;
|
|
158
157
|
}) => boolean | Promise<boolean>;
|
|
159
158
|
/**
|
|
@@ -279,10 +278,6 @@ interface WssActions {
|
|
|
279
278
|
* Extended WssContext with full RFC support.
|
|
280
279
|
*/
|
|
281
280
|
interface WssContext<TData = any, TUser = any> {
|
|
282
|
-
/** Socket.IO server instance */
|
|
283
|
-
io: Server;
|
|
284
|
-
/** Socket.IO socket instance */
|
|
285
|
-
socket: Socket;
|
|
286
281
|
/** Request metadata */
|
|
287
282
|
req: {
|
|
288
283
|
headers: Record<string, string | string[] | undefined>;
|
package/dist/index.js
CHANGED
|
@@ -15826,7 +15826,7 @@ var DEFAULT_REALTIME_CONFIG = {
|
|
|
15826
15826
|
burst: 60
|
|
15827
15827
|
},
|
|
15828
15828
|
logging: {
|
|
15829
|
-
level: "info",
|
|
15829
|
+
level: process.env.NODE_ENV === "production" ? "warn" : "info",
|
|
15830
15830
|
pretty: process.env.NODE_ENV !== "production"
|
|
15831
15831
|
}
|
|
15832
15832
|
};
|
|
@@ -16629,7 +16629,6 @@ async function executeGuard(guardFn, ctx) {
|
|
|
16629
16629
|
const guardCtx = {
|
|
16630
16630
|
user: ctx.user,
|
|
16631
16631
|
req: ctx.req,
|
|
16632
|
-
socket: ctx.socket,
|
|
16633
16632
|
namespace: ctx.pathname
|
|
16634
16633
|
};
|
|
16635
16634
|
const result = await guardFn(guardCtx);
|
|
@@ -16664,13 +16663,24 @@ function validateSchema(schema, data) {
|
|
|
16664
16663
|
}
|
|
16665
16664
|
|
|
16666
16665
|
// modules/realtime/logging/index.ts
|
|
16667
|
-
|
|
16666
|
+
var LOG_LEVELS = {
|
|
16667
|
+
debug: 0,
|
|
16668
|
+
info: 1,
|
|
16669
|
+
warn: 2,
|
|
16670
|
+
error: 3
|
|
16671
|
+
};
|
|
16672
|
+
function createWssLogger(namespace, socket, baseLogger, minLevel = "info") {
|
|
16668
16673
|
const context = {
|
|
16669
16674
|
namespace,
|
|
16670
16675
|
socketId: socket.id,
|
|
16671
16676
|
userId: socket.data?.user?.id || null
|
|
16672
16677
|
};
|
|
16678
|
+
const minLevelNum = LOG_LEVELS[minLevel] ?? LOG_LEVELS.info;
|
|
16673
16679
|
const log = (level, message, meta) => {
|
|
16680
|
+
const levelNum = LOG_LEVELS[level] ?? LOG_LEVELS.info;
|
|
16681
|
+
if (levelNum < minLevelNum) {
|
|
16682
|
+
return;
|
|
16683
|
+
}
|
|
16674
16684
|
const fullMeta = {
|
|
16675
16685
|
...context,
|
|
16676
16686
|
...meta,
|
|
@@ -16736,9 +16746,6 @@ var generateActions = (socket, namespace, presence) => {
|
|
|
16736
16746
|
return {
|
|
16737
16747
|
emit: async (event, payload) => {
|
|
16738
16748
|
if (!presence) {
|
|
16739
|
-
console.warn(
|
|
16740
|
-
"[loly:realtime] toUser() requires presence manager. Make sure realtime is properly configured."
|
|
16741
|
-
);
|
|
16742
16749
|
return;
|
|
16743
16750
|
}
|
|
16744
16751
|
const socketIds = await presence.getSocketsForUser(userId);
|
|
@@ -16841,19 +16848,12 @@ async function setupWssEvents(options) {
|
|
|
16841
16848
|
const subClient = pubClient.duplicate();
|
|
16842
16849
|
io.adapter(createAdapter(pubClient, subClient));
|
|
16843
16850
|
} catch (error) {
|
|
16844
|
-
console.error(
|
|
16845
|
-
"[loly:realtime] Failed to setup Redis adapter:",
|
|
16846
|
-
error instanceof Error ? error.message : String(error)
|
|
16847
|
-
);
|
|
16848
16851
|
throw error;
|
|
16849
16852
|
}
|
|
16850
16853
|
}
|
|
16851
16854
|
for (const wssRoute of wssRoutes) {
|
|
16852
16855
|
const normalized = wssRoute.normalized;
|
|
16853
16856
|
if (!normalized) {
|
|
16854
|
-
console.warn(
|
|
16855
|
-
`[loly:realtime] Skipping route ${wssRoute.pattern}: No normalized route definition`
|
|
16856
|
-
);
|
|
16857
16857
|
continue;
|
|
16858
16858
|
}
|
|
16859
16859
|
let namespacePath = normalized.namespace || wssRoute.pattern.replace(/^\/wss/, "");
|
|
@@ -16864,12 +16864,11 @@ async function setupWssEvents(options) {
|
|
|
16864
16864
|
namespacePath = "/";
|
|
16865
16865
|
}
|
|
16866
16866
|
const namespace = io.of(namespacePath);
|
|
16867
|
-
console.log(`[loly:realtime] Registered namespace: ${namespacePath} (from pattern: ${wssRoute.pattern})`);
|
|
16868
16867
|
namespace.on("connection", async (socket) => {
|
|
16869
|
-
console.log(`[loly:realtime] Client connected to namespace ${namespacePath}, socket: ${socket.id}`);
|
|
16870
16868
|
const requestId = generateRequestId();
|
|
16871
16869
|
socket.requestId = requestId;
|
|
16872
|
-
const
|
|
16870
|
+
const logLevel = realtimeConfig.logging?.level || (process.env.NODE_ENV === "production" ? "warn" : "info");
|
|
16871
|
+
const log = createWssLogger(namespacePath, socket, void 0, logLevel);
|
|
16873
16872
|
try {
|
|
16874
16873
|
const user = await executeAuth(normalized.auth, socket, namespacePath);
|
|
16875
16874
|
socket.data = socket.data || {};
|
|
@@ -16878,8 +16877,6 @@ async function setupWssEvents(options) {
|
|
|
16878
16877
|
await presence.addSocketForUser(String(user.id), socket.id);
|
|
16879
16878
|
}
|
|
16880
16879
|
const baseCtx = {
|
|
16881
|
-
socket,
|
|
16882
|
-
io: namespace.server,
|
|
16883
16880
|
req: {
|
|
16884
16881
|
headers: socket.handshake.headers,
|
|
16885
16882
|
ip: socket.handshake.address,
|
|
@@ -16906,7 +16903,8 @@ async function setupWssEvents(options) {
|
|
|
16906
16903
|
socket.on(eventName, async (data) => {
|
|
16907
16904
|
const eventRequestId = generateRequestId();
|
|
16908
16905
|
socket.requestId = eventRequestId;
|
|
16909
|
-
const
|
|
16906
|
+
const eventLogLevel = realtimeConfig.logging?.level || (process.env.NODE_ENV === "production" ? "warn" : "info");
|
|
16907
|
+
const eventLog = createWssLogger(namespacePath, socket, void 0, eventLogLevel);
|
|
16910
16908
|
eventLog.debug(`Event received: ${eventName}`, { data });
|
|
16911
16909
|
try {
|
|
16912
16910
|
const ctx = {
|
|
@@ -16964,7 +16962,8 @@ async function setupWssEvents(options) {
|
|
|
16964
16962
|
await eventDef.handler(ctx);
|
|
16965
16963
|
eventLog.debug(`Event handled: ${eventName}`);
|
|
16966
16964
|
} catch (error) {
|
|
16967
|
-
const
|
|
16965
|
+
const errorLogLevel = realtimeConfig.logging?.level || (process.env.NODE_ENV === "production" ? "warn" : "info");
|
|
16966
|
+
const errorLog = createWssLogger(namespacePath, socket, void 0, errorLogLevel);
|
|
16968
16967
|
errorLog.error(`Error handling event ${eventName}`, {
|
|
16969
16968
|
error: error instanceof Error ? error.message : String(error),
|
|
16970
16969
|
stack: error instanceof Error ? error.stack : void 0
|
|
@@ -16984,9 +16983,10 @@ async function setupWssEvents(options) {
|
|
|
16984
16983
|
}
|
|
16985
16984
|
if (normalized.onDisconnect) {
|
|
16986
16985
|
try {
|
|
16986
|
+
const disconnectLogLevel = realtimeConfig.logging?.level || (process.env.NODE_ENV === "production" ? "warn" : "info");
|
|
16987
16987
|
const disconnectCtx = {
|
|
16988
16988
|
...baseCtx,
|
|
16989
|
-
log: createWssLogger(namespacePath, socket)
|
|
16989
|
+
log: createWssLogger(namespacePath, socket, void 0, disconnectLogLevel)
|
|
16990
16990
|
};
|
|
16991
16991
|
await normalized.onDisconnect(disconnectCtx, reason);
|
|
16992
16992
|
} catch (error) {
|
|
@@ -18725,9 +18725,7 @@ function AppShell({
|
|
|
18725
18725
|
function setupHotReload2() {
|
|
18726
18726
|
const nodeEnv = process.env.NODE_ENV || "production";
|
|
18727
18727
|
const isDev = nodeEnv === "development";
|
|
18728
|
-
console.log(`[hot-reload] NODE_ENV: ${nodeEnv}, isDev: ${isDev}`);
|
|
18729
18728
|
if (!isDev) {
|
|
18730
|
-
console.log("[hot-reload] Skipping hot reload setup (not in development mode)");
|
|
18731
18729
|
return;
|
|
18732
18730
|
}
|
|
18733
18731
|
console.log("[hot-reload] Setting up hot reload client...");
|