Skip to content

mohamed-said/blog-rust

Repository files navigation

Hi there, this is a toy project to experiment building a simple blog CRUD application with Rust, Axum and MongoDB. This project provides a simple API for adding users and articles, and view/read all the articles as well The goal of this project is completely educational, feel free to use it however you want.

🚨 It's still a work in progress. 🤓 💻

Image 1 Image 2

I recommend using docker and docker compose to try the project, but feel free to use the other method as well.

Feature List

  • ✅ Add Article
  • ✅ Add User
  • ✅ View Articles
  • ⏳ Delete Article
  • ⏳ Authentication

Usage

Docker

You need to have docker and docker comopse installed.

Without Docker

You need to have rust and MongoDB installed.

  • Run the following command to install Rust:

    curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

NOTE: If you find the command sketchy, please head to the official website and check for yourself 😏

  • Install MongoDB (Community Edition) Official Documentation
  • Check that the mongodb server is running locally, for example, on Mac OS run:

    brew services list | grep mongodb

  • If the server is in the started status then everything should be fine.

NOTE: Check the docs for linux and windows.

  • Head to the project directory and run the web server

    cargo run

Examples

Add an article using curl

curl -X POST -H "Content-Type: application/json" -d '{
    "title": "Title goes here", \
    "body": "article body goes here" \
}' http://localhost:3000/api/article`

View all existing articles

curl http://localhost:3000/api/list

About

Simple blog backend with Rust, Axum and MongoDB. Ready to use in a Docker environment.

Resources

Stars

Watchers

Forks