summary refs log tree commit diff
diff options
context:
space:
mode:
authorwhinis <whinis@whinis.com>2026-02-18 07:56:24 -0500
committerRory& <root@rory.gay>2026-02-18 14:14:14 +0100
commit97d271b2958f28613e5f99e5fed9e296c4653e17 (patch)
treebd41bd4f6f513f9b7fc72a2912aa68ced4adf489
parentAdd decorator to change Bigint back to string using Number (diff)
downloadserver-ts-97d271b2958f28613e5f99e5fed9e296c4653e17.tar.xz
Renamed to JsonNumber and removed from incorrectly typed date field
-rw-r--r--src/util/entities/BaseClass.ts4
-rw-r--r--src/util/entities/Member.ts3
-rw-r--r--src/util/entities/User.ts10
-rw-r--r--src/util/util/Decorators.ts4
4 files changed, 10 insertions, 11 deletions
diff --git a/src/util/entities/BaseClass.ts b/src/util/entities/BaseClass.ts

index 2b6c651b..b8bf73c4 100644 --- a/src/util/entities/BaseClass.ts +++ b/src/util/entities/BaseClass.ts
@@ -20,7 +20,7 @@ import { BaseEntity, BeforeInsert, BeforeUpdate, Column, ColumnOptions, FindOpti import { Snowflake } from "../util/Snowflake"; import { getDatabase } from "../util/Database"; import { OrmUtils } from "../imports/OrmUtils"; -import { annotationsKey } from "../util/Decorators"; +import { annotationsKey, JsonNumber } from "../util/Decorators"; export class BaseClassWithoutId extends BaseEntity { private get construct() { @@ -56,7 +56,7 @@ export class BaseClassWithoutId extends BaseEntity { if ( key in this && // This object has this property, should never fail but better to be safe key in annotations && // If this property has an annotation - annotations[key].indexOf("BigintToLong") > -1 && // if one of the annotations is JsonRemoveEmpty + annotations[key].indexOf("JsonNumber") > -1 && // if one of the annotations is JsonRemoveEmpty typeof this[key] == "string" // and its a String ) { // eslint-disable-next-line @typescript-eslint/ban-ts-comment diff --git a/src/util/entities/Member.ts b/src/util/entities/Member.ts
index 5d2de478..163c25f7 100644 --- a/src/util/entities/Member.ts +++ b/src/util/entities/Member.ts
@@ -29,7 +29,7 @@ import { Message } from "./Message"; import { Role } from "./Role"; import { User } from "./User"; import { AvatarDecorationData, Collectibles, DisplayNameStyle, PrimaryGuild, PublicMember, PublicMemberProjection, UserGuildSettings } from "@spacebar/schemas"; -import { BigintToLong } from "../util/Decorators"; +import { JsonNumber } from "../util/Decorators"; export const MemberPrivateProjection: (keyof Member)[] = [ "id", @@ -99,7 +99,6 @@ export class Member extends BaseClassWithoutId { joined_at: Date; @Column({ type: "bigint", nullable: true }) - @BigintToLong premium_since?: number; @Column() diff --git a/src/util/entities/User.ts b/src/util/entities/User.ts
index 57b90ee1..9a5f0d95 100644 --- a/src/util/entities/User.ts +++ b/src/util/entities/User.ts
@@ -38,7 +38,7 @@ import { PublicUserProjection, UserPrivate, } from "@spacebar/schemas"; -import { BigintToLong } from "../util/Decorators"; +import { JsonNumber } from "../util/Decorators"; @Entity({ name: "users", @@ -125,22 +125,22 @@ export class User extends BaseClass { email?: string; // email of the user @Column({ type: "bigint" }) - @BigintToLong + @JsonNumber flags: number = 0; // UserFlags // TODO: generate @Column({ type: "bigint" }) - @BigintToLong + @JsonNumber public_flags: number = 0; @Column({ type: "bigint" }) - @BigintToLong + @JsonNumber purchased_flags: number = 0; @Column() premium_usage_flags: number = 0; @Column({ type: "bigint" }) - @BigintToLong + @JsonNumber rights: string; @OneToMany(() => Session, (session: Session) => session.user) diff --git a/src/util/util/Decorators.ts b/src/util/util/Decorators.ts
index 0b7a67b6..dd2ec1b2 100644 --- a/src/util/util/Decorators.ts +++ b/src/util/util/Decorators.ts
@@ -20,7 +20,7 @@ export function JsonRemoveEmpty(target: BaseClassWithoutId, propertyKey: string) addAnnotationMetadata(target, propertyKey, "JsonRemoveEmpty"); } -export function BigintToLong(target: BaseClassWithoutId, propertyKey: string) { +export function JsonNumber(target: BaseClassWithoutId, propertyKey: string) { initAnnotationMetadata(target, propertyKey); - addAnnotationMetadata(target, propertyKey, "BigintToLong"); + addAnnotationMetadata(target, propertyKey, "JsonNumber"); }