diff --git a/src/api/start.ts b/src/api/start.ts index bb5b23c..f50f442 100644 --- a/src/api/start.ts +++ b/src/api/start.ts @@ -16,17 +16,19 @@ along with this program. If not, see . */ -import moduleAlias from "module-alias"; -moduleAlias(__dirname + "../../../package.json"); process.on("uncaughtException", console.error); process.on("unhandledRejection", console.error); +import moduleAlias from "module-alias"; +moduleAlias(__dirname + "../../../package.json"); import { config } from "dotenv"; config({ quiet: true }); -import { SpacebarServer } from "./Server"; + import cluster from "node:cluster"; import os from "node:os"; import fs from "node:fs"; +import { SpacebarServer } from "./Server"; + let cores = 1; try { cores = Number(process.env.THREADS) || os.cpus().length; diff --git a/src/apply-migrations.ts b/src/apply-migrations.ts index d074c70..4511fe8 100644 --- a/src/apply-migrations.ts +++ b/src/apply-migrations.ts @@ -1,8 +1,26 @@ -import moduleAlias from "module-alias"; -moduleAlias(__dirname + "../../package.json"); +/* + Spacebar: A FOSS re-implementation and extension of the Discord.com backend. + Copyright (C) 2026 Spacebar and Spacebar Contributors + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published + by the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . +*/ + process.on("uncaughtException", console.error); process.on("unhandledRejection", console.error); +import moduleAlias from "module-alias"; +moduleAlias(__dirname + "../../../package.json"); import { config } from "dotenv"; config({ quiet: true }); diff --git a/src/bundle/start.ts b/src/bundle/start.ts index 0ffe377..59cf3c6 100644 --- a/src/bundle/start.ts +++ b/src/bundle/start.ts @@ -16,18 +16,21 @@ along with this program. If not, see . */ +process.on("unhandledRejection", console.error); +process.on("uncaughtException", console.error); + import moduleAlias from "module-alias"; moduleAlias(__dirname + "../../../package.json"); -import "reflect-metadata"; +import { config } from "dotenv"; +config({ quiet: true }); + import cluster, { Worker } from "node:cluster"; import os from "node:os"; +import "reflect-metadata"; import { red, bold, yellow, cyan, blueBright, redBright } from "picocolors"; -import { initStats } from "./stats"; -import { config } from "dotenv"; - -config({ quiet: true }); import { centerString, getRevInfoOrFail, Logo } from "@spacebar/util"; +import { initStats } from "./stats"; const cores = process.env.THREADS ? parseInt(process.env.THREADS) : 1; diff --git a/src/cdn/start.ts b/src/cdn/start.ts index 97eaa5f..4df20bf 100644 --- a/src/cdn/start.ts +++ b/src/cdn/start.ts @@ -16,14 +16,18 @@ along with this program. If not, see . */ +process.on("uncaughtException", console.error); +process.on("unhandledRejection", console.error); + import moduleAlias from "module-alias"; moduleAlias(__dirname + "../../../package.json"); import { config } from "dotenv"; config({ quiet: true }); -import { CDNServer } from "./Server"; import fs from "node:fs"; import cluster from "node:cluster"; +import { CDNServer } from "./Server"; + const server = new CDNServer({ port: Number(process.env.PORT) || 3003 }); server .start() diff --git a/src/gateway/start.ts b/src/gateway/start.ts index 3ee8711..90071b7 100644 --- a/src/gateway/start.ts +++ b/src/gateway/start.ts @@ -16,16 +16,17 @@ along with this program. If not, see . */ -import moduleAlias from "module-alias"; -moduleAlias(__dirname + "../../../package.json"); process.on("uncaughtException", console.error); process.on("unhandledRejection", console.error); -import { Server } from "./Server"; +import moduleAlias from "module-alias"; +moduleAlias(__dirname + "../../../package.json"); import { config } from "dotenv"; +config({ quiet: true }); + +import { Server } from "./Server"; import fs from "node:fs"; import cluster from "node:cluster"; -config({ quiet: true }); let port = Number(process.env.PORT); if (isNaN(port)) port = 3002; diff --git a/src/webrtc/start.ts b/src/webrtc/start.ts index f35bba2..2a6674a 100644 --- a/src/webrtc/start.ts +++ b/src/webrtc/start.ts @@ -15,16 +15,18 @@ You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ -import moduleAlias from "module-alias"; -moduleAlias(__dirname + "../../../package.json"); + process.on("uncaughtException", console.error); process.on("unhandledRejection", console.error); +import moduleAlias from "module-alias"; +moduleAlias(__dirname + "../../../package.json"); import { config } from "dotenv"; -import { Server } from "./Server"; +config({ quiet: true }); + import fs from "node:fs"; import cluster from "node:cluster"; -config({ quiet: true }); +import { Server } from "./Server"; const port = Number(process.env.PORT) || 3004;