@joystick.js/node-canary 0.0.0-canary.57 → 0.0.0-canary.58

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.
package/dist/app/index.js CHANGED
@@ -35,6 +35,9 @@ import generateMachineId from "../lib/generateMachineId.js";
35
35
  import importFile from "../lib/importFile.js";
36
36
  import emitWebsocketEvent from "../websockets/emitWebsocketEvent.js";
37
37
  import getTargetDatabaseConnection from "./databases/getTargetDatabaseConnection.js";
38
+ import getAPIForDataFunctions from "../ssr/getAPIForDataFunctions.js";
39
+ import getBrowserSafeRequest from "./getBrowserSafeRequest.js";
40
+ import getDataFromComponent from "../ssr/getDataFromComponent.js";
38
41
  process.setMaxListeners(0);
39
42
  class App {
40
43
  constructor(options = {}) {
@@ -166,7 +169,12 @@ class App {
166
169
  const Component = req?.query?.pathToComponent ? await importFile(`${process.cwd()}/.joystick/build/${req?.query?.pathToComponent}`) : null;
167
170
  if (Component) {
168
171
  const componentInstance = Component();
169
- console.log(componentInstance);
172
+ const apiForDataFunctions = await getAPIForDataFunctions(req, this?.options?.api);
173
+ const browserSafeRequest = getBrowserSafeRequest(req);
174
+ const data = await getDataFromComponent(componentInstance, apiForDataFunctions, browserSafeRequest);
175
+ console.log({
176
+ data
177
+ });
170
178
  }
171
179
  res.status(200).send({
172
180
  ping: "pong",
@@ -0,0 +1,33 @@
1
+ import get from "../api/get";
2
+ import set from "../api/set";
3
+ var getAPIForDataFunctions_default = (req = {}, api = {}) => {
4
+ try {
5
+ return {
6
+ get: (getterName = "", getterOptions = {}) => {
7
+ return get({
8
+ getterName,
9
+ getterOptions: api?.getters[getterName] || {},
10
+ input: getterOptions?.input,
11
+ output: getterOptions?.output,
12
+ context: req?.context,
13
+ APIOptions: api?.options
14
+ });
15
+ },
16
+ set: (setterName = "", setterOptions = {}) => {
17
+ return set({
18
+ setterName,
19
+ setterOptions: api?.setters[setterName] || {},
20
+ input: setterOptions?.input,
21
+ output: setterOptions?.output,
22
+ context: req?.context,
23
+ APIOptions: api?.options
24
+ });
25
+ }
26
+ };
27
+ } catch (exception) {
28
+ throw new Error(`[ssr.getAPIForDataFunctions] ${exception.message}`);
29
+ }
30
+ };
31
+ export {
32
+ getAPIForDataFunctions_default as default
33
+ };
package/dist/ssr/index.js CHANGED
@@ -9,6 +9,7 @@ import replaceWhenTags from "./replaceWhenTags";
9
9
  import setHeadTagsInHTML from "./setHeadTagsInHTML";
10
10
  import { parseHTML } from "linkedom";
11
11
  import getDataFromComponent from "./getDataFromComponent.js";
12
+ import getAPIForDataFunctions from "./getAPIForDataFunctions.js";
12
13
  const injectCSSIntoHTML = (html, baseCSS = "", css = "") => {
13
14
  try {
14
15
  return html.replace("${css}", css).replace("${globalCSS}", `<style>${baseCSS || ""}</style>`).replace("${componentCSS}", css);
@@ -311,34 +312,6 @@ const getComponentInstance = (Component, options = {}) => {
311
312
  throw new Error(`[ssr.getComponentInstance] ${exception.message}`);
312
313
  }
313
314
  };
314
- const getAPIForDataFunctions = (req = {}, api = {}) => {
315
- try {
316
- return {
317
- get: (getterName = "", getterOptions = {}) => {
318
- return get({
319
- getterName,
320
- getterOptions: api?.getters[getterName] || {},
321
- input: getterOptions?.input,
322
- output: getterOptions?.output,
323
- context: req?.context,
324
- APIOptions: api?.options
325
- });
326
- },
327
- set: (setterName = "", setterOptions = {}) => {
328
- return set({
329
- setterName,
330
- setterOptions: api?.setters[setterName] || {},
331
- input: setterOptions?.input,
332
- output: setterOptions?.output,
333
- context: req?.context,
334
- APIOptions: api?.options
335
- });
336
- }
337
- };
338
- } catch (exception) {
339
- throw new Error(`[ssr.getAPIForDataFunctions] ${exception.message}`);
340
- }
341
- };
342
315
  const validateOptions = (options) => {
343
316
  try {
344
317
  if (!options)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@joystick.js/node-canary",
3
- "version": "0.0.0-canary.57",
3
+ "version": "0.0.0-canary.58",
4
4
  "type": "module",
5
5
  "description": "A Node.js framework for building web apps.",
6
6
  "main": "./dist/index.js",