-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.ts
47 lines (39 loc) · 1.09 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import process from "process";
import { config } from "dotenv";
config();
import { MongoConnect, RedisClient } from "./src/libs";
import { StartRBot } from "./src/core";
import { FigletChalkStarter, Logger } from "./src/utils/logger";
import { cleanEnv, email, makeValidator, num, str } from "envalid";
const ownerNumber = makeValidator((num) => {
if (num.split(" ").length > 0) return [...num.split(" ")];
else throw new Error("Owner ");
});
export const env = cleanEnv(process.env, {
NODE_ENV: str({ choices: ["development", "test", "production"] }),
MONGO_URI: str(),
EMAIL: email(),
SESSION_ID: str(),
REDIS_EXPIRES_SECONDS: num(),
OWNER_NUMBER: ownerNumber(),
});
async function Start() {
try {
FigletChalkStarter("RBOT");
await RedisClient.connect();
await MongoConnect(env.MONGO_URI);
StartRBot({ env });
} catch (e) {
Logger.error(`Error ${e}`);
process.exit();
}
}
Start().then(() => {});
// /**
// * Init DB (Mongo)
// * Init Redis
// * Init WA Client
// */
process.on("exit", (code) => {
console.log(`About to exit with code: ${code}`);
});