mirror of
https://github.com/versia-pub/server.git
synced 2026-03-13 13:59:16 +01:00
refactor(api): 🎨 Move User methods into their own class similar to Note
This commit is contained in:
parent
abc8f1ae16
commit
9d70778abd
81 changed files with 2055 additions and 1603 deletions
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue