expresso-macchiato 0.4.2 → 0.4.4-dev.0
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/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +7 -6
- package/dist/index.mjs +7 -6
- package/package.json +1 -1
- package/types/socket.sptypes.ts +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -472,7 +472,7 @@ type SocketWrapperConstructor<Metadata extends Record<string, any> = any> = {
|
|
|
472
472
|
clientConnectionKey?: string;
|
|
473
473
|
connectionMiddleware?: SocketConnectionMiddleware<Metadata>;
|
|
474
474
|
afterClientConnect?: (self: SocketWrapper, client: Socket, metadata?: Metadata) => Promise<void>;
|
|
475
|
-
onClientDisconnect?: (self: SocketWrapper,
|
|
475
|
+
onClientDisconnect?: (self: SocketWrapper, clientId: string, ...params: any[]) => Promise<void>;
|
|
476
476
|
listeners?: Record<string, (self: SocketWrapper, client: Socket, metadata: any, ...params: any[]) => Promise<void>>;
|
|
477
477
|
};
|
|
478
478
|
|
|
@@ -483,7 +483,7 @@ declare class SocketWrapper<Metadata extends Record<string, any> = any> {
|
|
|
483
483
|
protected namespace?: Namespace;
|
|
484
484
|
constructor(data: SocketWrapperConstructor<Metadata>);
|
|
485
485
|
setupConnection: (io: Server$1) => void;
|
|
486
|
-
protected handleDisconnection: (
|
|
486
|
+
protected handleDisconnection: (clientId: string) => void;
|
|
487
487
|
broadcast: (eventName: string, data: any) => void;
|
|
488
488
|
broadcastExceptClient: (clientId: string, eventName: string, data: any) => void;
|
|
489
489
|
sendToClient: (clientId: string, eventName: string, data: any) => void;
|
package/dist/index.d.ts
CHANGED
|
@@ -472,7 +472,7 @@ type SocketWrapperConstructor<Metadata extends Record<string, any> = any> = {
|
|
|
472
472
|
clientConnectionKey?: string;
|
|
473
473
|
connectionMiddleware?: SocketConnectionMiddleware<Metadata>;
|
|
474
474
|
afterClientConnect?: (self: SocketWrapper, client: Socket, metadata?: Metadata) => Promise<void>;
|
|
475
|
-
onClientDisconnect?: (self: SocketWrapper,
|
|
475
|
+
onClientDisconnect?: (self: SocketWrapper, clientId: string, ...params: any[]) => Promise<void>;
|
|
476
476
|
listeners?: Record<string, (self: SocketWrapper, client: Socket, metadata: any, ...params: any[]) => Promise<void>>;
|
|
477
477
|
};
|
|
478
478
|
|
|
@@ -483,7 +483,7 @@ declare class SocketWrapper<Metadata extends Record<string, any> = any> {
|
|
|
483
483
|
protected namespace?: Namespace;
|
|
484
484
|
constructor(data: SocketWrapperConstructor<Metadata>);
|
|
485
485
|
setupConnection: (io: Server$1) => void;
|
|
486
|
-
protected handleDisconnection: (
|
|
486
|
+
protected handleDisconnection: (clientId: string) => void;
|
|
487
487
|
broadcast: (eventName: string, data: any) => void;
|
|
488
488
|
broadcastExceptClient: (clientId: string, eventName: string, data: any) => void;
|
|
489
489
|
sendToClient: (clientId: string, eventName: string, data: any) => void;
|
package/dist/index.js
CHANGED
|
@@ -664,11 +664,12 @@ var RouterWrapper = class {
|
|
|
664
664
|
const callBackFunction = async (req, res) => {
|
|
665
665
|
try {
|
|
666
666
|
const handlerRes = await currentMethod.handler(req, res);
|
|
667
|
+
log.gold(`Handling res on [${method}] ${this.data.basePath}${path3}`, handlerRes);
|
|
667
668
|
if (handlerRes.contentType) {
|
|
668
669
|
res.set("Content-Type", handlerRes.contentType);
|
|
669
670
|
res.status(_nullishCoalesce(handlerRes.status, () => ( 200))).send(handlerRes.result);
|
|
670
|
-
} else if (typeof handlerRes.result === "object") res.status(handlerRes.status).json(handlerRes.result);
|
|
671
|
-
else res.status(handlerRes.status).send(handlerRes.result);
|
|
671
|
+
} else if (typeof handlerRes.result === "object") res.status(_nullishCoalesce(handlerRes.status, () => ( 200))).json(handlerRes.result);
|
|
672
|
+
else res.status(_nullishCoalesce(handlerRes.status, () => ( 200))).send(handlerRes.result);
|
|
672
673
|
} catch (err) {
|
|
673
674
|
fullLogNok("api", `[${method}] ${this.data.basePath}${path3} => ${_nullishCoalesce(err.message, () => ( err))}`);
|
|
674
675
|
res.status(500).send(_nullishCoalesce(_optionalChain([err, 'optionalAccess', _41 => _41.message]), () => ( err)));
|
|
@@ -738,7 +739,7 @@ var SocketWrapper = class {
|
|
|
738
739
|
this.connectedClients.set(finalClientId, { socket: client, connectedAt: /* @__PURE__ */ new Date(), metadata });
|
|
739
740
|
if (this.data.afterClientConnect) this.data.afterClientConnect(this, client, metadata);
|
|
740
741
|
for (const eventName in _nullishCoalesce(this.data.listeners, () => ( []))) client.on(eventName, (...params) => _optionalChain([this, 'access', _46 => _46.data, 'access', _47 => _47.listeners, 'optionalAccess', _48 => _48[eventName], 'call', _49 => _49(this, client, metadata, ...params)]));
|
|
741
|
-
client.on("disconnect", () => this.handleDisconnection(
|
|
742
|
+
client.on("disconnect", () => this.handleDisconnection(finalClientId));
|
|
742
743
|
} catch (err) {
|
|
743
744
|
fullLogNok(`SOCKETWRAPPER`, `[${this.socketNamespace.toUpperCase()}]`, err);
|
|
744
745
|
}
|
|
@@ -747,11 +748,11 @@ var SocketWrapper = class {
|
|
|
747
748
|
fullLogNok(`SOCKETWRAPPER`, `[${this.socketNamespace.toUpperCase()}]`, err);
|
|
748
749
|
}
|
|
749
750
|
};
|
|
750
|
-
this.handleDisconnection = (
|
|
751
|
+
this.handleDisconnection = (clientId) => {
|
|
751
752
|
try {
|
|
752
753
|
if (!this.namespace) throw new Error("Socket.IO not initialized");
|
|
753
|
-
this.connectedClients.delete(
|
|
754
|
-
if (this.data.onClientDisconnect) this.data.onClientDisconnect(this,
|
|
754
|
+
this.connectedClients.delete(clientId);
|
|
755
|
+
if (this.data.onClientDisconnect) this.data.onClientDisconnect(this, clientId);
|
|
755
756
|
} catch (err) {
|
|
756
757
|
fullLogNok(`SOCKETWRAPPER`, `[${this.socketNamespace.toUpperCase()}]`, err);
|
|
757
758
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -664,11 +664,12 @@ var RouterWrapper = class {
|
|
|
664
664
|
const callBackFunction = async (req, res) => {
|
|
665
665
|
try {
|
|
666
666
|
const handlerRes = await currentMethod.handler(req, res);
|
|
667
|
+
log.gold(`Handling res on [${method}] ${this.data.basePath}${path3}`, handlerRes);
|
|
667
668
|
if (handlerRes.contentType) {
|
|
668
669
|
res.set("Content-Type", handlerRes.contentType);
|
|
669
670
|
res.status(handlerRes.status ?? 200).send(handlerRes.result);
|
|
670
|
-
} else if (typeof handlerRes.result === "object") res.status(handlerRes.status).json(handlerRes.result);
|
|
671
|
-
else res.status(handlerRes.status).send(handlerRes.result);
|
|
671
|
+
} else if (typeof handlerRes.result === "object") res.status(handlerRes.status ?? 200).json(handlerRes.result);
|
|
672
|
+
else res.status(handlerRes.status ?? 200).send(handlerRes.result);
|
|
672
673
|
} catch (err) {
|
|
673
674
|
fullLogNok("api", `[${method}] ${this.data.basePath}${path3} => ${err.message ?? err}`);
|
|
674
675
|
res.status(500).send(err?.message ?? err);
|
|
@@ -738,7 +739,7 @@ var SocketWrapper = class {
|
|
|
738
739
|
this.connectedClients.set(finalClientId, { socket: client, connectedAt: /* @__PURE__ */ new Date(), metadata });
|
|
739
740
|
if (this.data.afterClientConnect) this.data.afterClientConnect(this, client, metadata);
|
|
740
741
|
for (const eventName in this.data.listeners ?? []) client.on(eventName, (...params) => this.data.listeners?.[eventName](this, client, metadata, ...params));
|
|
741
|
-
client.on("disconnect", () => this.handleDisconnection(
|
|
742
|
+
client.on("disconnect", () => this.handleDisconnection(finalClientId));
|
|
742
743
|
} catch (err) {
|
|
743
744
|
fullLogNok(`SOCKETWRAPPER`, `[${this.socketNamespace.toUpperCase()}]`, err);
|
|
744
745
|
}
|
|
@@ -747,11 +748,11 @@ var SocketWrapper = class {
|
|
|
747
748
|
fullLogNok(`SOCKETWRAPPER`, `[${this.socketNamespace.toUpperCase()}]`, err);
|
|
748
749
|
}
|
|
749
750
|
};
|
|
750
|
-
this.handleDisconnection = (
|
|
751
|
+
this.handleDisconnection = (clientId) => {
|
|
751
752
|
try {
|
|
752
753
|
if (!this.namespace) throw new Error("Socket.IO not initialized");
|
|
753
|
-
this.connectedClients.delete(
|
|
754
|
-
if (this.data.onClientDisconnect) this.data.onClientDisconnect(this,
|
|
754
|
+
this.connectedClients.delete(clientId);
|
|
755
|
+
if (this.data.onClientDisconnect) this.data.onClientDisconnect(this, clientId);
|
|
755
756
|
} catch (err) {
|
|
756
757
|
fullLogNok(`SOCKETWRAPPER`, `[${this.socketNamespace.toUpperCase()}]`, err);
|
|
757
758
|
}
|
package/package.json
CHANGED
package/types/socket.sptypes.ts
CHANGED
|
@@ -18,6 +18,6 @@ export type SocketWrapperConstructor<Metadata extends Record<string, any> = any>
|
|
|
18
18
|
clientConnectionKey?:string,
|
|
19
19
|
connectionMiddleware?:SocketConnectionMiddleware<Metadata>
|
|
20
20
|
afterClientConnect?: (self:SocketWrapper, client:Socket, metadata?:Metadata) => Promise<void>
|
|
21
|
-
onClientDisconnect?:(self:SocketWrapper,
|
|
21
|
+
onClientDisconnect?:(self:SocketWrapper, clientId:string, ...params:any[]) => Promise<void>
|
|
22
22
|
listeners?:Record<string, (self:SocketWrapper, client:Socket, metadata:any, ...params:any[]) => Promise<void>>
|
|
23
23
|
}
|