1
0
mirror of https://github.com/spacebarchat/server.git synced 2024-11-05 10:22:31 +01:00

Add additional config

This commit is contained in:
Madeline 2022-12-19 16:51:24 +11:00
parent bc669ea9e1
commit d407d8ebe7
15 changed files with 53 additions and 24 deletions

View File

@ -18,7 +18,7 @@ export const DEFAULT_FETCH_OPTIONS: any = {
export const getProxyUrl = (url: URL, width: number, height: number): string => {
const { resizeWidthMax, resizeHeightMax, imagorServerUrl } = Config.get().cdn;
const secret = Config.get().security.jwtSecret; // maybe shouldn't use this?
const secret = Config.get().security.requestSignature;
width = Math.min(width || 500, resizeWidthMax || width);
height = Math.min(height || 500, resizeHeightMax || width);

View File

@ -10,8 +10,8 @@ import {
VoiceState,
VoiceStateUpdateEvent,
VoiceStateUpdateSchema,
Region,
} from "@fosscord/util";
import { Region } from "@fosscord/util/src/config";
// TODO: check if a voice server is setup
// Notice: Bot users respect the voice channel's user limit, if set.

View File

@ -1,8 +1,28 @@
import { ApiConfiguration, ClientConfiguration, DefaultsConfiguration, EndpointConfiguration, GeneralConfiguration, GifConfiguration, GuildConfiguration, KafkaConfiguration, LimitsConfiguration, LoginConfiguration, MetricsConfiguration, RabbitMQConfiguration, RegionConfiguration, RegisterConfiguration, SecurityConfiguration, SentryConfiguration, TemplateConfiguration } from "../config";
import {
ApiConfiguration,
CdnConfiguration,
ClientConfiguration,
DefaultsConfiguration,
EndpointConfiguration,
ExternalTokensConfiguration,
GeneralConfiguration,
GifConfiguration,
GuildConfiguration,
KafkaConfiguration,
LimitsConfiguration,
LoginConfiguration,
MetricsConfiguration,
RabbitMQConfiguration,
RegionConfiguration,
RegisterConfiguration,
SecurityConfiguration,
SentryConfiguration,
TemplateConfiguration
} from "../config";
export class ConfigValue {
gateway: EndpointConfiguration = new EndpointConfiguration();
cdn: EndpointConfiguration = new EndpointConfiguration();
cdn: CdnConfiguration = new CdnConfiguration();
api: ApiConfiguration = new ApiConfiguration();
general: GeneralConfiguration = new GeneralConfiguration();
limits: LimitsConfiguration = new LimitsConfiguration();
@ -19,4 +39,5 @@ export class ConfigValue {
metrics: MetricsConfiguration = new MetricsConfiguration();
sentry: SentryConfiguration = new SentryConfiguration();
defaults: DefaultsConfiguration = new DefaultsConfiguration();
external: ExternalTokensConfiguration = new ExternalTokensConfiguration();
}

View File

@ -1,2 +1,2 @@
export * from "./Config";
export * from "./types/index";
export * from "./types";

View File

@ -0,0 +1,7 @@
import { EndpointConfiguration } from "./EndpointConfiguration";
export class CdnConfiguration extends EndpointConfiguration {
resizeHeightMax: number = 1000;
resizeWidthMax: number = 1000;
imagorServerUrl: string | null = null;
}

View File

@ -1,8 +1,6 @@
import { ClientReleaseConfiguration } from ".";
export class ClientConfiguration {
//classes
releases: ClientReleaseConfiguration = new ClientReleaseConfiguration();
//base types
useTestClient: boolean = true;
}

View File

@ -0,0 +1,3 @@
export class ExternalTokensConfiguration {
twitter: string | null = null;
}

View File

@ -1,11 +1,11 @@
import { Snowflake } from "../../util";
import { Snowflake } from "@fosscord/util";
export class GeneralConfiguration {
instanceName: string = "Fosscord Instance";
instanceDescription: string | null = "This is a Fosscord instance made in the pre-release days";
frontPage: string | null = null;
tosPage: string | null = null;
correspondenceEmail: string | null = "noreply@localhost.local";
correspondenceEmail: string | null = null;
correspondenceUserID: string | null = null;
image: string | null = null;
instanceId: string = Snowflake.generate();

View File

@ -3,4 +3,5 @@ import { DiscoveryConfiguration, AutoJoinConfiguration } from ".";
export class GuildConfiguration {
discovery: DiscoveryConfiguration = new DiscoveryConfiguration();
autoJoin: AutoJoinConfiguration = new AutoJoinConfiguration();
defaultFeatures: string[] = [];
}

View File

@ -1,11 +1,9 @@
import { DateOfBirthConfiguration, EmailConfiguration, PasswordConfiguration } from ".";
export class RegisterConfiguration {
//classes
email: EmailConfiguration = new EmailConfiguration();
dateOfBirth: DateOfBirthConfiguration = new DateOfBirthConfiguration();
password: PasswordConfiguration = new PasswordConfiguration();
//base types
disabled: boolean = false;
requireCaptcha: boolean = true;
requireInvite: boolean = false;
@ -14,5 +12,5 @@ export class RegisterConfiguration {
allowMultipleAccounts: boolean = true;
blockProxies: boolean = true;
incrementingDiscriminators: boolean = false; // random otherwise
defaultRights: string = "0";
defaultRights: string = "30644591655940"; // See `npm run generate:rights`
}

View File

@ -2,10 +2,8 @@ import crypto from "crypto";
import { CaptchaConfiguration, TwoFactorConfiguration } from ".";
export class SecurityConfiguration {
//classes
captcha: CaptchaConfiguration = new CaptchaConfiguration();
twoFactor: TwoFactorConfiguration = new TwoFactorConfiguration();
//base types
autoUpdate: boolean | number = true;
requestSignature: string = crypto.randomBytes(32).toString("base64");
jwtSecret: string = crypto.randomBytes(256).toString("base64");

View File

@ -1,7 +1,9 @@
export * from "./ApiConfiguration";
export * from "./CdnConfiguration";
export * from "./ClientConfiguration";
export * from "./DefaultsConfiguration";
export * from "./EndpointConfiguration";
export * from "./ExternalTokensConfiguration";
export * from "./GeneralConfiguration";
export * from "./GifConfiguration";
export * from "./GuildConfiguration";
@ -15,4 +17,4 @@ export * from "./RegisterConfiguration";
export * from "./SecurityConfiguration";
export * from "./SentryConfiguration";
export * from "./TemplateConfiguration";
export * from "./subconfigurations/index";
export * from "./subconfigurations";

View File

@ -1,8 +1,8 @@
export * from "./client/index";
export * from "./defaults/index";
export * from "./guild/index";
export * from "./kafka/index";
export * from "./limits/index";
export * from "./region/index";
export * from "./register/index";
export * from "./security/index";
export * from "./client";
export * from "./defaults";
export * from "./guild";
export * from "./kafka";
export * from "./limits";
export * from "./region";
export * from "./register";
export * from "./security";

View File

@ -344,7 +344,7 @@ export class User extends BaseClass {
disabled: false,
deleted: false,
email: email,
rights: Config.get().security.defaultRights,
rights: Config.get().register.defaultRights,
nsfw_allowed: true, // TODO: depending on age
public_flags: 0,
flags: "0", // TODO: generate

View File

@ -6,3 +6,4 @@ export * from "./entities/index";
export * from "./dtos/index";
export * from "./schemas";
export * from "./imports";
export * from "./config"