Backend Web API for 23prime-page.
$ docker-compose -f docker-compose.local.yml up
$ docker-compose -f docker-compose.local.yml up postgres
$ cargo run
(Recommend) If using cargo-watch:
$ cargo watch -x run
Some tests require DB connection, so you need up and migrate before testing.
$ docker-compose -f docker-compose.test.yml up -d --wait
$ export DATABASE_URL=postgres://admin:password@localhost:5442/GKBDB
$ cargo run --manifest-path ./migration/Cargo.toml up
$ cargo test --all -- --nocapture --test-threads=1
$ cargo fmt --all -- --check
$ cargo clippy --all-targets --all-features -- -D warnings -A clippy::needless_return
$ chmod +x check.sh
$ ./check.sh
$ aws ecr-public get-login-password --region us-east-1 | docker login --username AWS --password-stdin public.ecr.aws/m0z8x5y6
$ docker-compose build
$ docker push public.ecr.aws/m0z8x5y6/okkey-api:latest
Make .env
and add some variables. See .env.template
.
See:
- Setting Up Migration | SeaORM π An async & dynamic ORM for Rust
- Writing Migration | SeaORM π An async & dynamic ORM for Rust
- Running Migration | SeaORM π An async & dynamic ORM for Rust
- Seeding Data | SeaORM π An async & dynamic ORM for Rust
$ cd migration/
$ target/debug/migration generate <migration name>
Check status:
$ migration/target/debug/migration status
And run:
$ migration/target/debug/migration up
If use only Docker, you need not to install these tools, because there are already installed in Dockerfile-local
.
$ rustup component add rustfmt
$ rustup component add clippy
$ cargo install cargo-watch cargo-edit
Authorized with Authorization Code Flow by Auth0.
Access to My URL: https://23prime.xyz
Then, redirect to /auth/callback
and get access token:
{
id: "{your id}",
token: "{access token}"
}
You can send API request with the header Authorization: Bearer {access_token}
.
Method | Require Auth |
---|---|
GET | o |
- Response Body
Hello, Anime API!!
Method | Require Auth |
---|---|
GET | o |
POST | o |
- Response Body
{your request body}
- Response Body
{your request body}
Method | Require Auth |
---|---|
GET | o |
- Params
Param | Kind | Type | Required | remarks |
---|---|---|---|---|
year |
path | integer | false | |
season |
path | string | false | spring|summer|fall|winter |
- Response Body
{
"animes": [
{
"id": {id},
"year": {YYYY},
"season": "{spring|summer|fall|winter}",
"day": "{Sun|Mon|Tue|Wed|Thu|Fri|Sat}",
"time": "hh:mm",
"station": "{station}",
"title": "{title}",
"recommend": {true|false}
},
// and more...
]
}
- Params
Param | Kind | Type | Required | remarks |
---|---|---|---|---|
id |
body | integer | true | |
year |
body | integer | true | |
season |
body | string | true | |
day |
body | string | true | |
time |
body | string | true | |
station |
body | string | true | |
title |
body | string | true | |
recommend |
body | bool | true |
- Response Body
{
"animes": [
{
"id": {id},
"year": {YYYY},
"season": "{spring|summer|fall|winter}",
"day": "{Sun|Mon|Tue|Wed|Thu|Fri|Sat}",
"time": "hh:mm",
"station": "{station}",
"title": "{title}",
"recommend": {true|false}
},
// and more...
]
}
- Params
Param | Kind | Type | Required | remarks |
---|---|---|---|---|
id |
body | integer | true | |
year |
body | integer | true | |
season |
body | string | true | |
day |
body | string | true | |
time |
body | string | true | |
station |
body | string | true | |
title |
body | string | true | |
recommend |
body | bool | true |
- Response Body
{
"animes": [
{
"id": {id},
"year": {YYYY},
"season": "{spring|summer|fall|winter}",
"day": "{Sun|Mon|Tue|Wed|Thu|Fri|Sat}",
"time": "hh:mm",
"station": "{station}",
"title": "{title}",
"recommend": {true|false}
},
// and more...
]
}
- Params
Param | Kind | Type | Required | remarks |
---|---|---|---|---|
id |
body | integer | true | |
year |
body | integer | true | |
season |
body | string | true | |
day |
body | string | true | |
time |
body | string | true | |
station |
body | string | true | |
title |
body | string | true | |
recommend |
body | bool | true |
- Response Body
{
"animes": [
{
"id": {id},
"year": {YYYY},
"season": "{spring|summer|fall|winter}",
"day": "{Sun|Mon|Tue|Wed|Thu|Fri|Sat}",
"time": "hh:mm",
"station": "{station}",
"title": "{title}",
"recommend": {true|false}
},
// and more...
]
}
Method | Require Auth |
---|---|
GET | o |
- Params
Param | Kind | Type | Required | remarks |
---|---|---|---|---|
season |
path | string | true | spring|summer|fall|winter |
- Response Body
{
"animes": [
{
"title": "{title}",
"year": {current year (YYYY)},
"season": "{spring|summer|fall|winter}",
"wday": "{Sun|Mon|Tue|Wed|Thu|Fri|Sat}",
"time": "hh:mm",
"station": "{station}"
},
// and more...
]
}