-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
executable file
·101 lines (87 loc) · 3.26 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
const mongoose = require("mongoose");
const monitoring = require("./Utils/monitor");
const path = require("path");
const logging = require("@connibug/js-logging");
logging.setupFileLogging("./");
const express = require("express");
const app = express();
require("dotenv").config();
process.env.debug = process.env.debug == "True" ? true : false;
const port = process.env.PORT || 3000;
// const hashing = require("./Utils/hashing");
// if(!process.env.saltRounds) {
// hashing.setup();
// }
monitoring.output();
// mongoose instance connection url connection
// let startTimestamp = new Date().getTime();
// mongoose
// .connect(uri_main, {
// useNewUrlParser: true,
// useCreateIndex: true,
// useUnifiedTopology: true,
// useFindAndModify: false,
// })
// .then((res) => {
// logging.log("uri_main Connected!");
// monitoring.log("mongodb_main - DB Connected", new Date().getTime() - startTimestamp);
// })
// .catch((err) => {
// console.log(Error, "Failed to connect to mongodb_main DB\nErrror :" + err.message);
// logging.log(err, "ERROR");
// monitoring.log(
// "mongodb_main - DB Connection failed",
// new Date().getTime() - startTimestamp
// );
// process.exit(1);
// });
// mongoose
// .connect(uri_buckets, {
// useNewUrlParser: true,
// useCreateIndex: true,
// useUnifiedTopology: true,
// useFindAndModify: false,
// })
// .then((res) => {
// logging.log("uri_buckets Connected!");
// monitoring.log("uri_buckets - DB Connected", new Date().getTime() - startTimestamp);
// })
// .catch((err) => {
// console.log(Error, "Failed to connect to uri_buckets DB\nErrror :" + err.message);
// logging.log(err, "ERROR");
// monitoring.log(
// "uri_buckets - DB Connection failed",
// new Date().getTime() - startTimestamp
// );
// process.exit(1);
// });
async function start() {
logging.log("--------------------------------------------------");
logging.log("Starting.");
logging.log("--------------------------------------------------");
require("./Databases/DBs").initDBs();
const servers = await require("./Databases/DBs").get();
console.log("=========================");
console.log("Servers");
servers.forEach((e) => {
var ServerName = Object.keys(e)[0];
console.log("|", ServerName, "- Databases:", undefined);
});
console.log("=========================");
require("./api/models/MemberModel"); // created model loading here
require("./api/models/GuildModel"); // created model loading here
require("./api/models/BucketModel"); // created model loading here
require("./api/models/VerificationModel"); // created model loading here
logging.debug("Defined models", mongoose.modelNames());
app.use(express.urlencoded({ extended: true }));
app.use(express.json());
const routes = require("./api/routes/routes");
routes(app); // register the routes
app.get("*", (req, res) => {
logging.log(req.originalUrl + " not found");
res.status(404).send({ url: req.originalUrl + " not found" });
});
app.listen(port);
logging.log("Server RESTful API server started on: " + port);
}
start();