Skip to content

Commit

Permalink
get envs
Browse files Browse the repository at this point in the history
  • Loading branch information
Alw3ys committed Dec 15, 2023
1 parent 820ea76 commit 90a43b2
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
3 changes: 2 additions & 1 deletion dosei/src/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ pub struct CronJob {
pub struct Secret {
pub uuid: Uuid,
pub name: String,
pub value: Vec<u8>,
// This should be u8, figute out how postgres does it
pub value: Vec<i32>,
pub owner_id: Uuid,
pub project_id: Uuid,
pub updated_at: DateTime<Utc>,
Expand Down
1 change: 1 addition & 0 deletions dosei/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ pub async fn start_server(config: &'static Config) -> anyhow::Result<()> {
cron::start_job_manager(config, Arc::clone(&shared_pool));
let app = Router::new()
.route("/envs", routing::post(secret::api_set_envs))
.route("/envs", routing::get(secret::api_get_envs))
.route("/cron-jobs", routing::post(cron::api_create_job))
.route("/cron-jobs", routing::get(cron::api_get_cron_jobs))
.layer(Extension(Arc::clone(&shared_pool)));
Expand Down
9 changes: 9 additions & 0 deletions dosei/src/server/secret.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@ use serde::Deserialize;
use sqlx::{Pool, Postgres};
use std::collections::HashMap;
use std::sync::Arc;
use crate::schema::{Secret};

pub async fn api_get_envs(pool: Extension<Arc<Pool<Postgres>>>) -> Json<Vec<Secret>> {
let recs = sqlx::query_as!(Secret, "SELECT * from envs")
.fetch_all(&**pool)
.await
.unwrap();
Json(recs)
}

pub async fn api_set_envs(
pool: Extension<Arc<Pool<Postgres>>>,
Expand Down

0 comments on commit 90a43b2

Please sign in to comment.