Skip to content

Commit

Permalink
before esbuild refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
rubenfiszel committed Jan 3, 2025
1 parent a424edf commit 10b850a
Show file tree
Hide file tree
Showing 6 changed files with 102 additions and 1,943 deletions.
2 changes: 2 additions & 0 deletions backend/windmill-api/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12918,6 +12918,8 @@ components:
execution_mode:
type: string
enum: [viewer, publisher, anonymous]
raw_app:
type: boolean
required:
- id
- workspace_id
Expand Down
56 changes: 32 additions & 24 deletions backend/windmill-api/src/apps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ pub fn workspaced_service() -> Router {
.route("/get/draft/*path", get(get_app_w_draft))
.route("/secret_of/*path", get(get_secret_id))
.route("/get/v/*id", get(get_app_by_id))
.route("/get_data/v/*id", get(get_raw_app_data))
.route("/exists/*path", get(exists_app))
.route("/update/*path", post(update_app))
.route("/delete/*path", delete(delete_app))
Expand Down Expand Up @@ -372,36 +373,43 @@ async fn list_apps(
Ok(Json(rows))
}

async fn get_raw_app_data(Path((w_id, version_id)): Path<(String, i64)>) -> Result<Response> {
async fn get_raw_app_data(Path((w_id, version_id)): Path<(String, String)>) -> Result<Response> {
let file_path = format!("/home/rfiszel/wmill/{}/{}", w_id, version_id);
let file = tokio::fs::File::open(file_path).await?;
let stream = tokio_util::io::ReaderStream::new(file);
let res = Response::builder().header(http::header::CONTENT_TYPE, "text/javascript");
let res = Response::builder().header(
http::header::CONTENT_TYPE,
if version_id.ends_with(".css") {
"text/css"
} else {
"text/javascript"
},
);
Ok(res.body(Body::from_stream(stream)).unwrap())
}

async fn get_app_version(
authed: ApiAuthed,
Extension(user_db): Extension<UserDB>,
Path((w_id, path)): Path<(String, StripPath)>,
) -> JsonResult<i64> {
let path = path.to_path();
let mut tx = user_db.begin(&authed).await?;

let version_o = sqlx::query_scalar!(
"SELECT app.versions[array_upper(app.versions, 1)] as version FROM app
WHERE app.path = $1 AND app.workspace_id = $2",
path,
&w_id,
)
.fetch_optional(&mut *tx)
.await?
.flatten();
tx.commit().await?;

let version = not_found_if_none(version_o, "App", path)?;
Ok(Json(version))
}
// async fn get_app_version(
// authed: ApiAuthed,
// Extension(user_db): Extension<UserDB>,
// Path((w_id, path)): Path<(String, StripPath)>,
// ) -> JsonResult<i64> {
// let path = path.to_path();
// let mut tx = user_db.begin(&authed).await?;

// let version_o = sqlx::query_scalar!(
// "SELECT app.versions[array_upper(app.versions, 1)] as version FROM app
// WHERE app.path = $1 AND app.workspace_id = $2",
// path,
// &w_id,
// )
// .fetch_optional(&mut *tx)
// .await?
// .flatten();
// tx.commit().await?;

// let version = not_found_if_none(version_o, "App", path)?;
// Ok(Json(version))
// }

async fn get_app(
authed: ApiAuthed,
Expand Down
1 change: 0 additions & 1 deletion backend/windmill-api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ mod kafka_triggers_ee;
pub mod oauth2_ee;
mod oidc_ee;
mod raw_apps;
mod raw_apps_v2;
mod resources;
mod saml_ee;
mod schedule;
Expand Down
Loading

0 comments on commit 10b850a

Please sign in to comment.