A simple production-ready backend server template for Content Management Systems built with Rust using Axum.
!!! Go through the Critical Information 🚨🚨🚨 section below before getting started !!!
- Authors (Authors of posts)
- Posts (The actual content to be managed)
- EditSuggestion (Edits on posts suggested by self or other authors)
- Redis Caching (Discontinued, may be re-implemented in the future)
- WebSocket Draft Saves (Coming Soon, perhaps)
- Google sign-up/sign-in (Coming soon, perhaps)
- Refactored for even quicker development 🚀🚀🚀. Happy coding 💫
- Make sure to set the correct config information in the config file.
- For production, Make sure to comment out
_dev_utils::init_dev().await?in themain()function as this is for dev only. - For development, In all
.sqlfiles, individual database statements should end with;--#, failure to do this may break dev database initialization - If you have a field with a database enum, I advise avoiding
base's genericupdatemethod. This breaks with postgres at the moment, you would have to manually cast the enum fields to a database enum using sea_query. See theupdatemethod at edit.rs for a detailed example.
See here for the code implementation of all the routes
- POST
/signup: Sign up with name, email, and password - POST
/login: Login with email and password
- GET
/api/author: get all authors - GET
/api/author/:id: Get specific author.
- GET
/api/post: Get all posts - GET
/api/post/:id: Get specific post - PATCH
/api/post/:id: Update specific post - DELETE
/api/post/:id: Delete specific post
- GET
/api/edit: List edits by/for an author's posts - GET
/api/edit/incoming: List all incoming edits - GET
/api/edit/outgoing: List all outgoing edits - GET
/api/edit/:id: Get edit - PATCH
/api/edit/:id: Update edit - DELETE
/api/edit/:id: Delete edit - POST
/api/edit/accept/:idAccept edit - POST
/api/edit/reject/:idReject edit
You must have cargo-watch installed for these to work
# Run tests
cargo watch -q -c -x "test -- -- nocapture"
# Specific test with filter
cargo watch -q -c -x "test models::author::tests::test_create_ok"
# Run quick_dev exampl while developing
cargo watch -q -c -w examples/ -x "run --example quick_dev"
# Run any example while developing
cargo watch -q -c -w examples/ -x "run --example {FILE_NAME}"` # where `FILE_NAME` is the name of the file containing the test- IMPORTANT!: If you decide to change
DEV_DATABASE_URL, edit the following files accordingly:sql\dev_initial\00-recreate-db.sqlsrc\_dev_utils\dev_db.rs
- Use the "WithRejection<
CUSTOM_JSON_BODY, ApiError>" as Json body type in order to enable JSON extraction errors All errors can be found insrc/models/error.rsin theErrorenum. You may write custom responses for each error inside theimpl IntoResponseblock for theErrorenum- All fixtures are prefixed with 'fx'
- An e2e example is given in the
/examplesfolder - Run the example with the command:
cargo run --example {FILE_NAME}, whereFILE_NAMEis the name of the file containing the example, in this case,quick_dev - With
cargo watchinstalled, you can automatically re-run the example on each file save with the command:cargo watch -q -c -w examples/ -x "run --example {FILE_NAME}"instead.