✨ rabbitmq
This commit is contained in:
parent
08dee5c847
commit
d8eece32de
BIN
package-lock.json
generated
BIN
package-lock.json
generated
Binary file not shown.
@ -32,6 +32,7 @@
|
||||
"@types/mongoose-lean-virtuals": "^0.5.1",
|
||||
"@types/node": "^14.14.25",
|
||||
"ajv": "^8.5.0",
|
||||
"amqplib": "^0.8.0",
|
||||
"dot-prop": "^6.0.1",
|
||||
"env-paths": "^2.2.1",
|
||||
"jsonwebtoken": "^8.5.1",
|
||||
@ -40,5 +41,8 @@
|
||||
"mongoose": "^5.12.3",
|
||||
"mongoose-autopopulate": "^0.12.3",
|
||||
"typescript": "^4.1.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/amqplib": "^0.8.1"
|
||||
}
|
||||
}
|
||||
|
||||
@ -25,17 +25,17 @@ export interface RateLimitOptions {
|
||||
}
|
||||
|
||||
export interface Region {
|
||||
id: string,
|
||||
name: string,
|
||||
vip: boolean,
|
||||
custom: boolean,
|
||||
deprecated: boolean,
|
||||
optimal: boolean,
|
||||
id: string;
|
||||
name: string;
|
||||
vip: boolean;
|
||||
custom: boolean;
|
||||
deprecated: boolean;
|
||||
optimal: boolean;
|
||||
}
|
||||
|
||||
export interface KafkaBroker {
|
||||
ip: string,
|
||||
port: number
|
||||
ip: string;
|
||||
port: number;
|
||||
}
|
||||
|
||||
export interface DefaultOptions {
|
||||
@ -133,10 +133,13 @@ export interface DefaultOptions {
|
||||
regions: {
|
||||
default: string;
|
||||
available: Region[];
|
||||
}
|
||||
};
|
||||
rabbitmq: {
|
||||
host: string | null;
|
||||
};
|
||||
kafka: {
|
||||
brokers: KafkaBroker[] | null
|
||||
}
|
||||
brokers: KafkaBroker[] | null;
|
||||
};
|
||||
}
|
||||
|
||||
export const DefaultOptions: DefaultOptions = {
|
||||
@ -230,17 +233,18 @@ export const DefaultOptions: DefaultOptions = {
|
||||
},
|
||||
regions: {
|
||||
default: "fosscord",
|
||||
available: [
|
||||
{ id: "fosscord", name: "Fosscord", vip: false, custom: false, deprecated: false, optimal: false },
|
||||
]
|
||||
available: [{ id: "fosscord", name: "Fosscord", vip: false, custom: false, deprecated: false, optimal: false }],
|
||||
},
|
||||
rabbitmq: {
|
||||
host: null,
|
||||
},
|
||||
kafka: {
|
||||
brokers: null
|
||||
}
|
||||
brokers: null,
|
||||
},
|
||||
};
|
||||
|
||||
export const ConfigSchema = new Schema({}, { strict: false });
|
||||
|
||||
export interface DefaultOptionsDocument extends DefaultOptions, Document { }
|
||||
export interface DefaultOptionsDocument extends DefaultOptions, Document {}
|
||||
|
||||
export const ConfigModel = model<DefaultOptionsDocument>("Config", ConfigSchema, "config");
|
||||
|
||||
14
src/util/RabbitMQ.ts
Normal file
14
src/util/RabbitMQ.ts
Normal file
@ -0,0 +1,14 @@
|
||||
import amqp, { Connection, Channel } from "amqplib";
|
||||
import Config from "./Config";
|
||||
|
||||
var rabbitCon: Connection;
|
||||
var rabbitCh: Channel;
|
||||
|
||||
export async function init() {
|
||||
const host = Config.get().rabbitmq.host;
|
||||
if (!host) return;
|
||||
rabbitCon = await amqp.connect(host);
|
||||
rabbitCh = await rabbitCon.createChannel();
|
||||
}
|
||||
|
||||
export { rabbitCon, rabbitCh };
|
||||
@ -5,4 +5,5 @@ export * from "./MessageFlags";
|
||||
export * from "./Permissions";
|
||||
export * from "./Snowflake";
|
||||
export * from "./UserFlags";
|
||||
export * from "./toBigInt"
|
||||
export * from "./toBigInt";
|
||||
export * from "./RabbitMQ";
|
||||
|
||||
Reference in New Issue
Block a user