@joystick.js/node-canary 0.0.0-canary.388 → 0.0.0-canary.389
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import g from"./format_api_error.js";import y from"./get.js";import h from"./get_api_context.js";import w from"./get_api_url_component.js";import v from"./handle_api_error.js";import _ from"../../lib/is_valid_json.js";import x from"../../lib/types.js";import J from"./validate_session.js";const N=(d={},n=[],m={},u={})=>{for(let r=0;r<n?.length;r+=1){const[s,i]=n[r];d.get(`/api/_getters/${w(s)}`,...x.is_array(i?.middleware)?i?.middleware:[],async(e={},t={})=>{if(process.databases?._sessions&&!await J(e,t))return t.status(403).send(JSON.stringify({errors:[g(new Error("Unauthorized request."))]}));const c=await h(e,t,m),a=decodeURIComponent(e?.query?.input),f=_(a)?JSON.parse(a):null,p=decodeURIComponent(e?.query?.output),l=_(p)?JSON.parse(p):null;y({get_name:s,get_options:{input:f,output:l},getter_definition:i,request_context:c,api_schema_options:u}).then(o=>t.status(200).send(JSON.stringify(o))).catch(o=>{v(`api.getters.${s}`,o,t)})})}};var j=N;export{j as default};
|
package/package.json
CHANGED
|
@@ -27,11 +27,12 @@ const register_getters = (express_app = {}, getter_definitions = [], api_context
|
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
const context = await get_api_context(req, res, api_context);
|
|
30
|
-
|
|
31
|
-
const
|
|
30
|
+
|
|
31
|
+
const decoded_input = decodeURIComponent(req?.query?.input);
|
|
32
|
+
const input = is_valid_json(decoded_input) ? JSON.parse(decoded_input) : null;
|
|
32
33
|
|
|
33
|
-
|
|
34
|
-
const output = is_valid_json(
|
|
34
|
+
const decoded_output = decodeURIComponent(req?.query?.output);
|
|
35
|
+
const output = is_valid_json(decoded_output) ? JSON.parse(decoded_output) : null;
|
|
35
36
|
|
|
36
37
|
get({
|
|
37
38
|
get_name: getter_name,
|