Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/0h-n0/mytodo
https://github.com/0h-n0/mytodo
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/0h-n0/mytodo
- Owner: 0h-n0
- Created: 2024-01-06T13:57:04.000Z (about 1 year ago)
- Default Branch: master
- Last Pushed: 2024-01-06T14:00:38.000Z (about 1 year ago)
- Last Synced: 2024-11-09T09:49:20.116Z (3 months ago)
- Language: Rust
- Size: 353 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# MyTODO
* (WIP) frontend/React
* (DONE) backend/Rust(Axum)
* Sea-Orm
* (DONE) database/PostgreSQL
* (WIP) cloud/terraform
* AWS## Prerequisites
* [rust](https://www.rust-lang.org/tools/install)
* [nodejs](https://nodejs.org/en/download/)
* [docker](https://docs.docker.com/engine/install/)
* [docker-compose](https://docs.docker.com/compose/install/)
* [terraform](https://www.terraform.io/)## Backend API
see `openapi.yaml`
## table schema
```sql
$ cargo install sea-orm-cli
```## Setup
### Database
```bash
$ docker-compose up -d
``````bash
$ sudo apt install postgresql-client
$ psql -h localhost -p 5432 -U postgres
``````sql
$ create database todo;
``````bash
$ cd backend
$ cargo install sea-orm-cli
$ sea-orm-cli migrate init
```#### execute migration
```bash
$ sea-orm-cli migrate refresh
```#### generate entity
```bash
$ sea-orm-cli generate entity -u ${DATABASE_URL} -o entity/src
```### start Backend
```bash
$ cd backend
$ cargo run
```### Note
```shell
backend/entity/src/
├── lib.rs
├── mod.rs
├── prelude.rs
└── todo.rs ## <---
``````rust
// todo.rs
// add Serialize Derive, because of the error
// * https://zenn.dev/hitochan777/scraps/13e8c8af011c7d
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize)]
#[sea_orm(table_name = "todo")]
pub struct Model {
#[sea_orm(primary_key)]
pub id: i32,
pub text: String,
pub completed: bool,
}
```## Reference
* Backend
* https://github.com/tokio-rs/axum/blob/main/examples/todos/src/main.rs
* Sea-Orm
* https://github.com/SeaQL/sea-orm/tree/master/examples/axum_example