diff --git a/frontend-service/src/main/vue/api/piperchat/channel.ts b/frontend-service/src/main/vue/api/piperchat/channel.ts index 31e35c1ee..7292d38d1 100644 --- a/frontend-service/src/main/vue/api/piperchat/channel.ts +++ b/frontend-service/src/main/vue/api/piperchat/channel.ts @@ -1,292 +1,292 @@ -import {type Empty, ErrorResponse, Response} from "../response"; -import type {RequestSchema} from "../schema"; +import { type Empty, ErrorResponse, Response } from "../response"; +import type { RequestSchema } from "../schema"; /* eslint-disable @typescript-eslint/no-namespace */ export module GetChannelsApi { - export module Request { - export type Type = Body & Params; - export type Params = { - serverId: string; - }; - export type Body = Empty; - export const Schema: RequestSchema = { - Params: { - serverId: "string", - }, - Body: {}, - }; + export module Request { + export type Type = Body & Params; + export type Params = { + serverId: string; + }; + export type Body = Empty; + export const Schema: RequestSchema = { + Params: { + serverId: "string", + }, + Body: {}, + }; + } + + export module Responses { + interface Channel { + id: string; + name: string; + type: string; + description?: string; } - export module Responses { - interface Channel { - id: string; - name: string; - type: string; - description?: string; - } + export class Success extends Response { + statusCode = 200; + message = "Channels retrieved successfully"; - export class Success extends Response { - statusCode = 200; - message = "Channels retrieved successfully"; - - constructor(public channels: Channel[]) { - super(); - } - } + constructor(public channels: Channel[]) { + super(); + } + } - export type Type = Success; + export type Type = Success; + } + export module Errors { + export class ServerNotFound extends ErrorResponse { + statusCode = 404; + error = "Server not found" as const; } - export module Errors { - export class ServerNotFound extends ErrorResponse { - statusCode = 404; - error = "Server not found" as const; - } - - export class UserNotAuthorized extends ErrorResponse { - statusCode = 403; - error = "User not authorized" as const; - } - - export type Type = ServerNotFound | UserNotAuthorized; + + export class UserNotAuthorized extends ErrorResponse { + statusCode = 403; + error = "User not authorized" as const; } - export type Response = Responses.Type | Errors.Type; + + export type Type = ServerNotFound | UserNotAuthorized; + } + export type Response = Responses.Type | Errors.Type; } export module GetChannelByIdApi { - export module Request { - export type Type = Body & Params; - export type Params = { - serverId: string; - channelId: string; - }; - export const Schema: RequestSchema = { - Params: { - serverId: "string", - channelId: "string", - }, - Body: {}, - }; + export module Request { + export type Type = Body & Params; + export type Params = { + serverId: string; + channelId: string; + }; + export const Schema: RequestSchema = { + Params: { + serverId: "string", + channelId: "string", + }, + Body: {}, + }; + } + export module Responses { + export interface Channel { + id: string; + name: string; + createdAt: Date; + channelType: string; + description?: string; } - export module Responses { - export interface Channel { - id: string; - name: string; - createdAt: Date; - channelType: string; - description?: string; - } - - export class Success extends Response { - statusCode = 200; - message = "Channels retrieved successfully"; - - constructor(public channel: Channel) { - super(); - } - } - - export type Type = Success; + + export class Success extends Response { + statusCode = 200; + message = "Channels retrieved successfully"; + + constructor(public channel: Channel) { + super(); + } } - export module Errors { - export class ChannelNotFound extends ErrorResponse { - statusCode = 404; - error = "Channel not found" as const; - } - - export class UserNotAuthorized extends ErrorResponse { - statusCode = 403; - error = "User not authorized" as const; - } - - export class ServerNotFound extends ErrorResponse { - statusCode = 404; - error = "Server not found" as const; - } - - export type Type = ChannelNotFound | UserNotAuthorized | ServerNotFound; + + export type Type = Success; + } + export module Errors { + export class ChannelNotFound extends ErrorResponse { + statusCode = 404; + error = "Channel not found" as const; } - export type Response = Responses.Type | Errors.Type; + + export class UserNotAuthorized extends ErrorResponse { + statusCode = 403; + error = "User not authorized" as const; + } + + export class ServerNotFound extends ErrorResponse { + statusCode = 404; + error = "Server not found" as const; + } + + export type Type = ChannelNotFound | UserNotAuthorized | ServerNotFound; + } + export type Response = Responses.Type | Errors.Type; } export module CreateChannelApi { - export enum ChannelType { - Messages = "TEXT", - Multimedia = "MULTIMEDIA", + export enum ChannelType { + Messages = "TEXT", + Multimedia = "MULTIMEDIA", + } + + export module Request { + export type Type = Body & Params; + export type Params = { + serverId: string; + }; + export type Body = { + name: string; + channelType: ChannelType; + description?: string; + }; + export const Schema: RequestSchema = { + Params: { + serverId: "string", + }, + Body: { + name: "string", + channelType: "string", + description: "string?", + }, + }; + } + export module Responses { + interface Channel { + id: string; + name: string; + createdAt: Date; + channelType: string; + description?: string; + } + + export class Success extends Response { + statusCode = 200; + message = "Channel created successfully"; + channel: Channel; + + constructor(channel: Channel) { + super(); + this.channel = channel; + } } - export module Request { - export type Type = Body & Params; - export type Params = { - serverId: string; - }; - export type Body = { - name: string; - channelType: ChannelType; - description?: string; - }; - export const Schema: RequestSchema = { - Params: { - serverId: "string", - }, - Body: { - name: "string", - channelType: "string", - description: "string?", - }, - }; + export type Type = Success; + } + export module Errors { + export class ServerNotFound extends ErrorResponse { + statusCode = 404; + error = "Server not found" as const; } - export module Responses { - interface Channel { - id: string; - name: string; - createdAt: Date; - channelType: string; - description?: string; - } - - export class Success extends Response { - statusCode = 200; - message = "Channel created successfully"; - channel: Channel; - - constructor(channel: Channel) { - super(); - this.channel = channel; - } - } - - export type Type = Success; + + export class UserNotAuthorized extends ErrorResponse { + statusCode = 403; + error = "User not authorized" as const; + } + + export class ChannelAlreadyExists extends ErrorResponse { + statusCode = 409; + error = "Channel already exists" as const; } - export module Errors { - export class ServerNotFound extends ErrorResponse { - statusCode = 404; - error = "Server not found" as const; - } - - export class UserNotAuthorized extends ErrorResponse { - statusCode = 403; - error = "User not authorized" as const; - } - - export class ChannelAlreadyExists extends ErrorResponse { - statusCode = 409; - error = "Channel already exists" as const; - } - - export class InvalidChannelType extends ErrorResponse { - statusCode = 400; - error = "Invalid channel type" as const; - } - - export type Type = - | ServerNotFound - | UserNotAuthorized - | ChannelAlreadyExists - | InvalidChannelType; + + export class InvalidChannelType extends ErrorResponse { + statusCode = 400; + error = "Invalid channel type" as const; } - export type Response = Responses.Type | Errors.Type; + + export type Type = + | ServerNotFound + | UserNotAuthorized + | ChannelAlreadyExists + | InvalidChannelType; + } + export type Response = Responses.Type | Errors.Type; } export module UpdateChannelApi { - export module Request { - export type Type = Body & Params; - export type Params = { - serverId: string; - channelId: string; - }; - export type Body = { - name?: string; - description?: string; - }; - export const Schema: RequestSchema = { - Params: { - serverId: "string", - channelId: "string", - }, - Body: { - name: "string?", - description: "string?", - }, - }; + export module Request { + export type Type = Body & Params; + export type Params = { + serverId: string; + channelId: string; + }; + export type Body = { + name?: string; + description?: string; + }; + export const Schema: RequestSchema = { + Params: { + serverId: "string", + channelId: "string", + }, + Body: { + name: "string?", + description: "string?", + }, + }; + } + export module Responses { + export class Success extends Response { + statusCode = 200; + message = "Channel updated successfully"; + } + + export type Type = Success; + } + export module Errors { + export class ServerNotFound extends ErrorResponse { + statusCode = 404; + error = "Server not found" as const; } - export module Responses { - export class Success extends Response { - statusCode = 200; - message = "Channel updated successfully"; - } - export type Type = Success; + export class ChannelNotFound extends ErrorResponse { + statusCode = 404; + error = "Channel not found" as const; } - export module Errors { - export class ServerNotFound extends ErrorResponse { - statusCode = 404; - error = "Server not found" as const; - } - - export class ChannelNotFound extends ErrorResponse { - statusCode = 404; - error = "Channel not found" as const; - } - - export class UserNotAuthorized extends ErrorResponse { - statusCode = 403; - error = "User not authorized" as const; - } - - export class ChannelAlreadyExists extends ErrorResponse { - statusCode = 409; - error = "Channel already exists" as const; - } - - export type Type = - | ServerNotFound - | ChannelNotFound - | UserNotAuthorized - | ChannelAlreadyExists; + + export class UserNotAuthorized extends ErrorResponse { + statusCode = 403; + error = "User not authorized" as const; } - export type Response = Responses.Type | Errors.Type; + + export class ChannelAlreadyExists extends ErrorResponse { + statusCode = 409; + error = "Channel already exists" as const; + } + + export type Type = + | ServerNotFound + | ChannelNotFound + | UserNotAuthorized + | ChannelAlreadyExists; + } + export type Response = Responses.Type | Errors.Type; } export module DeleteChannelApi { - export module Request { - export type Type = Body & Params; - export type Params = { - serverId: string; - channelId: string; - }; - export type Body = Empty; - export const Schema: RequestSchema = { - Params: { - serverId: "string", - channelId: "string", - }, - Body: {}, - }; + export module Request { + export type Type = Body & Params; + export type Params = { + serverId: string; + channelId: string; + }; + export type Body = Empty; + export const Schema: RequestSchema = { + Params: { + serverId: "string", + channelId: "string", + }, + Body: {}, + }; + } + export module Responses { + export class Success extends Response { + statusCode = 200; + message = "Channel deleted successfully"; } - export module Responses { - export class Success extends Response { - statusCode = 200; - message = "Channel deleted successfully"; - } - export type Type = Success; + export type Type = Success; + } + export module Errors { + export class ServerNotFound extends ErrorResponse { + statusCode = 404; + error = "Server not found" as const; } - export module Errors { - export class ServerNotFound extends ErrorResponse { - statusCode = 404; - error = "Server not found" as const; - } - - export class ChannelNotFound extends ErrorResponse { - statusCode = 404; - error = "Channel not found" as const; - } - - export class UserNotAuthorized extends ErrorResponse { - statusCode = 403; - error = "User not authorized" as const; - } - - export type Type = ServerNotFound | ChannelNotFound | UserNotAuthorized; + + export class ChannelNotFound extends ErrorResponse { + statusCode = 404; + error = "Channel not found" as const; } - export type Response = Responses.Type | Errors.Type; + + export class UserNotAuthorized extends ErrorResponse { + statusCode = 403; + error = "User not authorized" as const; + } + + export type Type = ServerNotFound | ChannelNotFound | UserNotAuthorized; + } + export type Response = Responses.Type | Errors.Type; } diff --git a/frontend-service/src/main/vue/controllers/piperchat/server/server-controller-impl.ts b/frontend-service/src/main/vue/controllers/piperchat/server/server-controller-impl.ts index f30963ed5..6db6e76b2 100644 --- a/frontend-service/src/main/vue/controllers/piperchat/server/server-controller-impl.ts +++ b/frontend-service/src/main/vue/controllers/piperchat/server/server-controller-impl.ts @@ -59,7 +59,7 @@ export class ServerControllerImpl ): Promise { const params = request as GetServerParticipantsApi.Request.Params; return await this.get( - `/servers/${params.serverId}/participants` + `/servers/${params.serverId}/users` ); } @@ -68,7 +68,7 @@ export class ServerControllerImpl ): Promise { const params = request as JoinServerApi.Request.Params; return await this.post( - `/servers/${params.serverId}/participants` + `/servers/${params.serverId}/users` ); } @@ -77,7 +77,7 @@ export class ServerControllerImpl ): Promise { const params = request as LeaveServerApi.Request.Params; return await this.delete( - `/servers/${params.serverId}/participants` + `/servers/${params.serverId}/users` ); } @@ -87,7 +87,7 @@ export class ServerControllerImpl const params = request as KickUserFromServerApi.Request.Params; const body = request as KickUserFromServerApi.Request.Body; return await this.delete( - `/servers/${params.serverId}/participants/${params.username}`, + `/servers/${params.serverId}/users/${params.username}`, body ); }