summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--.idea/workspace.xml84
-rw-r--r--assets/openapi.json250
-rw-r--r--assets/schemas.json16
-rw-r--r--src/util/util/Database.ts56
4 files changed, 134 insertions, 272 deletions
diff --git a/.idea/workspace.xml b/.idea/workspace.xml

index 25a9866f..741d94a6 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml
@@ -50,50 +50,50 @@ <option name="hideEmptyMiddlePackages" value="true" /> <option name="showLibraryContents" value="true" /> </component> - <component name="PropertiesComponent"><![CDATA[{ - "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" + <component name="PropertiesComponent">{ + &quot;keyToString&quot;: { + &quot;NIXITCH_NIXPKGS_CONFIG&quot;: &quot;/etc/nix/nixpkgs-config.nix&quot;, + &quot;NIXITCH_NIX_CONF_DIR&quot;: &quot;&quot;, + &quot;NIXITCH_NIX_OTHER_STORES&quot;: &quot;&quot;, + &quot;NIXITCH_NIX_PATH&quot;: &quot;/home/Rory/.nix-defexpr/channels:nixpkgs=/nix/store/wb6agba4kfsxpbnb5hzlq58vkjzvbsk6-source&quot;, + &quot;NIXITCH_NIX_PROFILES&quot;: &quot;/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&quot;, + &quot;NIXITCH_NIX_REMOTE&quot;: &quot;&quot;, + &quot;NIXITCH_NIX_USER_PROFILE_DIR&quot;: &quot;/nix/var/nix/profiles/per-user/Rory&quot;, + &quot;Node.js.Server.ts.executor&quot;: &quot;Debug&quot;, + &quot;RunOnceActivity.ShowReadmeOnStart&quot;: &quot;true&quot;, + &quot;RunOnceActivity.git.unshallow&quot;: &quot;true&quot;, + &quot;git-widget-placeholder&quot;: &quot;master&quot;, + &quot;javascript.nodejs.core.library.configured.version&quot;: &quot;24.11.1&quot;, + &quot;javascript.nodejs.core.library.typings.version&quot;: &quot;24.10.4&quot;, + &quot;last_opened_file_path&quot;: &quot;/home/Rory/git/spacebar/server-master/src/util/migration/postgres&quot;, + &quot;node.js.detected.package.eslint&quot;: &quot;true&quot;, + &quot;node.js.detected.package.standard&quot;: &quot;true&quot;, + &quot;node.js.selected.package.eslint&quot;: &quot;(autodetect)&quot;, + &quot;node.js.selected.package.standard&quot;: &quot;&quot;, + &quot;node.js.selected.package.tslint&quot;: &quot;(autodetect)&quot;, + &quot;nodejs_interpreter_path&quot;: &quot;node&quot;, + &quot;nodejs_package_manager_path&quot;: &quot;npm&quot;, + &quot;npm.Start API.executor&quot;: &quot;Run&quot;, + &quot;npm.Start CDN.executor&quot;: &quot;Run&quot;, + &quot;npm.Start Gateway.executor&quot;: &quot;Run&quot;, + &quot;npm.build.executor&quot;: &quot;Run&quot;, + &quot;npm.build:src.executor&quot;: &quot;Run&quot;, + &quot;npm.start.executor&quot;: &quot;Debug&quot;, + &quot;prettierjs.PrettierConfiguration.Package&quot;: &quot;/home/Rory/git/spacebar/server-master/node_modules/prettier&quot;, + &quot;settings.editor.selected.configurable&quot;: &quot;com.github.copilot.settings.customInstructions.CopilotInstructionsConfigurable&quot;, + &quot;ts.external.directory.path&quot;: &quot;/home/Rory/git/spacebar/server-master/node_modules/typescript/lib&quot; }, - "keyToStringList": { - "DatabaseDriversLRU": [ - "postgresql" + &quot;keyToStringList&quot;: { + &quot;DatabaseDriversLRU&quot;: [ + &quot;postgresql&quot; ], - "GitStage.ChangesTree.GroupingKeys": [ - "directory", - "module", - "repository" + &quot;GitStage.ChangesTree.GroupingKeys&quot;: [ + &quot;directory&quot;, + &quot;module&quot;, + &quot;repository&quot; ] } -}]]></component> +}</component> <component name="RecentsManager"> <key name="CopyFile.RECENT_KEYS"> <recent name="$PROJECT_DIR$/src/util/migration/postgres" /> @@ -125,8 +125,6 @@ <entry key="Start CDN" value="STOPPED" /> <entry key="Start Gateway" value="STOPPED" /> <entry key="Start bundle" value="STOPPED" /> - <entry key="build" value="STOPPED" /> - <entry key="build:src" value="STOPPED" /> </map> </value> </entry> @@ -177,6 +175,8 @@ <workItem from="1765142585081" duration="16912000" /> <workItem from="1765849511651" duration="7921000" /> <workItem from="1765861713706" duration="18045000" /> + <workItem from="1766715967914" duration="40995000" /> + <workItem from="1766823293461" duration="11580000" /> </task> <servers /> </component> diff --git a/assets/openapi.json b/assets/openapi.json
index edfae315..319060a5 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 f691b79e..8cb3da25 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 7a0d084f..95ced311 100644 --- a/src/util/util/Database.ts +++ b/src/util/util/Database.ts
@@ -29,43 +29,51 @@ import fs from "fs"; 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 {