-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
54 lines (44 loc) · 1.33 KB
/
index.js
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
48
49
50
51
52
53
54
"use strict";
import "dotenv/config";
import path from "path";
import { fileURLToPath } from "url";
import terminal from "@guritso/terminal";
import AniHub from "./src/server/AniHub.js";
import routeMapper from "./src/server/utils/mapper.js";
import generateKey from "./src/server/utils/generateKey.js";
import config from "./src/server/utils/configLoader.js";
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const __server = "src/server";
const __web = "src/web";
/**
* Client class extends AniHub to initialize and configure the application.
*/
class Client extends AniHub {
constructor() {
super();
this.app.client = this;
this.__dirname = __dirname;
this.__server = __server;
this.__web = __web;
this.config = () => {
const cg = config();
terminal.setVerbose(cg.server.verbose);
return cg;
};
}
start() {
const { server, security } = this.config();
const port = process.env.PORT || server.port;
const host = process.env.HOST || server.host;
super.start(host, port);
generateKey.write({
override: security.newKeyOnStart,
show: security.showKeyOnStart,
});
}
}
const routes = await routeMapper(path.join(__dirname, __server, "/routes"));
const client = new Client();
client.start();
client.routes(routes);