2023-05-07 17:56:55 +03:00
|
|
|
// KEEP THIS AS FIRST IMPORT
|
|
|
|
// See comment in module for details
|
|
|
|
import "../threadsSignalFix";
|
|
|
|
|
2019-06-22 18:52:24 +03:00
|
|
|
import { connect } from "../data/db";
|
2022-06-26 14:37:37 +03:00
|
|
|
import { env } from "../env";
|
2023-04-01 12:58:17 +01:00
|
|
|
import { setIsAPI } from "../globals";
|
2021-06-06 23:51:32 +02:00
|
|
|
|
2022-06-26 14:37:37 +03:00
|
|
|
if (!env.KEY) {
|
2020-09-16 22:32:43 +03:00
|
|
|
// tslint:disable-next-line:no-console
|
|
|
|
console.error("Project root .env with KEY is required!");
|
|
|
|
process.exit(1);
|
|
|
|
}
|
2019-07-22 00:11:24 +03:00
|
|
|
|
2019-08-04 15:45:35 +03:00
|
|
|
function errorHandler(err) {
|
2019-08-22 01:22:26 +03:00
|
|
|
console.error(err.stack || err); // tslint:disable-line:no-console
|
2019-08-04 15:45:35 +03:00
|
|
|
process.exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
process.on("unhandledRejection", errorHandler);
|
|
|
|
|
2020-05-28 02:45:07 +03:00
|
|
|
setIsAPI(true);
|
|
|
|
|
2020-05-23 16:22:03 +03:00
|
|
|
// Connect to the database before loading the rest of the code (that depend on the database connection)
|
2019-08-22 01:22:26 +03:00
|
|
|
console.log("Connecting to database..."); // tslint:disable-line
|
2019-05-26 00:13:42 +03:00
|
|
|
connect().then(() => {
|
2023-04-01 12:58:17 +01:00
|
|
|
import("./start.js");
|
2019-05-26 00:13:42 +03:00
|
|
|
});
|