all repos — stealth-developers @ 9b885fe8c0d7c22dd2e256a7f9db5bafcf9bdc4d

src/utils/woke.ts (view raw)

 1
 2
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
import { eq } from "drizzle-orm";
import { db, moderators } from "@/database";

type Moderator = {
  id: string;
  /** they */
  subjective: string;
  /** them */
  objective: string;
  /** their */
  possessiveDeterminer: string;
  /** theirs */
  possessive: string;
  /** themself */
  reflexive: string;
}


const defaultModerator: Omit<Moderator, 'id'> = {
  subjective: 'they',
  objective: 'them',
  possessiveDeterminer: 'their',
  possessive: 'theirs',
  reflexive: 'themself'
}

export function getModerator(id: string): Moderator {
  const moderator = db.select().from(moderators).where(eq(moderators.user_id, id)).get();
  if (!moderator) return { id, ...defaultModerator}
  return { id: id, ...moderator };
}

export function capitalise(str: string): string {
  return str.charAt(0).toUpperCase() + str.slice(1);
}