- Install sqlite (sqlite3, libsqlite3-dev packages)
- Install gcc
- Install rust
- Install docker, docker compose (optional)
- If you want to use the test scripts, install curl
- Create file
secret.sql
in the root directory with the following contentINSERT INTO users VALUES (0, '{admin_user}', '{admin_display_name}', '{admin_desc}', '{admin_passwd_hash}', 1);
- Before the first deploy, create a file
SECRET
in the root directory, with its content being a base64 secret - Run
./scripts/deploy.sh
from the root directory - Docker: First
docker build -t backend .
and rundocker compose up
from the root directory
- Get: 200 (PostList) / 404 ("User not found")
- Note: Only from user {id}
- Get: 200 (Post) / 404 ("Post not found")
- Note: Post with id {id}
- Get: 200 (PostList) sorted by date
- Get: 200 (PostList) sorted by likes descending
- Get: 200 (PostList) sorted by likes ascending
- Get: 200 (PostList) sorted by (likes / age in minutes)
- Get: 200 (PostList)
Post {
post_id: i64
user_id: i64
date: i64
body: string (max 2048 chars)
likes: i64
user_name: string
display_name: string
pfp_image: string
}
PostList {
post_list: Vec<Post>
}
- Get: 200 (ProfileList)
Profile {
user_id: i64
user_name: String
display_name: String
description: String
pfp_image: String
}
ProfileList {
profile_list: Vec<Profile>
}
- Get: 200 (TagList) / 404 ("Post not found")
- Note: All tags of post {id}
TagList {
tag_list: Vec<string (max 64 chars)>
}
- Get: 200 (string) / 404 ("User not found")
- Note: Get username of user {id}
- Get: 200 (i64) / 404 ("User not found")
- Note: Get id of user {name}
- Get: 200 (Profile) / 404 ("User not found")
- Note: Get user profile
Profile {
user_id: i64
user_name: string (max 64 chars)
display_name: string (max 64 chars)
description: string (max 2048 chars)
}
- Get: 200 (LikeCount) / 404 ("Post not found")
- Note: Get the number of likes from post {id}
LikeCount {
like_count: i64
}
- Get: 200 (ImageList) / 404 ("Post not found")
- Note: Get a list of image names used to acces them via the call below
ImageList {
image_list: Vec<string (max 64 chars)>
}
- Get: Image
- Get: 200 (CommentList) / 404 ("Post not found")
- Note: Get a list of comments from post {id}
- Post:
PostCreateRequest {
body: string (max 2048 chars)
tags: Vec<string (max 64 chars)>
}
- With cookies
- Effect: Adds a post to the db
- Return: 201 ({post_id:i64}) / 401 ("Wrong token" / "User is banned") / 404 ("User not found")
- Headers: 'Content-Type: application/json' 'Content-Type: text/plain'
- Post:
CommentCreateRequest {
post_id: i64
body: string (max 2048 chars)
}
- With cookies
- Effect: Adds a comment to the post
- Return: 201 ({comment_id:i64}) / 401 ("Wrong token" / "User is banned") / 404 ("User not found" / "Post not found")
- Headers: 'Content-Type: application/json' 'Content-Type: text/plain'
- Post:
LikeRequest {
post_id: i64
}
- With cookies
- Effects: Adds like to a post
- Return: 200 ("Like added") / 406 ("Like already exists")
- Headers: 'Content-Type: application/json' 'Content-Type: text/plain'
- Post:
LoginRequest {
user_name: string (max 64 chars)
passwd: string (max 128 chars)
remember_password: bool
}
- Effect: Login ig
- Return: 200 (token) / 401 ("Password incorrect") / 404 ("User not found")
- Headers: 'Content-Type: application/json' 'Content-Type: text/plain'
- Post:
SignupRequest {
user_name: string (max 64 chars)
passwd: string (max 128 chars)
remember_password: bool
}
- Effect: Creates a user with given name and password
- Return: 201 (token) / 409 ("User already exists")
- Headers: 'Content-Type: application/json' 'Content-Type: text/plain'
- Post:
UserDeleteRequest {
user_id: i64
}
- With cookies
- Effect: Deletes a user
- Return: 200 ("User deleted") / 401 ("Wrong token") / 404 ("User not found")
- Headers: 'Content-Type: application/json' 'Content-Type: text/plain'
- Post:
UserUpgradeRequest {
user_id: i64
}
- With cookies
- Effect: User with given id becomes an admin
- Note: Token must belong to an admin
- Return: 200 ("Upgrade succesful") / 401 ("User is not admin" / "Wrong token") / 404 ("User not found")
- Headers: 'Content-Type: application/json' 'Content-Type: text/plain'
- Post:
UserBanRequest {
user_id: i64
ban_length: i64,
ban_message: string,
}
- With cookies
- Effect: User with given id is banned
- Note: Token must belong to an admin
- Return: 200 ("Ban succesful") / 401 ("User is not admin" / "Wrong token") / 404 ("User not found")
- Headers: 'Content-Type: application/json' 'Content-Type: text/plain'
- Post:
UserUnbanRequest {
user_id: i64,
}
- With cookies
- Effect: User with given id is unbanned
- Note: Token must belong to an admin
- Return: 200 ("Unban succesful") / 401 ("User is not admin" / "Wrong token") / 404 ("User not found")
- Headers: 'Content-Type: application/json' 'Content-Type: text/plain'
- Post:
DisplayNameChangeRequest {
new_display_name: string (max 64 chars)
}
- With cookies
- Effect: User's display name changes
- Return: 200 ("Change succesful") / 401 ("Wrong token") / 404 ("User not found")
- Headers: 'Content-Type: application/json' 'Content-Type: text/plain'
- Post:
UserNameChangeRequest {
new_user_name: string (max 64 chars)
}
- With cookies
- Effect: User's display name changes
- Return: 200 ("Change succesful") / 401 ("Wrong token") / 404 ("User not found")
- Headers: 'Content-Type: application/json' 'Content-Type: text/plain'
- Post:
DescriptionChangeRequest {
new_description: string (max 64 chars)
}
- With cookies
- Effect: User's description changes
- Return: 200 ("Change succesful") / 401 ("Wrong token") / 404 ("User not found")
- Headers: 'Content-Type: application/json' 'Content-Type: text/plain'
- Post: Image (max 25MB)
- With cookies
- Return: 200 (image-id) / 400 ("Invalid image format" / "File type error" / ) / 401 ("Wrong token") / 500 ("File read error")
- Headers: 'Content-Type: multipart/form-data', 'auth: {user_token}'
- Post:
AddImageToPostRequest {
image_id: i64,
post_id: i64
}
- With cookies
- Effect: Image is added to post
- Return: 200 ("Image added to post") / 400 ("Image already added to this post") / 401 ("Wrong token" / "User not authorized") / 404 ("Image not found" / "Post not found")
- Headers: 'Content-Type: application/json' 'Content-Type: text/plain'
- Post:
SetPFPRequest {
image_id: i64,
user_id: i64
}
- With cookies
- Effect: User's PFP is set to the image
- Post:
RemovePFPRequest {
user_id: i64
}
- With cookies
- Effect: User's PFP is deleted