Remove fallback URIs, remove endpointClient, expose admin api

This commit is contained in:
Rory&
2025-12-04 10:36:26 +01:00
parent e981f491b7
commit 13bbf5dbd5
11 changed files with 22 additions and 27 deletions

View File

@@ -158,6 +158,9 @@ export class SpacebarServer extends Server {
baseUrl: Config.get().gateway.endpointPublic,
encoding: [...(erlpackSupported ? ["etf"] : []), "json"],
compression: ["zstd-stream", "zlib-stream", null],
},
admin: Config.get().admin.endpointPublic === null ? undefined : {
baseUrl: Config.get().admin.endpointPublic
}
});
});

View File

@@ -33,20 +33,14 @@ router.get(
async (req: Request, res: Response) => {
const { cdn, gateway, api } = Config.get();
const IdentityForm = {
cdn:
cdn.endpointPublic ||
process.env.CDN ||
"http://localhost:3001",
gateway:
gateway.endpointPublic ||
process.env.GATEWAY ||
"ws://localhost:3001",
defaultApiVersion: api.defaultVersion ?? 9,
apiEndpoint: api.endpointPublic ?? "http://localhost:3001/api/",
};
res.json(IdentityForm);
res.json({
admin: Config.get().admin.endpointPublic,
api: Config.get().api.endpointPublic?.split("/api")[0] || "", // Transitional, see /.well-known/spacebar/client
apiEndpoint: api.endpointPublic,
cdn: cdn.endpointPublic,
defaultApiVersion: api.defaultVersion,
gateway: gateway.endpointPublic,
});
},
);

View File

@@ -40,7 +40,7 @@ router.post("/:channel_id", multer.single("file"), async (req: Request, res: Res
const id = Snowflake.generate();
const path = `attachments/${channel_id}/${id}/${filename}`;
const endpoint = Config.get()?.cdn.endpointPublic || "http://localhost:3001";
const endpoint = Config.get()?.cdn.endpointPublic;
await storage.set(path, buffer);
let width;

View File

@@ -62,8 +62,7 @@ router.post(
if (ANIMATED_MIME_TYPES.includes(type.mime)) hash = `a_${hash}`; // animated icons have a_ infront of the hash
const path = `avatars/${user_id}/${hash}`;
const endpoint =
Config.get().cdn.endpointPublic || "http://localhost:3001";
const endpoint = Config.get().cdn.endpointPublic;
await storage.set(path, buffer);

View File

@@ -59,7 +59,7 @@ router.post("/", multer.single("file"), async (req: Request, res: Response) => {
if (ANIMATED_MIME_TYPES.includes(type.mime)) hash = `a_${hash}`; // animated icons have a_ infront of the hash
const path = `guilds/${guild_id}/users/${user_id}/avatars/${hash}`;
const endpoint = Config.get().cdn.endpointPublic || "http://localhost:3001";
const endpoint = Config.get().cdn.endpointPublic;
await storage.set(path, buffer);

View File

@@ -61,8 +61,7 @@ router.post(
throw new HTTPError("Invalid file type");
const path = `role-icons/${role_id}/${hash}.png`;
const endpoint =
Config.get().cdn.endpointPublic || "http://localhost:3001";
const endpoint = Config.get().cdn.endpointPublic;
await storage.set(path, buffer);

View File

@@ -542,7 +542,7 @@ export async function onIdentify(this: WebSocket, data: Payload) {
merged_members: merged_members,
sessions: allSessions,
resume_gateway_url: Config.get().gateway.endpointClient || Config.get().gateway.endpointPublic || "ws://127.0.0.1:3001",
resume_gateway_url: Config.get().gateway.endpointPublic!,
// lol hack whatever
required_action: Config.get().login.requireVerification && !user.verified ? "REQUIRE_VERIFIED_EMAIL" : undefined,

View File

@@ -17,8 +17,10 @@
*/
export interface InstanceDomainsResponse {
admin?: string;
api: string;
apiEndpoint: string;
cdn: string;
gateway: string;
defaultApiVersion: string;
apiEndpoint: string;
}

View File

@@ -40,6 +40,7 @@ import {
} from "../config";
export class ConfigValue {
admin: EndpointConfiguration = new EndpointConfiguration();
gateway: EndpointConfiguration = new EndpointConfiguration();
cdn: CdnConfiguration = new CdnConfiguration();
api: ApiConfiguration = new ApiConfiguration();
@@ -58,7 +59,6 @@ export class ConfigValue {
defaults: DefaultsConfiguration = new DefaultsConfiguration();
external: ExternalTokensConfiguration = new ExternalTokensConfiguration();
email: EmailConfiguration = new EmailConfiguration();
passwordReset: PasswordResetConfiguration =
new PasswordResetConfiguration();
passwordReset: PasswordResetConfiguration = new PasswordResetConfiguration();
user: UserConfiguration = new UserConfiguration();
}

View File

@@ -17,7 +17,6 @@
*/
export class EndpointConfiguration {
endpointClient: string | null = null;
endpointPrivate: string | null = null;
endpointPublic: string | null = null;
}

View File

@@ -20,8 +20,7 @@ import { Snowflake } from "@spacebar/util";
export class GeneralConfiguration {
instanceName: string = "Spacebar Instance";
instanceDescription: string | null =
"This is a Spacebar instance made in the pre-release days";
instanceDescription: string | null = "This is a Spacebar instance made in the pre-release days";
frontPage: string | null = null;
tosPage: string | null = null;
correspondenceEmail: string | null = null;