Code Monkey home page Code Monkey logo

rust-api-sample's Introduction

rust-api-sample

動かす

cp .env.sample .env

cd infrastructure/docker

docker-compose up -d

docker-compose exec rust-actix-web bash

cargo run

動いてるか確認

// dockerでなくlocalで実行
curl localhost:9999/health

migration

diesel migration generate create_design

diesel migration run

diesel migration redo

structure

domain
=> API上でのデータ定義をし、そのデータを完全に扱う。

controller
=> サービスを実行し、受け取ったドメインをレスポンスへ渡す。

service
=> repositoryを通してドメインを取得し、整形する。今回は使ってない。

repository
=> DBの操作を行い、ドメインを返す。

response
=> 「controllerから受け取ったドメイン」からAPIレスポンスを生成する。

request
=> APIへのリクエストパラメータを管理する。

driver
=> API外部との接続をする。

model
=> ORMのためのテーブル定義を管理。

usecase
=> 依存性の逆転をする。今回は使ってない。

tests
=> 単体テストする。

infrastructure
=> 環境依存のものを管理。

e2e
=> end to endテストを行う。型あり言語でなくpythonで記述。

やってないこと

・usecase層で、依存性逆転(DIP)はやっていない。
・service層も、今回は必要なかったのでやってない。
・DIもやっていない。

rust-api-sample's People

Contributors

bokotomo 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.