rename unique uesrname response and schema

This commit is contained in:
Puyodead1
2023-12-23 17:31:31 -05:00
parent 5c220b4bdf
commit cf34ab1674
10 changed files with 19 additions and 13 deletions

Binary file not shown.

Binary file not shown.

View File

@@ -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(

View File

@@ -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",

View File

@@ -0,0 +1,3 @@
export interface UniqueUsernameAttemptSchema {
username: string;
}

View File

@@ -1,3 +0,0 @@
export interface UsernameAttemptUnauthedSchema {
username: string;
}

View File

@@ -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";

View File

@@ -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;
}

View File

@@ -0,0 +1,3 @@
export interface UniqueUsernameAttemptResponse {
taken: boolean;
}

View File

@@ -1,3 +0,0 @@
export interface UsernameAttemptResponse {
taken: boolean;
}