@joystick.js/node-canary 0.0.0-canary.466 → 0.0.0-canary.468
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 g from"./format_api_error.js";import y from"./get.js";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};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import c from"./format_api_error.js";import
|
|
1
|
+
import c from"./format_api_error.js";import d from"./get_api_context.js";import f from"./get_api_url_component.js";import g from"./handle_api_error.js";import y from"./set.js";import h from"../../lib/types.js";import w from"./validate_session.js";const x=(_={},n=[],m={},u={})=>{for(let e=0;e<n?.length;e+=1){const[r,i]=n[e];_.post(`/api/_setters/${f(r)}`,...h.is_array(i?.middleware)?i?.middleware:[],async(o={},t={})=>{if(process.databases?._sessions&&!await w(o,t))return t.status(403).send(JSON.stringify({errors:[c(new Error("Unauthorized request."))]}));const l=await d(o,t,m),a=o?.body?.input||null,p=o?.body?.output||null;console.log({input:a,output:p}),y({set_name:r,set_options:{input:a,output:p},setter_definition:i,request_context:l,api_schema_options:u}).then(s=>t.status(200).send(JSON.stringify(s))).catch(s=>{g(`api.setters.${r}`,s,t)})})}};var z=x;export{z as default};
|
package/package.json
CHANGED
|
@@ -10,7 +10,6 @@ import validate_session from "./validate_session.js";
|
|
|
10
10
|
const register_getters = (express_app = {}, getter_definitions = [], api_context = {}, api_schema_options = {}) => {
|
|
11
11
|
for (let i = 0; i < getter_definitions?.length; i += 1) {
|
|
12
12
|
const [getter_name, getter_definition] = getter_definitions[i];
|
|
13
|
-
console.log('HERE', getter_definition?.middleware);
|
|
14
13
|
express_app.get(
|
|
15
14
|
`/api/_getters/${get_api_url_component(getter_name)}`,
|
|
16
15
|
...(types.is_array(getter_definition?.middleware) ? getter_definition?.middleware : []),
|
|
@@ -32,6 +32,11 @@ const register_setters = (express_app = {}, setter_definitions = [], api_context
|
|
|
32
32
|
const input = req?.body?.input || null;
|
|
33
33
|
const output = req?.body?.output || null;
|
|
34
34
|
|
|
35
|
+
console.log({
|
|
36
|
+
input,
|
|
37
|
+
output,
|
|
38
|
+
});
|
|
39
|
+
|
|
35
40
|
set({
|
|
36
41
|
set_name: setter_name,
|
|
37
42
|
set_options: {
|