From cf34ab167477a1fd86f017f2aee7ec1e849e8a05 Mon Sep 17 00:00:00 2001 From: Puyodead1 Date: Sat, 23 Dec 2023 17:31:31 -0500 Subject: [PATCH] rename unique uesrname response and schema --- assets/openapi.json | Bin 577326 -> 584745 bytes assets/schemas.json | Bin 18699325 -> 18987700 bytes .../username-attempt-unauthed.ts | 11 ++++++----- .../username-suggestions-unauthed.ts | 4 +++- .../schemas/UniqueUsernameAttemptSchema.ts | 3 +++ .../schemas/UsernameAttemptUnauthedSchema.ts | 3 --- src/util/schemas/index.ts | 2 +- src/util/schemas/responses/TypedResponses.ts | 3 +++ .../UniqueUsernameAttemptResponse.ts | 3 +++ .../responses/UsernameAttemptResponse.ts | 3 --- 10 files changed, 19 insertions(+), 13 deletions(-) create mode 100644 src/util/schemas/UniqueUsernameAttemptSchema.ts delete mode 100644 src/util/schemas/UsernameAttemptUnauthedSchema.ts create mode 100644 src/util/schemas/responses/UniqueUsernameAttemptResponse.ts delete mode 100644 src/util/schemas/responses/UsernameAttemptResponse.ts diff --git a/assets/openapi.json b/assets/openapi.json index c3e1419dd51b37b25225afcf02a85a9c3ba66c0e..0705f4ffe560704ef696a7dab07171f21ca5118e 100644 GIT binary patch delta 883 zcmZ2CPkH4H<%SlfRZI3r%kuhW|$j?p9$)8@B&muhiK^2G8^b74Q6YHIG5;Jp) z6%rLn!DnXTp7Nvqr1o==Q6s%am9jK!`u~H$mEH$r0Pf3SM0RkphGjmP<(8T&$G!$E? zY&V?CGL?}F;rHo^D_ACP+rmDFar%ZtR=MdDZnC)XL42lLT$-MqT3j;yU=rJ==@)LX z@cY4Bod|RsSPtZBG=CPC6lLb6DZP~b4y2>@8FP$~cb delta 224 zcmZ2^LwVgi<%SlGK!BM=I4?0b)v=@`HMgK7G%vBVBqKFt`a)-> zr0ET(nZ2h6=rXxaHxOd7*v_fMoH-M$W&8XS%rDBOKQLkypRSd|9KHR&JBYOVf0PYb^ZY&Kar6*$SCy3W*A(#i>Og z%M~(<6{gQ+XOfv-(8|I(?GM}Y$q7AJ-L?JWM7F7nAldfEMyx>02E^>!9~*JF?F0bh C)mG2| diff --git a/assets/schemas.json b/assets/schemas.json index b12357ca71db964109a097a39263d0850eb49f41..b27dc2c789dbc19417dae5b61702852843d78dc0 100644 GIT binary patch delta 1167 zcmXxjX;jp86o>IM3OF;MvNIrVWmsfrnc@;IM3$2FZ$Y!vz|N#3km6vAic8;^6lp5b zzb!6lg%zbGHsuoNxMh?}i?&$UVwPIAOlphy{5r=MpXbFr_vO7?)`Xo6;VRc$In+w6 z6`@E)sg0a+$*pL`sIA(my<^Pq6~G{ zrMgU+x?DYUg|gIBy>z9nQg2RRRLIt|nHxg-q> z8#mfszHV2%KTw~8LBT-%;DK58sj=fC{F$KwjK&z;j6%A&P>Tp^0mI z`#l+6+=EG&jAGo2DJVfH%5Wd1Vj9XZ9X?cG2JXiLcn}X^CT3waDlrFhF%R?cFoZ`? z1wS6e0xU!|7NG`@A%Ms61fE1Kp2A`*fsLhj8qeTaJcngijulvm=dlW_@d94NOQ^#d zyo^`yD(dkXUdLLj!y9-L>(PJ>cnd+ijd!pSo3I&M@GctBgss?y5Vm6nc48NH<2~%b z`$11ebH8-ARbD)!$Y&12K2qaJwhM>N&aT~?kY{(vZ;tY}REDrU*iyM;Ot#Cam{?ML z_l4CJd+J<{6uYU=8SQslTd^(Zwn784{8nx=KEQ|Ai+$LS1NaCZ;}d*}gE)lG@HxJ~ zmpF{C@HJX+1mECWe24FG6hGh?e#B2WjuSYEpYaP$;aB{I-|+{+_!Fmb250dX{>DG} z7w7O_wUz4#z@(K)Ym*3*NRud&HYQFJmxIGk#dX3~L$aJu8rc@fcVrQw%VeU7(-No;|x`DmIFZm>3s!cLx@V zUGIN!PF(6#kE539{DJ* z^2t~ERX~37S3wn0VHHtP1*n*ctAt9bluE0N%Bq~otAZ*jP?c0!Ra8~gR9!VxQ?(SN z+Nz_vs;ByDpoVIs#%iLbYNqCDp_Xc;)@q}+YNz(5Ct2CV+2NG6h>nV z#$p`CV*(~38ZnrJ$q=SsD(sks>6n3;n1$Jx0|(|}9_C{K7Ge<=!-*wWie*@i6zbduRYOq372sNS8)y3aRWDT3%79xcX1E*@c<9;2#@gu zPw@=T@d7XL3a{}7Z;_05c#jYGh)+ntXM8~_zTz9c;|G4?7k=Xp{^H-vM3=<@lbb1x zDXl4;DZMF!$=&2(%4o`D%52JF@-$^NWiw?re@jAANI^?-kN+eq)kgpT diff --git a/src/api/routes/unique-username/username-attempt-unauthed.ts b/src/api/routes/unique-username/username-attempt-unauthed.ts index 3af1fa883..b225a2996 100644 --- a/src/api/routes/unique-username/username-attempt-unauthed.ts +++ b/src/api/routes/unique-username/username-attempt-unauthed.ts @@ -1,5 +1,5 @@ import { route } from "@spacebar/api"; -import { Config, User, UsernameAttemptUnauthedSchema } from "@spacebar/util"; +import { Config, UniqueUsernameAttemptSchema, User } from "@spacebar/util"; import { Request, Response, Router } from "express"; import { HTTPError } from "lambert-server"; const router = Router(); @@ -7,15 +7,16 @@ const router = Router(); router.post( "/", route({ - requestBody: "UsernameAttemptUnauthedSchema", + requestBody: "UniqueUsernameAttemptSchema", responses: { - 200: { body: "UsernameAttemptResponse" }, + 200: { body: "UniqueUsernameAttemptResponse" }, 400: { body: "APIErrorResponse" }, }, - description: "Check if a username is available", + description: + "Checks whether a unique username is available for the user to claim.", }), async (req: Request, res: Response) => { - const body = req.body as UsernameAttemptUnauthedSchema; + const body = req.body as UniqueUsernameAttemptSchema; const { uniqueUsernames } = Config.get().general; if (!uniqueUsernames) { throw new HTTPError( diff --git a/src/api/routes/unique-username/username-suggestions-unauthed.ts b/src/api/routes/unique-username/username-suggestions-unauthed.ts index 9b112b558..2ce09285b 100644 --- a/src/api/routes/unique-username/username-suggestions-unauthed.ts +++ b/src/api/routes/unique-username/username-suggestions-unauthed.ts @@ -1,12 +1,14 @@ import { route } from "@spacebar/api"; +import { Config } from "@spacebar/util"; import { Request, Response, Router } from "express"; import { HTTPError } from "lambert-server"; -import { Config } from "../../../util"; const router = Router(); router.get( "/", route({ + description: + "Returns a suggested unique username string based on the current user's username.", query: { global_name: { type: "string", diff --git a/src/util/schemas/UniqueUsernameAttemptSchema.ts b/src/util/schemas/UniqueUsernameAttemptSchema.ts new file mode 100644 index 000000000..39ebb25f2 --- /dev/null +++ b/src/util/schemas/UniqueUsernameAttemptSchema.ts @@ -0,0 +1,3 @@ +export interface UniqueUsernameAttemptSchema { + username: string; +} diff --git a/src/util/schemas/UsernameAttemptUnauthedSchema.ts b/src/util/schemas/UsernameAttemptUnauthedSchema.ts deleted file mode 100644 index 0ac83dd0e..000000000 --- a/src/util/schemas/UsernameAttemptUnauthedSchema.ts +++ /dev/null @@ -1,3 +0,0 @@ -export interface UsernameAttemptUnauthedSchema { - username: string; -} diff --git a/src/util/schemas/index.ts b/src/util/schemas/index.ts index bb449e450..f8fd5365f 100644 --- a/src/util/schemas/index.ts +++ b/src/util/schemas/index.ts @@ -66,13 +66,13 @@ export * from "./TemplateModifySchema"; export * from "./TotpDisableSchema"; export * from "./TotpEnableSchema"; export * from "./TotpSchema"; +export * from "./UniqueUsernameAttemptSchema"; export * from "./UserDeleteSchema"; export * from "./UserGuildSettingsSchema"; export * from "./UserModifySchema"; export * from "./UserNoteUpdateSchema"; export * from "./UserProfileModifySchema"; export * from "./UserSettingsSchema"; -export * from "./UsernameAttemptUnauthedSchema"; export * from "./Validator"; export * from "./VanityUrlSchema"; export * from "./VoiceIdentifySchema"; diff --git a/src/util/schemas/responses/TypedResponses.ts b/src/util/schemas/responses/TypedResponses.ts index fa169c253..0f4f9c79f 100644 --- a/src/util/schemas/responses/TypedResponses.ts +++ b/src/util/schemas/responses/TypedResponses.ts @@ -60,6 +60,9 @@ export type APIDMChannelArray = DmChannelDTO[]; export type APIBackupCodeArray = BackupCode[]; +export type PrivateUserResponse = APIPrivateUser; +export type PublicUserResponse = APIPublicUser; + export interface UserUpdateResponse extends APIPrivateUser { newToken?: string; } diff --git a/src/util/schemas/responses/UniqueUsernameAttemptResponse.ts b/src/util/schemas/responses/UniqueUsernameAttemptResponse.ts new file mode 100644 index 000000000..b9804f9cc --- /dev/null +++ b/src/util/schemas/responses/UniqueUsernameAttemptResponse.ts @@ -0,0 +1,3 @@ +export interface UniqueUsernameAttemptResponse { + taken: boolean; +} diff --git a/src/util/schemas/responses/UsernameAttemptResponse.ts b/src/util/schemas/responses/UsernameAttemptResponse.ts deleted file mode 100644 index 864a3bb00..000000000 --- a/src/util/schemas/responses/UsernameAttemptResponse.ts +++ /dev/null @@ -1,3 +0,0 @@ -export interface UsernameAttemptResponse { - taken: boolean; -}