style: code cleanup

This commit is contained in:
Sebastian Pravda 2022-10-24 20:39:36 +02:00
parent 50abef29e3
commit 29ff462ef9
No known key found for this signature in database
GPG key ID: F3BC84F08EFA3F57
4 changed files with 10 additions and 13 deletions

View file

@ -3,10 +3,10 @@ extern crate rocket;
use rocket::{Rocket, Build}; use rocket::{Rocket, Build};
use rocket::serde::json::Json; use rocket::serde::json::Json;
use rocket::fairing::{self, AdHoc}; use rocket::fairing::{self, AdHoc};
use rocket::response::status::BadRequest; use rocket::response::status::Custom;
use portfolio_core::{Mutation, Query}; use portfolio_core::{Mutation};
use migration::MigratorTrait; use migration::{MigratorTrait};
use sea_orm_rocket::{Connection, Database}; use sea_orm_rocket::{Connection, Database};
mod pool; mod pool;
@ -15,11 +15,11 @@ use pool::Db;
pub use entity::candidate; pub use entity::candidate;
pub use entity::candidate::Entity as Candidate; pub use entity::candidate::Entity as Candidate;
use portfolio_core::crypto::{self, random_8_char_string}; use portfolio_core::crypto::random_8_char_string;
#[post("/", data = "<post_form>")] #[post("/", data = "<post_form>")]
async fn create(conn: Connection<'_, Db>, post_form: Json<candidate::Model>) -> Result<String, BadRequest<String>> { async fn create(conn: Connection<'_, Db>, post_form: Json<candidate::Model>) -> Result<String, Custom<String>> {
let db = conn.into_inner(); let db = conn.into_inner();
let form = post_form.into_inner(); let form = post_form.into_inner();
@ -27,9 +27,9 @@ async fn create(conn: Connection<'_, Db>, post_form: Json<candidate::Model>) ->
Mutation::create_candidate(db, form, &plain_text_password) Mutation::create_candidate(db, form, &plain_text_password)
.await .await
.expect("could not insert post"); .expect("Could not insert candidate");
Ok(plain_text_password) Ok(plain_text_password)
} }
#[get("/hello")] #[get("/hello")]

View file

@ -1,6 +1,6 @@
use ::entity::{candidate, candidate::Entity as Candidate}; use ::entity::{candidate};
use sea_orm::*; use sea_orm::*;
use crate::crypto::{self, hash_password}; use crate::crypto::hash_password;
pub struct Mutation; pub struct Mutation;

View file

@ -1,7 +1,7 @@
//! SeaORM Entity. Generated by sea-orm-codegen 0.9.3 //! SeaORM Entity. Generated by sea-orm-codegen 0.9.3
use sea_orm::entity::prelude::*; use sea_orm::entity::prelude::*;
use rocket::serde::{self, Deserialize, Serialize}; use rocket::serde::{Deserialize, Serialize};
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)] #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)]

View file

@ -1,6 +1,3 @@
#[macro_use]
extern crate rocket;
pub mod prelude; pub mod prelude;
pub mod admin; pub mod admin;