Skip to content

CleanBread/axum_blog

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

axum_blog

A REST API blog backend built with Rust, Axum, and PostgreSQL. Supports posts, user authentication (JWT), and likes.

Stack

  • Axum — web framework
  • SQLx — async PostgreSQL driver with compile-time checked queries
  • Argon2 — password hashing
  • jsonwebtoken — JWT auth

Features

  • CRUD for blog posts
  • User registration and login
  • JWT-based authentication via cookie
  • Like/unlike posts
  • Soft delete for posts (deleted_at)
  • Request tracing with tower-http

Getting Started

Prerequisites: Rust, PostgreSQL, sqlx-cli, just

# Copy and fill in env vars
cp .env-example .env

# Run migrations
just migrate

# Start dev server
just dev

API

Method Path Auth Description
POST /auth/register Register a new user
POST /auth/login Login, sets JWT cookie
GET /posts List all posts
POST /posts required Create a post
GET /posts/:id Get a post
PUT /posts/:id required Update a post (owner only)
DELETE /posts/:id required Delete a post (owner only)
POST /posts/:id/like required Toggle like on a post

Development

just watch          # auto-reload on changes
just test           # run tests
just clippy         # lint
just fmt            # format
just migrate        # run pending migrations
just migrate-revert # revert last migration

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors