summary refs log tree commit diff
diff options
context:
space:
mode:
authorRory& <root@rory.gay>2026-05-20 13:48:21 +0200
committerRory& <root@rory.gay>2026-05-24 06:09:16 +0200
commit829c8c436e0c656e0f58272de885ac443e1f4c81 (patch)
treec7cb7af8d80b5eace5375e2d94b2bc2c7adf9223
parentClean up erlpack types (diff)
downloadserver-ts-829c8c436e0c656e0f58272de885ac443e1f4c81.tar.xz
*/start.ts: unify import order for module-alias and dotenv
-rw-r--r--src/api/start.ts8
-rw-r--r--src/apply-migrations.ts22
-rw-r--r--src/bundle/start.ts13
-rw-r--r--src/cdn/start.ts6
-rw-r--r--src/gateway/start.ts9
-rw-r--r--src/webrtc/start.ts10
6 files changed, 49 insertions, 19 deletions
diff --git a/src/api/start.ts b/src/api/start.ts

index bb5b23ce..f50f4422 100644 --- a/src/api/start.ts +++ b/src/api/start.ts
@@ -16,17 +16,19 @@ along with this program. If not, see <https://www.gnu.org/licenses/>. */ -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 d074c704..4511fe83 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 <https://www.gnu.org/licenses/>. +*/ + 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 0ffe3779..59cf3c65 100644 --- a/src/bundle/start.ts +++ b/src/bundle/start.ts
@@ -16,18 +16,21 @@ along with this program. If not, see <https://www.gnu.org/licenses/>. */ +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 97eaa5f9..4df20bfe 100644 --- a/src/cdn/start.ts +++ b/src/cdn/start.ts
@@ -16,14 +16,18 @@ along with this program. If not, see <https://www.gnu.org/licenses/>. */ +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 3ee87115..90071b7e 100644 --- a/src/gateway/start.ts +++ b/src/gateway/start.ts
@@ -16,16 +16,17 @@ along with this program. If not, see <https://www.gnu.org/licenses/>. */ -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 f35bba2b..2a6674a9 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 <https://www.gnu.org/licenses/>. */ -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;