git clone https://github.com/WhySoBad/tria-backend.git
cd tria-backend
npm install
npm run start:dev
API is available on localhost at port 443
npm run start
API is available on localhost at port 443
Endpoint to validate an user auth token
Authorization header required
GET /auth/validate
Boolean whether the token is valid or not
400 No Token Provided
Endpoint to log an user in using its credentials
POST /auth/login
{
username: string,
password: string,
}
User auth token as string
404 User Not Found
400 Invalid Credentials
Endpoint to create a new private chat with another user
Authorization header required
POST /chat/create/private
{
user: string,
}
Chat uuid as string
404 User Not Found
404 Participant Not Found
400 Private Chat Already Exists
Endpoint to create a new group chat
Authorization header required
POST /chat/create/group
{
name: string,
tag: string,
type: ChatType,
description: string,
members: Array<{ uuid: string; role: GroupRole; }>,
}
Chat uuid as string
404 User Not Found
400 Group Tag Has To Be Unique
Endpoint to check whether a given group tag does already exist
GET /chat/check/tag/[tag]
Boolean whether the tag already exists or not
Endpoint to join an existing group
Authorization header required
POST /chat/[uuid]/join
Void
404 Group Not Found
400 Chat Has To Be Group
403 User Is Banned
400 User Is Already Joined
404 User Not Found
Endpoint to leave an existing group
Authorization header required
POST /chat/[uuid]/leave
Void
404 Group Not Found
400 Chat Has To Be Group
404 User Not Found
400 Owner Can't Leave The Group
Endpoint to delete an existing chat
Authorization header required
DELETE /chat/[uuid]/delete
Void
404 Chat Not Found
404 User Not Found
401 Only Owner Can Delete A Group
Endpoint to ban a member in a group
Admin role with ban permission or owner role required
Authorization header required
POST /chat/[uuid]/admin/ban
{
uuid: string,
}
Void
404 Chat Not Found
400 Chat Has To Be Group
400 User Is Already Banned
404 User Not Found
401 Owner Can't Be Banned
Endpoint to unban a banned member in a group
Admin role with unban permission or owner role required
Authorization header required
POST /chat/[uuid]/admin/unban
{
uuid: string,
}
Void
404 Chat Not Found
400 Chat Has To Be Group
404 User Isn't Banned
404 User Not Found
Endpoint to kick a member in a group
Admin role with kick permission or owner role required
Authorization header required
POST /chat/[uuid]/admin/kick
{
uuid: string,
}
Void
404 Chat Not Found
400 Chat Has To Be Group
404 User Not Found
401 Owner Can't Be Kicked
Endpoint to get a preview of a chat
GET /chat/[uuid]/preview
{
uuid: string,
type: ChatType,
description: string,
name: string,
tag: string,
size: number,
online: number,
avatar: string | null,
}
404 Chat Not Found
400 Can't Get Preview Of Private Group
400 Can't Get Preview Of Private Chat
Endpoint to get a specific amount of messages older than a given timestamp
User has to be a member of the chat
Authorization header required
GET /chat/[uuid]/messages/get/[timestamp]/[amount]
{
messages: Array<{
uuid: string,
sender: string,
chat: string,
createdAt: Date,
editedAt: Date | null,
edited: number,
text: string,
}>,
log: Array<{
user: string,
chat: string,
timestamp: Date,
joined: boolean,
}>,
last: boolean,
}
404 Chat Not Found
Endpoint to mark messages after a given timestamp as read
User has to be a member of the chat
Authorization header required
GET /chat/[uuid]/messages/read/[timestamp]
Void
400 Timestamp Can't Be In The Future
404 User Not Found
400 User Has Already Read Further
Endpoint to get all informations about a chat
User has to be a member of the chat
Authorization header required
GET /chat/[uuid]
{
uuid: string,
type: ChatType,
name: string | null,
tag: string | null,
description: string | null,
createdAt: Date,
lastRead: Date,
members: Array<{
joinedAt: Date,
role: GroupRole,
user: {
uuid: string,
createdAt: Date,
lastSeen: Date,
name: string,
tag: string,
description: string,
avatar: string | null,
locale: Locale,
online: boolean,
},
promotedAt: Date, //only when member is admin
permissions: Array<Permission>, //only when member is admin
}>,
messages: Array<{
uuid: string,
sender: string,
chat: string,
createdAt: Date,
editedAt: Date | null,
edited: number,
text: string,
}>,
banned: Array<{
bannedAt: Date,
user: {
uuid: string,
createdAt: Date,
name: string,
tag: string,
description: string,
avatar: string | null,
},
}>,
memberLog: Array<{
user: string,
chat: string,
timestamp: Date,
joined: boolean,
}>,
}
404 Chat Not Found
Endpoint to get the avatar of a group
GET /chat/[uuid]/avatar
The avatar of the chat as a .jpeg file
404 Avatar Not Found
Endpoint to upload an avatar for a group
Admin role with chat edit permission or owner role required
Authorization header required
POST /chat/[uuid]/avatar/upload
FormData with the name "avatar" and an avatar image in the .jpeg format
Void
400 Maximum File Size Is 100'000 Bytes
400 File Has To Be Of Type JPEG
400 Invalid File
404 Chat Not Found
Endpoint to delete an avatar of a group
Admin role with chat edit permission or owner role required
Authorization header required
DELETE /chat/[uuid]/avatar/delete
Void
404 Chat Not Found
400 Chat Has To Be Of Type Group
404 User Not Found
404 Avatar Not Found
Endpoint to search new groups and user
Authorization header required
POST /search
{
text: string,
checkUser?: boolean,
checkChat?: boolean,
checkUuid?: boolean,
checkTag?: boolean,
checkName?: boolean,
}
Array with UserPreview and ChatPreview objects
404 User Not Found
Endpoint to register a new user
POST /user/register
{
mail: string,
password: string,
}
Void
400 Mail Has To Be Unique
Endpoint to validate whether a register token is valid or not
GET /user/register/validate/[token]
Boolean whether the token is valid or not
Endpoint to finish the registration of an user
POST /user/register/verify
{
token: string,
name: string,
tag: string,
description: string,
locale: Locale,
}
Void
400 Invalid Registration Token
404 User Not Found
400 Tag Has To Be Unique
Endpoint to check whether a tag does already exist
GET /user/check/tag/[tag]
Boolean whether the tag does already exist or not
Endpoint to check whether a mail is already used
GET /user/check/mail/[mail]
Boolean whether the mail is already used or not
Endpoint to edit an user
Authorization header required
PUT /user/edit
{
name?: string,
tag?: string,
description?: string,
locale?: Locale,
}
Void
404 User Not Found
400 Tag Has To Be Unique
Endpoint to change the password using the old password
Authorization header required
PUT /user/password/change
{
old: string,
new: string,
}
Void
404 User Not Found
400 Invalid Password
Endpoint to request a mail to reset the password
POST /user/password/reset
{
mail: string,
}
Void
404 Mail Not Found
503 Failed To Send Mail
Endpoint to validate whether a password reset token is valid
GET /user/password/reset/validate/[token]
Boolean whether a password reset token is valid or not
Endpoint to confirm a password reset and to set a new password
POST /user/password/reset/confirm
{
token: string,
password: string,
}
Void
400 Invalid Reset Token
404 User Not Found
Endpoint to delete an user
Authorization header required
DELETE /user/delete
Void
404 User Not Found
Endpoint to get all information about an user
Authorization header required
GET /user/current
{
uuid: string,
name: string,
tag: string,
avatar: string | null,
description: string,
mail: string,
locale: Locale,
online: boolean,
createdAt: Date,
lastSeen: Date,
chats: Array<string>,
}
404 User Not Found
Endpoint to get a preview of an user
GET /user/[uuid]
{
uuid: string,
name: string,
tag: string,
avatar: string | null,
description: string,
}
404 User Not Found
Endpoint to get the avatar of an user
GET /user/[uuid]/avatar
The avatar of the chat as a .jpeg file
404 Avatar Not Found
Endpoint to upload an avatar for an user
Authorization header required
POST /user/avatar/upload
FormData with the name "avatar" and an avatar image in the .jpeg format
Void
400 Maximum File Size Is 100'000 Bytes
400 File Has To Be Of Type JPEG
400 Invalid File
404 User Not Found
Endpoint to delete an avatar of an user
Authorization header required
DELETE /user/avatar/delete
Void
404 User Not Found
404 Avatar Not Found
AGPL © WhySoBad