{"id":24656611,"url":"https://github.com/harrisdeperceptron/rext-rust-web-framework","last_synced_at":"2025-03-21T03:13:47.987Z","repository":{"id":196112298,"uuid":"690787369","full_name":"HarrisDePerceptron/Rext-rust-web-framework","owner":"HarrisDePerceptron","description":"Rext is an opinionated framework design to follow best practices for designing and writing backend business logic in Rust","archived":false,"fork":false,"pushed_at":"2023-11-09T20:27:03.000Z","size":132,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-21T03:13:37.294Z","etag":null,"topics":["axum","framework","rust","rust-lang"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/HarrisDePerceptron.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-09-12T22:02:45.000Z","updated_at":"2023-11-13T02:05:30.000Z","dependencies_parsed_at":"2023-09-27T02:13:01.824Z","dependency_job_id":"c09f97c1-34a2-4a6e-8118-e1c903316677","html_url":"https://github.com/HarrisDePerceptron/Rext-rust-web-framework","commit_stats":null,"previous_names":["harrisdeperceptron/rust-axum-template","harrisdeperceptron/rext-rust-web-framework"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HarrisDePerceptron%2FRext-rust-web-framework","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HarrisDePerceptron%2FRext-rust-web-framework/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HarrisDePerceptron%2FRext-rust-web-framework/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HarrisDePerceptron%2FRext-rust-web-framework/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/HarrisDePerceptron","download_url":"https://codeload.github.com/HarrisDePerceptron/Rext-rust-web-framework/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244728235,"owners_count":20500023,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["axum","framework","rust","rust-lang"],"created_at":"2025-01-25T23:38:11.059Z","updated_at":"2025-03-21T03:13:47.973Z","avatar_url":"https://github.com/HarrisDePerceptron.png","language":"Rust","readme":"\n## Rext: Rust Axum Web Framework\n\nRext is an opinionated framework design to follow best practices for designing and writing backend business logic in Rust :crab:\n\n### Features\n- File structure and organization\n- Tokio as the async provider\n- Axum as the api web framework\n- Ready to use WebSockets\n- Websockets design to work with rooms (join, leave, message)\n- Mongo data access layer included\n- Redis Adapter for working with redis async commands\n- Stateful horizontal scaling of Websockets\n\n### Getting Started\n\nFire away 🚀\n\n```\n$ cargo run\n```\n\n### Writing Apis\n\n**Model**\n\n```\n\n#[derive(Debug, Clone, Serialize, Deserialize)]\npub struct User {\n    email: String,\n    password: String,\n}\n\nimpl User {\n// model methods\n}\n\n```\n\n**Data Access layer**\n\n\n`app/user/user_dao.rs`\n```\npub struct UserDao {\n    fac: Arc\u003cApplicationFactory\u003e,\n    collection_name: String,\n}\n\nimpl DaoObj\u003cUser\u003e for UserDao {\nfn get_factory(\u0026self) -\u003e Arc\u003cApplicationFactory\u003e {\n        self.fac.clone()\n    }\n\nfn get_collection_name(\u0026self) -\u003e \u0026str {\n        \u0026self.collection_name\n    }\n}\n```\n\n**Service**\n\n`app/user/user_service.rs`\n```\npub struct UserService {\n    dao: Arc\u003cUserDao\u003e,\n}\n\nimpl Service\u003cUser\u003e for UserService {\n    fn get_dao(\u0026self) -\u003e Arc\u003cdyn DaoObj\u003cUser\u003e\u003e {\n        self.dao.clone()\n    }\n}\n\nimpl UserService {\n// extending service methods\n}\n\n\n```\n\n**Routes**\n\n`app/user/user_routes.rs`\n\n\n```\npub fn user_routes() -\u003e Router\u003cArc\u003cServerState\u003e\u003e {\n    Router::new()\n        .route(\"/\", post(user_create))\n        .route(\"/\", get(list_user))\n        .route(\"/:user_id\", get(get_user))\n        .route(\"/users/login\", post(user_login))\n}\n```\n\n\n**Registering Routes**\n\n`server.rs`\n\n```\npub async fn server(...) -\u003e ... {\n// code \n\nlet app = Router::new()\n    ...\n    .nest(\"/user\", user::user_routes::user_routes())\n    ...;\n}\n```\n\n### WebSockets\n\nWebsockets are setup-ed out of the box. Extend websocket functionality by extending the commands\n\n`websocket/messages.rs`\n```\npub struct RoomMessage {\n    pub message: String,\n    pub room: String,\n}\n\npub enum Command {\n    ...\n    NewCommand(String)\n}\n\n```\n```\npub async fn parse_text_messages(...) -\u003e ... {\n    // code\n    match command {\n        ...,\n        Command::NewCommand(v) =\u003e {\n\n        },\n        ...\n    }\n\n```\n\n**Authentication**\n\nWebsocket auth is implemented through the authorization header \nwhich accepts a bearer token and decodes the token for user id represented by the `sub` payload field\n\n\n\n### Secrets\nAdd your secrets to the  `secrets.rs`\n\n```\npub static REDIS_URI: Lazy\u003cString\u003e =\n    Lazy::new(|| env::var(\"REDIS_URI\").expect(\"REDIS_URI not found\"));\n\n```\n\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fharrisdeperceptron%2Frext-rust-web-framework","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fharrisdeperceptron%2Frext-rust-web-framework","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fharrisdeperceptron%2Frext-rust-web-framework/lists"}