Skip to content

About

Student project backend to a student social media platform.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

69 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 

Repository files navigation

Rust Rocket API (with Docker Compose)

This project runs a Rust Rocket web API inside Docker using Docker Compose.
You can execute cargo and diesel commands directly inside the container.


Requirements

  • Docker
  • Docker Compose

Running the Project

Build and start the containers: docker compose up -d --build

Run the application: docker compose exec app cargo run


Diesel Commands (Database Migrations)

Run migrations: docker compose exec app diesel migration run

Revert the last migration: docker compose exec app diesel migration revert


API ROUTES

Below is an overview of all available routes and their expected JSON bodies.


USER ROUTES GET /api/users → Get all users

GET /api/users/ → Get all users relative to the given user id

GET /api/user/ → Get a user by ID

PUT /api/users/update/ → Update user info (self or admin only) JSON body: { "username": "NewName", "email": "s7654321@student.hsleiden.nl", "follows_study": "CMD", "profile_image": "updated.jpg" }

DELETE /api/user/ → Delete a user


AUTH ROUTES POST /api/users/register → Register a new user JSON body: { "username": "John", "email": "s1234567@student.hsleiden.nl", this is the only valid email format "password": "secret123", "follows_study": "Informatica", "profile_image": "profile.jpg" }

POST /api/login → Log in a user JSON body: { "email": "s1234567@student.hsleiden.nl", "password": "secret123" }


POST ROUTES GET /api/posts → Get all posts

GET /api/post/ → Get a post by ID

GET /api/user_posts/ → Get all posts by a specific user

GET /api/friend_posts/ → Get all posts from a user’s friends

POST /api/post/create → Create a new post JSON body: { "tag_id": 1, "custom_user_id": 2, "text_content": "Hello world!", "image_content": "optional_image_url" }

PUT /api/post/update/ → Update a post (owner or admin only) JSON body: { "tag_id": 1, "text_content": "Updated text", "image_content": "updated_image.jpg" }

DELETE /api/post/ → Delete a post (owner or admin only)


POST COMMENT ROUTES GET /api/post_comments → Get all comments

GET /api/post_comment/ → Get a comment by ID

POST /api/post_comment/create → Create a new comment JSON body: { "post_id": 1, "custom_user_id": 2, "text_content": "Nice post!" }

PUT /api/post_comment/update/ → Update a comment JSON body: { "text_content": "Edited comment" }

DELETE /api/post_comment/ → Delete a comment


POST TAG ROUTES GET /api/post_tags → Get all post tags

GET /api/post_tag/ → Get a post tag by ID

THESE MUST BE PERFORMED BY AN ADMIN

POST /api/post_tag/create → Create a new post tag JSON body: { "name": "This is a tag name" }

PUT /api/post_tag/update/ → Update a post tag JSON body: { "name": "Updated Tag Name" }

DELETE /api/post_tag/ → Delete a post tag


USER FRIEND ROUTES GET /api/user_friends/<user_id> → Get all friends for a specific user

POST /api/user_friend/create → Send a friend request JSON body: { "custom_user_id": 1, "friend_id": 2, "friend_status": "Pending" }

PUT /api/user_friend/update/ → Update friendship status JSON body: { "friend_id": 2, to make clear which friend is being "Accepted" "friend_status": "Accepted" }

DELETE /api/user_friend/ → Remove a friendship the id you give here should be gotten from row_id


Notes

  • All routes under /api/ follow REST conventions.
  • Most POST and PUT routes require valid JSON bodies.
  • Authentication and caching mechanisms (via Redis) are integrated to improve performance.
  • Diesel ORM manages the PostgreSQL database migrations automatically when you run the container.

About

Student project backend to a student social media platform.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages