From e0b526e7de810fd0fcfde45d22bb7edc72fe71ce Mon Sep 17 00:00:00 2001 From: Flam3rboy <34555296+Flam3rboy@users.noreply.github.com> Date: Sat, 25 Sep 2021 23:24:16 +0200 Subject: :sparkles: key value config --- util/src/entities/Config.ts | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) (limited to 'util/src/entities') diff --git a/util/src/entities/Config.ts b/util/src/entities/Config.ts index a460b437..6d9db470 100644 --- a/util/src/entities/Config.ts +++ b/util/src/entities/Config.ts @@ -1,12 +1,15 @@ -import { Column, Entity, JoinColumn, ManyToOne } from "typeorm"; -import { BaseClass } from "./BaseClass"; +import { Column, Entity, JoinColumn, ManyToOne, PrimaryColumn } from "typeorm"; +import { BaseClass, BaseClassWithoutId } from "./BaseClass"; import crypto from "crypto"; import { Snowflake } from "../util/Snowflake"; @Entity("config") -export class ConfigEntity extends BaseClass { - @Column({ type: "simple-json" }) - value: ConfigValue; +export class ConfigEntity extends BaseClassWithoutId { + @PrimaryColumn() + key: string; + + @Column({ type: "simple-json", nullable: true }) + value: number | boolean | null | string | undefined; } export interface RateLimitOptions { @@ -37,14 +40,16 @@ export interface KafkaBroker { export interface ConfigValue { gateway: { endpointClient: string | null; - endpoint: string | null; + endpointPrivate: string | null; + endpointPublic: string | null; }; cdn: { endpointClient: string | null; - endpoint: string | null; + endpointPublic: string | null; + endpointPrivate: string | null; }; general: { - instance_id: string; + instanceId: string; }; permissions: { user: { @@ -149,14 +154,16 @@ export interface ConfigValue { export const DefaultConfigOptions: ConfigValue = { gateway: { endpointClient: null, - endpoint: null, + endpointPrivate: null, + endpointPublic: null, }, cdn: { endpointClient: null, - endpoint: null, + endpointPrivate: null, + endpointPublic: null, }, general: { - instance_id: Snowflake.generate(), + instanceId: Snowflake.generate(), }, permissions: { user: { -- cgit 1.5.1