Skip to content

Commit 5301406

Browse files
committed
feat: handled new rules
1 parent 275f6ea commit 5301406

File tree

3 files changed

+11
-28
lines changed

3 files changed

+11
-28
lines changed

adapter/rest/src/.env

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ PORT=8081
22
REDIS_URL=redis://localhost:6379
33
RABBITMQ_URL=amqp://localhost:5672
44
AQUILA_URL=http://localhost:8080
5-
IS_STATIC=true
5+
IS_STATIC=false

adapter/rest/src/queue/mod.rs

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ pub mod queue {
88
use std::{collections::HashMap, sync::Arc, time::Duration};
99
use tokio::sync::Mutex;
1010
use tucana::shared::{Struct, Value};
11-
use validator::{resolver::flow_resolver::resolve_flow, verify_flow};
11+
use validator::verify_flow;
1212

1313
use crate::store::store::check_flow_exists;
1414

@@ -88,31 +88,16 @@ pub mod queue {
8888
}
8989
}
9090
}
91-
// Determine which flow to use based on request body
92-
let flow_to_use = if let Some(body) = &request.body {
93-
// Verify flow
91+
92+
if let Some(body) = &request.body {
93+
// Verify the rules of a Flow - this is only possible if a body exists
9494
if let Err(err) = verify_flow(flow.clone(), body.clone()) {
9595
return Some(HttpResponse::bad_request(err.to_string(), HashMap::new()));
9696
}
97-
98-
// Resolve flow
99-
let mut resolvable_flow = flow.clone();
100-
match resolve_flow(&mut resolvable_flow, body.clone()) {
101-
Ok(resolved_flow) => resolved_flow,
102-
Err(_) => {
103-
return Some(HttpResponse::internal_server_error(
104-
"Internal Server Error".to_string(),
105-
HashMap::new(),
106-
))
107-
}
108-
}
109-
} else {
110-
// Use original flow if no body
111-
flow
112-
};
97+
}
11398

11499
// Serialize flow
115-
let json_flow = match serde_json::to_string(&flow_to_use) {
100+
let json_flow = match serde_json::to_string(&flow) {
116101
Ok(string) => string,
117102
Err(err) => {
118103
return Some(HttpResponse::internal_server_error(

crates/validator/src/lib.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
pub mod resolver;
21
mod rules;
32

43
use rules::{
@@ -40,7 +39,7 @@ pub fn verify_flow(flow: Flow, body: Value) -> Result<(), DataTypeRuleError> {
4039
}
4140

4241
//Verifies the rules on the datatype of the body thats given
43-
pub fn verify_data_type_rules(
42+
fn verify_data_type_rules(
4443
body: Value,
4544
data_type: DataType,
4645
availabe_data_types: &Vec<DataType>,
@@ -98,9 +97,8 @@ pub fn verify_data_type_rules(
9897
}
9998
};
10099
}
101-
_ => {
102-
todo!("Implement missing configs. (Question: should I skip input and return rule?)")
103-
}
100+
// Draco dont checks Node Rules (Input/Return Type Rules!)
101+
_ => continue,
104102
}
105103
}
106104

@@ -111,7 +109,7 @@ pub fn verify_data_type_rules(
111109
}
112110
}
113111

114-
pub fn get_data_type_by_id(data_types: &Vec<DataType>, str_id: &String) -> Option<DataType> {
112+
fn get_data_type_by_id(data_types: &Vec<DataType>, str_id: &String) -> Option<DataType> {
115113
let id = str_id.parse::<i32>().unwrap_or(1211);
116114

117115
data_types

0 commit comments

Comments
 (0)