-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
370 additions
and
65 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
[package] | ||
name = "api" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] | ||
axum = "0.7.5" | ||
dotenv.workspace = true | ||
serde = { workspace = true, features = ["derive"] } | ||
serde_json = "1.0.117" | ||
tokio = { workspace = true, features = ["full"] } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
use axum::{http::StatusCode, response::IntoResponse, routing::{delete, get, post, put}, Router}; | ||
|
||
pub fn router() -> Router { | ||
Router::new() | ||
.route("/", get(list)) | ||
.route("/", post(update_event)) | ||
.route("/:event_id/", get(show_event)) | ||
.route("/:event_id/", delete(delete_event)) | ||
.route("/:event_id/", post(update_event)) | ||
.route("/:event_id/meals/", put(meal_add)) | ||
.route("/:event_id/meals/", delete(meal_delete)) | ||
.route("/:event_id/meals/", post(meal_update)) | ||
} | ||
|
||
async fn list() -> impl IntoResponse { | ||
StatusCode::OK | ||
} | ||
|
||
async fn show_event() -> impl IntoResponse { | ||
StatusCode::OK | ||
} | ||
|
||
async fn delete_event() -> impl IntoResponse { | ||
StatusCode::OK | ||
} | ||
|
||
async fn update_event() -> impl IntoResponse { | ||
StatusCode::OK | ||
} | ||
|
||
async fn meal_add() -> impl IntoResponse { | ||
StatusCode::OK | ||
} | ||
|
||
async fn meal_delete() -> impl IntoResponse { | ||
StatusCode::OK | ||
} | ||
|
||
async fn meal_update() -> impl IntoResponse { | ||
StatusCode::OK | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
use axum::{http::StatusCode, response::IntoResponse, routing::{delete, get, post, put}, Router}; | ||
|
||
pub fn router() -> Router { | ||
Router::new() | ||
.route("/", get(list)) | ||
.route("/", put(add)) | ||
.route("/:ingredient_id/", get(show_ingredient)) | ||
.route("/:ingredient_id/", delete(delete_ingredient)) | ||
.route("/:ingredient_id/", post(show_ingredient)) | ||
} | ||
|
||
async fn add() -> impl IntoResponse { | ||
StatusCode::OK | ||
} | ||
|
||
async fn list() -> impl IntoResponse { | ||
StatusCode::OK | ||
} | ||
|
||
async fn show_ingredient() -> impl IntoResponse { | ||
StatusCode::OK | ||
} | ||
|
||
async fn delete_ingredient() -> impl IntoResponse { | ||
StatusCode::OK | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
use axum::Router; | ||
use tokio::net::TcpListener; | ||
|
||
mod events; | ||
mod ingredients; | ||
mod places; | ||
mod reciepes; | ||
|
||
#[tokio::main] | ||
async fn main() { | ||
let app = Router::new() | ||
.nest("/events", events::router()) | ||
.nest("/ingredients", ingredients::router()) | ||
.nest("/places", places::router()) | ||
.nest("/reciepes", reciepes::router()); | ||
|
||
println!("Server started successfully at 0.0.0.0:8080"); | ||
|
||
let listener = TcpListener::bind("0.0.0.0:8080").await.unwrap(); | ||
axum::serve(listener, app.into_make_service()) | ||
.await | ||
.unwrap(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
use axum::{http::StatusCode, response::IntoResponse, routing::{delete, get, post, put}, Router}; | ||
|
||
pub fn router() -> Router { | ||
Router::new() | ||
.route("/", get(list_places)) | ||
.route("/", put(add_places)) | ||
.route("/:place_id", get(get_place)) | ||
.route("/:place_id", post(update_place)) | ||
.route("/:place_id", delete(delete_place)) | ||
} | ||
|
||
async fn list_places() -> impl IntoResponse { | ||
StatusCode::OK | ||
} | ||
|
||
async fn add_places() -> impl IntoResponse { | ||
StatusCode::OK | ||
} | ||
|
||
async fn get_place() -> impl IntoResponse { | ||
StatusCode::OK | ||
} | ||
|
||
async fn update_place() -> impl IntoResponse { | ||
StatusCode::OK | ||
} | ||
|
||
async fn delete_place() -> impl IntoResponse { | ||
StatusCode::OK | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
use axum::{http::StatusCode, response::IntoResponse, routing::{delete, get, post, put}, Router}; | ||
|
||
pub fn router() -> Router { | ||
Router::new() | ||
.route("/", get(list_reciepes)) | ||
.route("/", put(add_reciepe)) | ||
.route("/:recipe_id/", get(calc_reciepe)) | ||
.route("/:recipe_id/", post(update_reciepe)) | ||
.route("/:recipe_id/", delete(update_reciepe)) | ||
.route("/:recipe_id/steps/", get(update_reciepe)) | ||
.route("/:recipe_id/steps/", post(update_reciepe)) | ||
.route("/:recipe_id/ingredients/", get(calc_reciepe)) | ||
.route("/:recipe_id/ingredients/", post(calc_reciepe)) | ||
} | ||
|
||
async fn list_reciepes() -> impl IntoResponse { | ||
StatusCode::OK | ||
} | ||
|
||
async fn add_reciepe() -> impl IntoResponse { | ||
StatusCode::OK | ||
} | ||
|
||
async fn calc_reciepe() -> impl IntoResponse { | ||
StatusCode::OK | ||
} | ||
|
||
async fn update_reciepe() -> impl IntoResponse { | ||
StatusCode::OK | ||
} |