@joystick.js/node-canary 0.0.0-canary.387 → 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 f from"./format_api_error.js";import g from"./get.js";import d from"./get_api_context.js";import y from"./get_api_url_component.js";import h from"./handle_api_error.js";import p from"../../lib/is_valid_json.js";import w from"../../lib/types.js";import v from"./validate_session.js";const x=(u={},n=[],_={},m={})=>{for(let r=0;r<n?.length;r+=1){const[s,i]=n[r];u.get(`/api/_getters/${y(s)}`,...w.is_array(i?.middleware)?i?.middleware:[],async(t={},e={})=>{if(process.databases?._sessions&&!await v(t,e))return e.status(403).send(JSON.stringify({errors:[f(new Error("Unauthorized request."))]}));const l=await d(t,e,_),a=p(t?.query?.input)?JSON.parse(t?.query?.input):null;console.log(a);const c=p(t?.query?.output)?JSON.parse(t?.query?.output):null;g({get_name:s,get_options:{input:a,output:c},getter_definition:i,request_context:l,api_schema_options:m}).then(o=>e.status(200).send(JSON.stringify(o))).catch(o=>{h(`api.getters.${s}`,o,e)})})}};var z=x;export{z as default};
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
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@joystick.js/node-canary",
3
3
  "type": "module",
4
- "version": "0.0.0-canary.387",
4
+ "version": "0.0.0-canary.389",
5
5
  "description": "The Node.js framework for Joystick.",
6
6
  "main": "./dist/index.js",
7
7
  "scripts": {
@@ -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
- const input = is_valid_json(req?.query?.input) ? JSON.parse(req?.query?.input) : null;
31
-
32
- console.log(input);
33
30
 
34
- const output = is_valid_json(req?.query?.output) ? JSON.parse(req?.query?.output) : null;
31
+ const decoded_input = decodeURIComponent(req?.query?.input);
32
+ const input = is_valid_json(decoded_input) ? JSON.parse(decoded_input) : null;
33
+
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,