GithubHelp home page GithubHelp logo

axum-cms's Introduction

axum-cms

A simple production-ready backend server template for Content Management Systems build with Rust and Axum.

Features

  • Authors (Authors of posts)
  • Posts (The actual content to be managed)

Information

  • Database used: Postgres
  • Cache used: Redis

Routes

  • POST /signup: Sign up with name, email, and password

  • POST /login: Login with email and password

  • GET /author: get all authors

  • GET /author/:id: Get specific author.

  • PATCH /author/:id: Edit specific author.

  • GET /post: Get all posts

  • GET /post/:id: Get specific post

  • PATCH /post/:id: Edit specific post

  • DELETE /post/:id: Delete specific post

Instructions

  1. Create a .env file in your local copy of the repository, and set the following env variables
    • PROD_DATABASE_URL: Your postgres database for production
    • DEV_DATABASE_URL: Your postgres database for development
    • JWT_SECRET: Your JWT secret
    • DEV_REDIS_CONN_URL: Your redis connection url for development, set to
    • PROD_REDIS_CONN_URL: Your redis connection url for production
    • MODE: Set as "production"(CASE SENSITIVE!) to enable production mode (setting this absent or as any other value will run the program in development mode)
    • DOCKER_IMAGE_NAME: The name of your docker image
  2. With all your environment variables set, start up your postgres dev server.
# Default config
# Start postgresql server docker image:
docker run --rm --name pg -p 5433:5433 \
   -e POSTGRES_PASSWORD=welcome \
   postgres:15

# (optional) To have a psql terminal on pg. 
# In another terminal (tab) run psql:
docker exec -it -u postgres pg psql

# (optional) For pg to print all sql statements.
# In psql command line started above.
ALTER DATABASE postgres SET log_statement = 'all';
  1. Run cargo run in your terminal to compile and run your project.
  2. To deploy to docker, run the deploy script with the command ./deploy.sh in the project directory

Notes

  • IMPORTANT!: If you decide to change DEV_DATABASE_URL, edit the following files accordingly:
    • sql\dev_initial\00-recreate-db.sql
    • src\_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 in src/models/error.rs in the Error enum. You may write custom responses for each error inside the impl IntoResponse block for the Error enum

axum-cms's People

Contributors

dreadedhippy avatar

Stargazers

Skgwd avatar Ifiok Jr. avatar Mazikï avatar mikione avatar Jeff avatar  avatar Burning ice avatar Jesse Zhu avatar Oghenovo Usiwoma avatar Mutalisk avatar Ezeoke Godswill avatar  avatar Eze Sunday avatar  avatar liangbaobin avatar iulx0 avatar  avatar  avatar hu avatar  avatar things avatar garvin wang avatar ranbo avatar Jamal Burgess avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.