🚧 fix server bundle

This commit is contained in:
Flam3rboy
2021-08-13 22:57:46 +02:00
parent f70a24ab6a
commit 194ef5478e
10 changed files with 96 additions and 28 deletions
+4 -4
View File
@@ -43,11 +43,11 @@ export interface KafkaBroker {
export interface DefaultOptions {
gateway: {
endpointClientKeepDefault?: boolean;
endpointClient: string | null;
endpoint: string | null;
};
cdn: {
endpointClientKeepDefault?: boolean;
endpointClient: string | null;
endpoint: string | null;
};
general: {
@@ -150,11 +150,11 @@ export interface DefaultOptions {
export const DefaultOptions: DefaultOptions = {
gateway: {
endpointClientKeepDefault: false,
endpointClient: null,
endpoint: null,
},
cdn: {
endpointClientKeepDefault: false,
endpointClient: null,
endpoint: null,
},
general: {
+6 -1
View File
@@ -16,6 +16,7 @@ export async function emitEvent(payload: Omit<Event, "created_at">) {
const successful = RabbitMQ.channel?.publish(id, "", Buffer.from(`${data}`), { type: payload.event });
if (!successful) throw new Error("failed to send event");
} else {
console.log("emit event", id);
events.emit(id, payload);
}
}
@@ -44,7 +45,11 @@ export async function listenEvent(event: string, callback: (event: EventOpts) =>
// @ts-ignore
return rabbitListen(opts?.channel || RabbitMQ.channel, event, callback, { acknowledge: opts?.acknowledge });
} else {
const cancel = () => events.removeListener(event, callback);
const cancel = () => {
console.log("cancel event", event);
events.removeListener(event, callback);
};
console.log("listen event", event);
events.addListener(event, (opts) => callback({ ...opts, cancel }));
return cancel;