Remove Canapi (#540)
* Remove Canapi It added more complexity than it helped. * Fail if there are many blog, but none was specified * cargo fmt
This commit is contained in:
+19
-7
@@ -1,12 +1,24 @@
|
||||
use canapi::Provider;
|
||||
use rocket_contrib::json::Json;
|
||||
use serde_json;
|
||||
|
||||
use plume_api::apps::AppEndpoint;
|
||||
use plume_models::{apps::App, db_conn::DbConn, Connection};
|
||||
use crate::api::Api;
|
||||
use plume_api::apps::NewAppData;
|
||||
use plume_common::utils::random_hex;
|
||||
use plume_models::{apps::*, db_conn::DbConn};
|
||||
|
||||
#[post("/apps", data = "<data>")]
|
||||
pub fn create(conn: DbConn, data: Json<AppEndpoint>) -> Json<serde_json::Value> {
|
||||
let post = <App as Provider<Connection>>::create(&*conn, (*data).clone()).ok();
|
||||
Json(json!(post))
|
||||
pub fn create(conn: DbConn, data: Json<NewAppData>) -> Api<App> {
|
||||
let client_id = random_hex();
|
||||
let client_secret = random_hex();
|
||||
let app = App::insert(
|
||||
&*conn,
|
||||
NewApp {
|
||||
name: data.name.clone(),
|
||||
client_id,
|
||||
client_secret,
|
||||
redirect_uri: data.redirect_uri.clone(),
|
||||
website: data.website.clone(),
|
||||
},
|
||||
)?;
|
||||
|
||||
Ok(Json(app))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user