refactor(api): 🎨 Move User methods into their own class similar to Note

This commit is contained in:
Jesse Wierzbinski 2024-04-24 17:40:27 -10:00
parent abc8f1ae16
commit 9d70778abd
No known key found for this signature in database
81 changed files with 2055 additions and 1603 deletions

View file

@ -7,11 +7,8 @@ import { RequestParser } from "request-parser";
import type { ZodType, z } from "zod";
import { fromZodError } from "zod-validation-error";
import type { Application } from "~database/entities/Application";
import {
type AuthData,
type UserWithRelations,
getFromRequest,
} from "~database/entities/User";
import { type AuthData, getFromRequest } from "~database/entities/User";
import type { User } from "~packages/database-interface/user";
type MaybePromise<T> = T | Promise<T>;
type HttpVerb = "GET" | "POST" | "PUT" | "DELETE" | "PATCH" | "OPTIONS";
@ -24,11 +21,11 @@ export type RouteHandler<
matchedRoute: MatchedRoute,
extraData: {
auth: {
// If the route doesn't require authentication, set the type to UserWithRelations | null
// Otherwise set to UserWithRelations
// If the route doesn't require authentication, set the type to User | null
// Otherwise set to User
user: RouteMeta["auth"]["required"] extends true
? UserWithRelations
: UserWithRelations | null;
? User
: User | null;
token: RouteMeta["auth"]["required"] extends true
? string
: string | null;