GithubHelp home page GithubHelp logo

snamiki1212 / realworld-v1-rust-actix-web-diesel Goto Github PK

View Code? Open in Web Editor NEW
90.0 3.0 20.0 519 KB

RealWorld with Rust + ActixWeb + Diesel on Clean Architecture

License: MIT License

Rust 93.67% Shell 4.94% PLpgSQL 0.97% Dockerfile 0.42%
rust actix-web diesel realworld realworld-backend clean clean-architecture

realworld-v1-rust-actix-web-diesel's Introduction

header

badge

Overview

Realworld App using Rust, actix-web, and diesel.

Getting Started

# ready
$ sh ./scripts/copy-env.sh

# start
$ docker compose up -d

# healthcheck
$ curl http://localhost:8080/api/healthcheck
# => OK
# Check app can connect to DB
$ curl http://localhost:8080/api/tags
# => {"tags":[]}

# Check app can insert data into DB
curl -X POST http://localhost:8080/api/users -d '{"user": {"email": "[email protected]", "username": "a", "password": "a" }}' -H "Content-Type: application/json"

E2E Test

Running E2E tests using POSTMAN scripts on CI

# run e2e
$ APIURL=http://localhost:8080/api zsh e2e/run-api-tests.sh

Tech Stacks

  • Rust Edition 2021
  • ActixWeb 4.x
  • Diesel 2.x

Architecture

  • Clean Architecture
  • DI container using Constructor Injection with dynamic dispatch (src/utils/di.rs)
flowchart TD
    Client(("Client"))
    Route["Middleware + Route <br><br>/src/app/drivers/{middlewares, route}"]
    Controller["Controller<br><br>/src/app/features/[feature]/controllers.rs"]
    Presenter["Presenter<br><br>/src/app/features/[feature]/presenters.rs"]
    Usecase["Usecase<br><br>/src/app/features/[feature]/usecases.rs"]
    Repository["Repository<br><br>/src/app/features/[feature]/repositories.rs"]
    Entity["Entity<br><br>/src/app/features/[feature]/entities.rs"]
    DB[(Database)]

    %% Top to Bottom
    Client --Request--> Route
    Route --> Controller
    Controller --> Usecase
    Usecase --> Repository
    Repository --> Entity
    Entity --> DB

    %% Bottom to Top
    DB -.-> Entity
    Entity -.-> Repository
    Repository -.-> Usecase
    Usecase -.-> Presenter
    Presenter -.Response.-> Client
Loading

LICENSE

MIT

realworld-v1-rust-actix-web-diesel's People

Contributors

cole-maxwell1 avatar qiujiafei avatar snamiki1212 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

realworld-v1-rust-actix-web-diesel's Issues

Why do you give new token back?

Hi, thank you for sharing you code.
I have one question about token-based authentication.

Why do you give new token back, when does '/api/user' call?

I'm really happy to hear your choice.

build error

= note: ld: library 'pq' not found
clang: error: linker command failed with exit code 1 (use -v to see invocation)

local setup on windows not working "forcibly closed by the remote host"

I tryed to do the local setup on windows but it did not work. Here is what i did:

  1. start postgres db pg_ctl start
  2. copy .env sh .\scripts\copy-env.sh (it uses sh from git for windows)
  3. modify the .env and replace 0.0.0.0 and port with just localhost
  4. diesel setup
  5. cargo run

It did compile but at runtime it aborts.

PS C:\Users\<my-user>\Git\realworld-v1-rust-actix-web-diesel> cargo run
    Finished dev [unoptimized + debuginfo] target(s) in 0.60s
     Running `target\debug\conduit.exe`
start conduit server...
2023-08-11 13:23:58.922 CEST [23336] LOG:  could not receive data from client: An existing conn
ection was forcibly closed by the remote host.

2023-08-11 13:23:58.923 CEST [16500] LOG:  could not receive data from client: An existing conn
ection was forcibly closed by the remote host.

2023-08-11 13:23:58.925 CEST [17720] LOG:  could not receive data from client: An existing conn
ection was forcibly closed by the remote host.

2023-08-11 13:23:58.926 CEST [5600] LOG:  could not receive data from client: An existing conne
ction was forcibly closed by the remote host.

2023-08-11 13:23:58.931 CEST [16948] LOG:  could not receive data from client: An existing conn
ection was forcibly closed by the remote host.

2023-08-11 13:23:58.933 CEST [17096] LOG:  could not receive data from client: An existing conn
ection was forcibly closed by the remote host.

Can someone help me get this app running?

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.