mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2025-12-07 12:07:07 +03:00
27 lines
760 B
TypeScript
27 lines
760 B
TypeScript
import { config } from "./config";
|
|
import { initDb } from "./databases/databases";
|
|
import { createServer } from "./app";
|
|
import { Logger } from "./utils/logger";
|
|
import { startAllCrons } from "./cronjob";
|
|
import { getCommit } from "./utils/getCommit";
|
|
|
|
async function init() {
|
|
process.on("unhandledRejection", (error: any) => {
|
|
console.dir(error?.stack);
|
|
process.exit(1);
|
|
});
|
|
|
|
await initDb();
|
|
(global as any).HEADCOMMIT = config.mode === "development" ? "development"
|
|
: config.mode === "test" ? "test"
|
|
: getCommit() as string;
|
|
createServer(() => {
|
|
Logger.info(`Server started on port ${config.port}.`);
|
|
|
|
// ignite cron job after server created
|
|
startAllCrons();
|
|
});
|
|
}
|
|
|
|
init();
|