fix: function data pass; (#80)

This commit is contained in:
stefan-gorules
2023-08-30 15:39:09 +02:00
committed by GitHub
parent d3d3bd44cd
commit ca568bcb4c
2 changed files with 8 additions and 4 deletions
+7 -3
View File
@@ -1,12 +1,13 @@
use anyhow::{anyhow, Context};
use std::fmt::Debug;
use std::thread;
use std::time::Duration;
use crate::handler::function::vm::BASE_VM;
use anyhow::{anyhow, Context};
use serde::{Deserialize, Serialize};
use serde_json::Value;
use crate::handler::function::vm::BASE_VM;
#[derive(Debug, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct EvaluateResponse {
@@ -90,6 +91,9 @@ impl Script {
return Err(anyhow!(exception.to_rust_string_lossy(tc_scope)));
};
serde_v8::from_v8(tc_scope, result).context("Failed to parse function result")
let result_string: String =
serde_v8::from_v8(tc_scope, result).context("Failed to parse function result")?;
serde_json::from_str(result_string.as_str()).context("Failed to parse function result")
}
}
@@ -16,7 +16,7 @@ const console = {
}
};
const main = (input) => ({
const main = (input) => JSON.stringify({
output: handler(input, {moment: __GLOBAL__DAYJS, dayjs: __GLOBAL__DAYJS, Big: Big, env: __GLOBAL__ENV}),
log,
});