mirror of
https://github.com/danbulant/Portfolio
synced 2026-06-16 21:11:06 +00:00
style: code cleanup
This commit is contained in:
parent
50abef29e3
commit
29ff462ef9
4 changed files with 10 additions and 13 deletions
|
|
@ -3,10 +3,10 @@ extern crate rocket;
|
|||
use rocket::{Rocket, Build};
|
||||
use rocket::serde::json::Json;
|
||||
use rocket::fairing::{self, AdHoc};
|
||||
use rocket::response::status::BadRequest;
|
||||
use portfolio_core::{Mutation, Query};
|
||||
use rocket::response::status::Custom;
|
||||
use portfolio_core::{Mutation};
|
||||
|
||||
use migration::MigratorTrait;
|
||||
use migration::{MigratorTrait};
|
||||
use sea_orm_rocket::{Connection, Database};
|
||||
|
||||
mod pool;
|
||||
|
|
@ -15,11 +15,11 @@ use pool::Db;
|
|||
pub use entity::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>")]
|
||||
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 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)
|
||||
.await
|
||||
.expect("could not insert post");
|
||||
.expect("Could not insert candidate");
|
||||
|
||||
Ok(plain_text_password)
|
||||
Ok(plain_text_password)
|
||||
}
|
||||
|
||||
#[get("/hello")]
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use ::entity::{candidate, candidate::Entity as Candidate};
|
||||
use ::entity::{candidate};
|
||||
use sea_orm::*;
|
||||
use crate::crypto::{self, hash_password};
|
||||
use crate::crypto::hash_password;
|
||||
|
||||
pub struct Mutation;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
//! SeaORM Entity. Generated by sea-orm-codegen 0.9.3
|
||||
|
||||
use sea_orm::entity::prelude::*;
|
||||
use rocket::serde::{self, Deserialize, Serialize};
|
||||
use rocket::serde::{Deserialize, Serialize};
|
||||
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)]
|
||||
|
|
|
|||
|
|
@ -1,6 +1,3 @@
|
|||
#[macro_use]
|
||||
extern crate rocket;
|
||||
|
||||
pub mod prelude;
|
||||
|
||||
pub mod admin;
|
||||
|
|
|
|||
Loading…
Reference in a new issue