diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 25a9866..741d94a 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -50,50 +50,50 @@
- {
+ "keyToString": {
+ "NIXITCH_NIXPKGS_CONFIG": "/etc/nix/nixpkgs-config.nix",
+ "NIXITCH_NIX_CONF_DIR": "",
+ "NIXITCH_NIX_OTHER_STORES": "",
+ "NIXITCH_NIX_PATH": "/home/Rory/.nix-defexpr/channels:nixpkgs=/nix/store/wb6agba4kfsxpbnb5hzlq58vkjzvbsk6-source",
+ "NIXITCH_NIX_PROFILES": "/run/current-system/sw /nix/var/nix/profiles/default /etc/profiles/per-user/Rory /home/Rory/.local/state/nix/profile /nix/profile /home/Rory/.nix-profile",
+ "NIXITCH_NIX_REMOTE": "",
+ "NIXITCH_NIX_USER_PROFILE_DIR": "/nix/var/nix/profiles/per-user/Rory",
+ "Node.js.Server.ts.executor": "Debug",
+ "RunOnceActivity.ShowReadmeOnStart": "true",
+ "RunOnceActivity.git.unshallow": "true",
+ "git-widget-placeholder": "master",
+ "javascript.nodejs.core.library.configured.version": "24.11.1",
+ "javascript.nodejs.core.library.typings.version": "24.10.4",
+ "last_opened_file_path": "/home/Rory/git/spacebar/server-master/src/util/migration/postgres",
+ "node.js.detected.package.eslint": "true",
+ "node.js.detected.package.standard": "true",
+ "node.js.selected.package.eslint": "(autodetect)",
+ "node.js.selected.package.standard": "",
+ "node.js.selected.package.tslint": "(autodetect)",
+ "nodejs_interpreter_path": "node",
+ "nodejs_package_manager_path": "npm",
+ "npm.Start API.executor": "Run",
+ "npm.Start CDN.executor": "Run",
+ "npm.Start Gateway.executor": "Run",
+ "npm.build.executor": "Run",
+ "npm.build:src.executor": "Run",
+ "npm.start.executor": "Debug",
+ "prettierjs.PrettierConfiguration.Package": "/home/Rory/git/spacebar/server-master/node_modules/prettier",
+ "settings.editor.selected.configurable": "com.github.copilot.settings.customInstructions.CopilotInstructionsConfigurable",
+ "ts.external.directory.path": "/home/Rory/git/spacebar/server-master/node_modules/typescript/lib"
},
- "keyToStringList": {
- "DatabaseDriversLRU": [
- "postgresql"
+ "keyToStringList": {
+ "DatabaseDriversLRU": [
+ "postgresql"
],
- "GitStage.ChangesTree.GroupingKeys": [
- "directory",
- "module",
- "repository"
+ "GitStage.ChangesTree.GroupingKeys": [
+ "directory",
+ "module",
+ "repository"
]
}
-}]]>
+}
@@ -125,8 +125,6 @@
-
-
@@ -177,6 +175,8 @@
+
+
diff --git a/assets/openapi.json b/assets/openapi.json
index edfae31..319060a 100644
--- a/assets/openapi.json
+++ b/assets/openapi.json
@@ -3236,6 +3236,11 @@
"type": "string",
"default": "Spacebar Instance"
},
+ "serverName": {
+ "type": "string",
+ "default": null,
+ "nullable": true
+ },
"instanceDescription": {
"type": "string",
"default": "This is a Spacebar instance made in the pre-release days",
@@ -3283,6 +3288,7 @@
"instanceDescription",
"instanceId",
"instanceName",
+ "serverName",
"tosPage"
]
},
@@ -12315,7 +12321,7 @@
"length": {
"type": "integer"
},
- "__@unscopables@700": {
+ "__@unscopables@698": {
"type": "object",
"additionalProperties": false,
"patternProperties": {
@@ -12444,17 +12450,17 @@
"remove": {
"type": "boolean"
},
- "__@iterator@698": {
+ "__@iterator@696": {
"type": "boolean"
},
- "__@unscopables@700": {
+ "__@unscopables@698": {
"type": "boolean"
}
}
}
},
"required": [
- "__@unscopables@700",
+ "__@unscopables@698",
"length"
]
},
@@ -18307,6 +18313,44 @@
]
}
},
+ "/guilds/{guild_id}/shield.svg/": {
+ "get": {
+ "security": [
+ {
+ "bearer": []
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "No description available"
+ },
+ "404": {
+ "description": "",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/APIErrorResponse"
+ }
+ }
+ }
+ }
+ },
+ "parameters": [
+ {
+ "name": "guild_id",
+ "in": "path",
+ "required": true,
+ "schema": {
+ "type": "string"
+ },
+ "description": "guild_id"
+ }
+ ],
+ "tags": [
+ "guilds"
+ ]
+ }
+ },
"/guilds/{guild_id}/roles/member-counts/": {
"get": {
"security": [
@@ -19816,42 +19860,6 @@
]
}
},
- "/guilds/{guild_id}/force-recount/": {
- "post": {
- "x-right-required": "MANAGE_GUILDS",
- "security": [
- {
- "bearer": []
- }
- ],
- "responses": {
- "200": {
- "description": "",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/APIGuild"
- }
- }
- }
- }
- },
- "parameters": [
- {
- "name": "guild_id",
- "in": "path",
- "required": true,
- "schema": {
- "type": "string"
- },
- "description": "guild_id"
- }
- ],
- "tags": [
- "guilds"
- ]
- }
- },
"/guilds/{guild_id}/emojis/": {
"get": {
"security": [
@@ -22545,56 +22553,6 @@
]
}
},
- "/channels/{channel_id}/messages/{message_id}/threads/": {
- "post": {
- "security": [
- {
- "bearer": []
- }
- ],
- "requestBody": {
- "required": true,
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/MessageThreadCreationSchema"
- }
- }
- }
- },
- "responses": {
- "200": {
- "description": "No description available"
- },
- "403": {
- "description": "No description available"
- }
- },
- "parameters": [
- {
- "name": "channel_id",
- "in": "path",
- "required": true,
- "schema": {
- "type": "string"
- },
- "description": "channel_id"
- },
- {
- "name": "message_id",
- "in": "path",
- "required": true,
- "schema": {
- "type": "string"
- },
- "description": "message_id"
- }
- ],
- "tags": [
- "channels"
- ]
- }
- },
"/channels/{channel_id}/messages/{message_id}/reactions/": {
"delete": {
"x-permission-required": "MANAGE_MESSAGES",
@@ -24001,74 +23959,6 @@
]
}
},
- "/auth/passwordless/start/": {
- "post": {
- "security": [
- {
- "bearer": []
- }
- ],
- "responses": {
- "400": {
- "description": "",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/APIErrorOrCaptchaResponse"
- }
- }
- }
- }
- },
- "tags": [
- "auth"
- ]
- }
- },
- "/auth/passwordless/finish/": {
- "post": {
- "security": [
- {
- "bearer": []
- }
- ],
- "requestBody": {
- "required": true,
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/WebAuthnSSOSchema"
- }
- }
- }
- },
- "responses": {
- "200": {
- "description": "",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/TokenResponse"
- }
- }
- }
- },
- "400": {
- "description": "",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/APIErrorResponse"
- }
- }
- }
- }
- },
- "tags": [
- "auth"
- ]
- }
- },
"/auth/mfa/webauthn/": {
"post": {
"requestBody": {
@@ -24340,50 +24230,6 @@
]
}
},
- "/auth/conditional/finish/": {
- "post": {
- "security": [
- {
- "bearer": []
- }
- ],
- "requestBody": {
- "required": true,
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/WebAuthnSSOSchema"
- }
- }
- }
- },
- "responses": {
- "200": {
- "description": "",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/TokenResponse"
- }
- }
- }
- },
- "400": {
- "description": "",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/APIErrorResponse"
- }
- }
- }
- }
- },
- "tags": [
- "auth"
- ]
- }
- },
"/attachments/refresh-urls/": {
"post": {
"security": [
diff --git a/assets/schemas.json b/assets/schemas.json
index f691b79..8cb3da2 100644
--- a/assets/schemas.json
+++ b/assets/schemas.json
@@ -3398,6 +3398,13 @@
"type": "string",
"default": "Spacebar Instance"
},
+ "serverName": {
+ "type": [
+ "null",
+ "string"
+ ],
+ "default": null
+ },
"instanceDescription": {
"type": [
"null",
@@ -3458,6 +3465,7 @@
"instanceDescription",
"instanceId",
"instanceName",
+ "serverName",
"tosPage"
],
"$schema": "http://json-schema.org/draft-07/schema#"
@@ -13083,7 +13091,7 @@
"length": {
"type": "integer"
},
- "__@unscopables@700": {
+ "__@unscopables@698": {
"type": "object",
"additionalProperties": false,
"patternProperties": {
@@ -13212,17 +13220,17 @@
"remove": {
"type": "boolean"
},
- "__@iterator@698": {
+ "__@iterator@696": {
"type": "boolean"
},
- "__@unscopables@700": {
+ "__@unscopables@698": {
"type": "boolean"
}
}
}
},
"required": [
- "__@unscopables@700",
+ "__@unscopables@698",
"length"
]
},
diff --git a/src/util/util/Database.ts b/src/util/util/Database.ts
index 7a0d084..95ced31 100644
--- a/src/util/util/Database.ts
+++ b/src/util/util/Database.ts
@@ -29,43 +29,51 @@
export let dbConnection: DataSource | undefined;
+let isHeadlessProcess = false;
// For typeorm cli
if (!process.env) {
+ isHeadlessProcess = true;
config({ quiet: true });
}
+if (process.argv[1]?.endsWith("scripts/openapi.js")) isHeadlessProcess = true;
const dbConnectionString = process.env.DATABASE || path.join(process.cwd(), "database.db");
export const DatabaseType = dbConnectionString.includes("://") ? dbConnectionString.split(":")[0]?.replace("+srv", "") : "sqlite";
const isSqlite = DatabaseType.includes("sqlite");
-let hasWarnedSqlite = false;
-if (isSqlite && !hasWarnedSqlite) {
- hasWarnedSqlite = true;
- console.log(`[Database] ${red(`You are running sqlite! Please keep in mind that we recommend setting up a dedicated database!`)}`);
- try {
- const _ = require("sqlite3");
- } catch (e) {
- console.log(`[Database] ${red(`Failed to load sqlite3 package. Please install it with 'npm install --no-save sqlite3', or switch to a real database like Postgres.`)}`);
- process.exit(1);
+// For openapi.js...
+if (!isHeadlessProcess) {
+ let hasWarnedSqlite = false;
+ if (isSqlite && !hasWarnedSqlite) {
+ hasWarnedSqlite = true;
+ console.log(`[Database] ${red(`You are running sqlite! Please keep in mind that we recommend setting up a dedicated database!`)}`);
+ try {
+ const _ = require("sqlite3");
+ } catch (e) {
+ console.log(`[Database] ${red(`Failed to load sqlite3 package. Please install it with 'npm install --no-save sqlite3', or switch to a real database like Postgres.`)}`);
+ process.exit(1);
+ }
}
}
-export const DataSourceOptions = new DataSource({
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
- //@ts-ignore type 'string' is not 'sqlite' | 'postgres' | etc etc
- type: DatabaseType,
- charset: "utf8mb4",
- url: isSqlite ? undefined : dbConnectionString,
- database: isSqlite ? dbConnectionString : undefined,
- entities: [path.join(__dirname, "..", "entities", "*.js")],
- synchronize: !!process.env.DB_SYNC,
- logging: !!process.env.DB_LOGGING,
- bigNumberStrings: false,
- supportBigNumbers: true,
- name: "default",
- migrations: [path.join(__dirname, "..", "migration", DatabaseType, "*.js")],
-});
+export const DataSourceOptions = isHeadlessProcess
+ ? (undefined as unknown as DataSource)
+ : new DataSource({
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
+ //@ts-ignore type 'string' is not 'sqlite' | 'postgres' | etc etc
+ type: DatabaseType,
+ charset: "utf8mb4",
+ url: isSqlite ? undefined : dbConnectionString,
+ database: isSqlite ? dbConnectionString : undefined,
+ entities: [path.join(__dirname, "..", "entities", "*.js")],
+ synchronize: !!process.env.DB_SYNC,
+ logging: !!process.env.DB_LOGGING,
+ bigNumberStrings: false,
+ supportBigNumbers: true,
+ name: "default",
+ migrations: [path.join(__dirname, "..", "migration", DatabaseType, "*.js")],
+ });
// Gets the existing database connection
export function getDatabase(): DataSource | null {