A REST API blog backend built with Rust, Axum, and PostgreSQL. Supports posts, user authentication (JWT), and likes.
- Axum — web framework
- SQLx — async PostgreSQL driver with compile-time checked queries
- Argon2 — password hashing
- jsonwebtoken — JWT auth
- 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
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| 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 |
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