summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/api/routes/unique-username/username-attempt-unauthed.ts11
-rw-r--r--src/api/routes/unique-username/username-suggestions-unauthed.ts4
-rw-r--r--src/util/schemas/UniqueUsernameAttemptSchema.ts3
-rw-r--r--src/util/schemas/UsernameAttemptUnauthedSchema.ts3
-rw-r--r--src/util/schemas/index.ts2
-rw-r--r--src/util/schemas/responses/TypedResponses.ts3
-rw-r--r--src/util/schemas/responses/UniqueUsernameAttemptResponse.ts3
-rw-r--r--src/util/schemas/responses/UsernameAttemptResponse.ts3
8 files changed, 19 insertions, 13 deletions
diff --git a/src/api/routes/unique-username/username-attempt-unauthed.ts b/src/api/routes/unique-username/username-attempt-unauthed.ts

index 3af1fa88..b225a299 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 9b112b55..2ce09285 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 00000000..39ebb25f --- /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 0ac83dd0..00000000 --- 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 bb449e45..f8fd5365 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 fa169c25..0f4f9c79 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 00000000..b9804f9c --- /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 864a3bb0..00000000 --- a/src/util/schemas/responses/UsernameAttemptResponse.ts +++ /dev/null
@@ -1,3 +0,0 @@ -export interface UsernameAttemptResponse { - taken: boolean; -}