mirror of
https://github.com/spacebarchat/server.git
synced 2026-04-02 22:05:39 +00:00
rename unique uesrname response and schema
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -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(
|
||||
|
||||
@@ -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",
|
||||
|
||||
3
src/util/schemas/UniqueUsernameAttemptSchema.ts
Normal file
3
src/util/schemas/UniqueUsernameAttemptSchema.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
export interface UniqueUsernameAttemptSchema {
|
||||
username: string;
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
export interface UsernameAttemptUnauthedSchema {
|
||||
username: string;
|
||||
}
|
||||
@@ -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";
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
export interface UniqueUsernameAttemptResponse {
|
||||
taken: boolean;
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
export interface UsernameAttemptResponse {
|
||||
taken: boolean;
|
||||
}
|
||||
Reference in New Issue
Block a user